diff options
author | Aurelien Gateau <aurelien.gateau@canonical.com> | 2010-07-20 14:58:16 +0200 |
---|---|---|
committer | Aurelien Gateau <aurelien.gateau@canonical.com> | 2010-07-20 14:58:16 +0200 |
commit | 463b05a77a8e21e60ffe197f58461b0fb02ed930 (patch) | |
tree | 5da34c96bfc83850a68f22b961e5b05177f50979 /tools | |
parent | 646c74694e86d6e5d479028a7dbd8cf9a1aca37a (diff) | |
download | libdbusmenu-463b05a77a8e21e60ffe197f58461b0fb02ed930.tar.gz libdbusmenu-463b05a77a8e21e60ffe197f58461b0fb02ed930.tar.bz2 libdbusmenu-463b05a77a8e21e60ffe197f58461b0fb02ed930.zip |
Clean up
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dbusmenu-dumper.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 3a47f21..4ddb057 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -104,17 +104,17 @@ click_filter (GdkXEvent *gdk_xevent, gpointer data); static Window -find_real_window(Display * display, Window w, int depth) +find_real_window (Window w, int depth) { if (depth > 5) { return None; } - /*static*/ Atom wm_state = XInternAtom(display, "WM_STATE", False); + /*static*/ Atom wm_state = XInternAtom(gdk_display, "WM_STATE", False); Atom type; int format; unsigned long nitems, after; unsigned char* prop; - if (XGetWindowProperty(display, w, wm_state, 0, 0, False, AnyPropertyType, + if (XGetWindowProperty(gdk_display, w, wm_state, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &prop) == Success) { if (prop != NULL) { XFree(prop); @@ -127,10 +127,10 @@ find_real_window(Display * display, Window w, int depth) Window* children; unsigned int nchildren; Window ret = None; - if (XQueryTree(display, w, &root, &parent, &children, &nchildren) != 0) { + if (XQueryTree(gdk_display, w, &root, &parent, &children, &nchildren) != 0) { unsigned int i; for(i = 0; i < nchildren && ret == None; ++i) { - ret = find_real_window(display, children[ i ], depth + 1); + ret = find_real_window(children[ i ], depth + 1); } if (children != NULL) { XFree(children); @@ -140,22 +140,17 @@ find_real_window(Display * display, Window w, int depth) } static Window -get_window_under_cursor() +get_window_under_cursor (void) { - Display * display = XOpenDisplay(NULL); - g_return_val_if_fail(display != NULL, None); - Window root; Window child; uint mask; int rootX, rootY, winX, winY; - XGrabServer(display); - Window root_window = DefaultRootWindow(display); - XQueryPointer(display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &mask); + XQueryPointer(gdk_display, gdk_x11_get_default_root_xwindow(), &root, &child, &rootX, &rootY, &winX, &winY, &mask); if (child == None) { return None; } - return find_real_window(display, child, 0); + return find_real_window(child, 0); } static void @@ -234,9 +229,8 @@ install_click_filter (gpointer data) } static gboolean -wait_for_click (int argc, char **argv) +wait_for_click (void) { - gtk_init(&argc, &argv); gboolean success; g_idle_add (install_click_filter, (gpointer)(&success)); gtk_main (); @@ -341,7 +335,8 @@ main (int argc, char ** argv) } if (dbusname == NULL && dbusobject == NULL) { - if (!wait_for_click(argc, argv)) { + gtk_init(&argc, &argv); + if (!wait_for_click()) { return 1; } Window window = get_window_under_cursor(); |