Skip to content
Browse files

Get rid of devil_display and use GDK_DISPLAY_XDISPLAY()

  • Loading branch information...
1 parent f3806c8 commit e82ae5ce5e0726f0c260aace970782534106f82f @plaes committed Aug 16, 2011
Showing with 22 additions and 21 deletions.
  1. +5 −5 src/actions.c
  2. +3 −6 src/devilspie.c
  3. +14 −10 src/xutils.c
View
10 src/actions.c
@@ -203,7 +203,7 @@ ESExpResult *func_geometry(ESExp *f, int argc, ESExpResult **argv, Context *c) {
/* try to set new position.. */
my_wnck_error_trap_push ();
- XMoveResizeWindow (devil_display,
+ XMoveResizeWindow (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
wnck_window_get_xid (c->window),
new_xoffset, new_yoffset,
new_width, new_height);
@@ -251,7 +251,7 @@ ESExpResult *func_center(ESExp *f, int argc, ESExpResult **argv, Context *c) {
/* Try to set new position.. */
my_wnck_error_trap_push ();
- XMoveWindow (devil_display,
+ XMoveWindow (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
wnck_window_get_xid (c->window),
xoffset, yoffset);
@@ -500,7 +500,7 @@ ESExpResult *func_set_viewport(ESExp *f, int argc, ESExpResult **argv, Context *
x = ((num - 1) * wnck_screen_get_width (screen)) - viewport_start + x;
my_wnck_error_trap_push ();
- XMoveResizeWindow (devil_display,
+ XMoveResizeWindow (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
wnck_window_get_xid (c->window),
x, y, width, height);
if (my_wnck_error_trap_pop ()) {
@@ -573,7 +573,7 @@ set_decorations (Context *c, gboolean decorate)
hints.decorations = decorate ? 1 : 0;
/* Set Motif hints, most window managers handle these */
- XChangeProperty(devil_display, wnck_window_get_xid (c->window),
+ XChangeProperty(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), wnck_window_get_xid (c->window),
my_wnck_atom_get ("_MOTIF_WM_HINTS"),
my_wnck_atom_get ("_MOTIF_WM_HINTS"), 32, PropModeReplace,
(unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
@@ -683,7 +683,7 @@ ESExpResult *func_opacity(ESExp *f, int argc, ESExpResult **argv, Context *c) {
}
my_wnck_error_trap_push ();
v=0xffffffff/100*opacity;
- XChangeProperty (devil_display, wnck_window_get_xid(c->window),
+ XChangeProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), wnck_window_get_xid(c->window),
my_wnck_atom_get ("_NET_WM_WINDOW_OPACITY"),
XA_CARDINAL, 32, PropModeReplace, (guchar *)&v, 1);
View
9 src/devilspie.c
@@ -68,7 +68,6 @@ static char **files = NULL;
*/
GMainLoop *loop = NULL;
-Display *devil_display;
/**
* Evaluate a s-expression.
*/
@@ -89,19 +88,17 @@ static void window_opened_cb(WnckScreen *screen, WnckWindow *window) {
/**
* Connect to every screen on this display and watch for new windows.
*/
-static Display *init_screens(void) {
+static void init_screens(void) {
int i;
- GdkDisplay *display = gdk_display_get_default();
- const int num_screens = gdk_display_get_n_screens (display);
+ const int num_screens = gdk_display_get_n_screens (gdk_display_get_default());
for (i = 0 ; i < num_screens; ++i) {
WnckScreen *screen = wnck_screen_get (i);
/* Connect a callback to the window opened event in libwnck */
g_signal_connect (screen, "window_opened", (GCallback)window_opened_cb, NULL);
/* TODO: broken at the moment due to wnck change */
//if (apply_to_existing) wnck_screen_force_update (screen);
}
- return GDK_DISPLAY_XDISPLAY(display);
}
/*
@@ -166,7 +163,7 @@ int main(int argc, char **argv) {
}
/* Connect to every screen */
- devil_display = init_screens ();
+ init_screens ();
/* Go go go! */
loop = g_main_loop_new (NULL, TRUE);
View
24 src/xutils.c
@@ -27,6 +27,10 @@
static GHashTable *atom_hash = NULL;
static GHashTable *reverse_atom_hash = NULL;
+/**
+ * Connect to every screen on this display and watch for new windows.
+ */
+
Atom
my_wnck_atom_get (const char *atom_name)
{
@@ -43,7 +47,7 @@ my_wnck_atom_get (const char *atom_name)
retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
if (!retval)
{
- retval = XInternAtom (devil_display, atom_name, FALSE);
+ retval = XInternAtom (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), atom_name, FALSE);
if (retval != None)
{
@@ -79,15 +83,15 @@ my_wnck_change_state (Screen *screen,
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
- xev.xclient.display = devil_display;
+ xev.xclient.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
xev.xclient.window = xwindow;
xev.xclient.message_type = my_wnck_atom_get ("_NET_WM_STATE");
xev.xclient.format = 32;
xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
xev.xclient.data.l[1] = state1;
xev.xclient.data.l[2] = state2;
- XSendEvent (devil_display,
+ XSendEvent (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
RootWindowOfScreen (screen),
False,
SubstructureRedirectMask | SubstructureNotifyMask,
@@ -103,7 +107,7 @@ my_wnck_error_trap_push (void)
int
my_wnck_error_trap_pop (void)
{
- XSync (devil_display, False);
+ XSync (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
return gdk_error_trap_pop ();
}
@@ -125,7 +129,7 @@ my_wnck_get_string_property_latin1 (Window xwindow,
my_wnck_error_trap_push ();
property = NULL;
- result = XGetWindowProperty (devil_display,
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
xwindow, atom,
0, G_MAXLONG,
False, AnyPropertyType, &type, &format, &nitems,
@@ -147,7 +151,7 @@ my_wnck_get_string_property_latin1 (Window xwindow,
pp = (long *)property; // we can assume (long *) since format == 32
if (nitems == 1)
{
- prop_name = XGetAtomName (devil_display, *pp);
+ prop_name = XGetAtomName (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), *pp);
if (prop_name)
{
retval = g_strdup (prop_name);
@@ -160,7 +164,7 @@ my_wnck_get_string_property_latin1 (Window xwindow,
prop_names[nitems] = NULL;
for (i=0; i < nitems; i++)
{
- prop_names[i] = XGetAtomName (devil_display, *pp++);
+ prop_names[i] = XGetAtomName (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), *pp++);
}
retval = g_strjoinv (", ", prop_names);
for (i=0; i < nitems; i++)
@@ -197,7 +201,7 @@ my_wnck_window_get_xscreen (WnckWindow *window)
XWindowAttributes attrs;
xid = wnck_window_get_xid (window);
- XGetWindowAttributes(devil_display, xid, &attrs);
+ XGetWindowAttributes(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), xid, &attrs);
return attrs.screen;
}
@@ -220,7 +224,7 @@ my_wnck_get_cardinal_list (Window xwindow,
my_wnck_error_trap_push ();
type = None;
- result = XGetWindowProperty (devil_display,
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
xwindow,
atom,
0, G_MAXLONG,
@@ -260,7 +264,7 @@ my_wnck_get_cardinal (Window xwindow,
my_wnck_error_trap_push ();
type = None;
- result = XGetWindowProperty (devil_display,
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
xwindow,
atom,
0, G_MAXLONG,

0 comments on commit e82ae5c

Please sign in to comment.
Something went wrong with that request. Please try again.