aboutsummaryrefslogtreecommitdiff
path: root/libtopmenu-server
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-02-15 03:57:49 +0100
committerJavier <dev.git@javispedro.com>2015-02-15 03:57:49 +0100
commitd82d349daa3fdccbef0186ae19311004c4bb2434 (patch)
tree81192b3ce05e59005e2885bd04d6461586146bf2 /libtopmenu-server
parentf0d43c65fe9c6b258a92ae9dfd612eae0060754b (diff)
downloadtopmenu-gtk-d82d349daa3fdccbef0186ae19311004c4bb2434.tar.gz
topmenu-gtk-d82d349daa3fdccbef0186ae19311004c4bb2434.zip
be slightly more reliable when following destroyed windows
Diffstat (limited to 'libtopmenu-server')
-rw-r--r--libtopmenu-server/topmenu-widget.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libtopmenu-server/topmenu-widget.c b/libtopmenu-server/topmenu-widget.c
index 9c8092b..762a792 100644
--- a/libtopmenu-server/topmenu-widget.c
+++ b/libtopmenu-server/topmenu-widget.c
@@ -232,13 +232,22 @@ static gboolean topmenu_widget_follow_window(TopMenuWidget *self, Window window)
return FALSE; // Ignore the window this widget is on as a candidate
}
- // Add this window to the list of windows we are following
- g_queue_push_head(&self->priv->followed_windows, GSIZE_TO_POINTER(window));
-
+ gdk_error_trap_push();
XWindowAttributes win_attrs;
if (XGetWindowAttributes(dpy, window, &win_attrs)) {
- XSelectInput(dpy, window, win_attrs.your_event_mask | PropertyChangeMask);
+ long event_mask = win_attrs.your_event_mask | StructureNotifyMask | PropertyChangeMask;
+ if (event_mask != win_attrs.your_event_mask) {
+ XSelectInput(dpy, window, event_mask);
+ }
}
+ gdk_flush();
+ if (gdk_error_trap_pop()) {
+ g_debug("got error while trying to follow window 0x%lx", window);
+ return FALSE; // Assume window has been destroyed.
+ }
+
+ // Add this window to the list of windows we are following
+ g_queue_push_head(&self->priv->followed_windows, GSIZE_TO_POINTER(window));
if (topmenu_widget_try_window(self, window)) {
// Found a menu bar on this window