aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtopmenu-client/topmenu-client.c4
-rw-r--r--libtopmenu-server/topmenu-widget.c17
2 files changed, 13 insertions, 8 deletions
diff --git a/libtopmenu-client/topmenu-client.c b/libtopmenu-client/topmenu-client.c
index 46bf714..0f95c2f 100644
--- a/libtopmenu-client/topmenu-client.c
+++ b/libtopmenu-client/topmenu-client.c
@@ -106,10 +106,6 @@ void topmenu_client_connect_window_widget(GdkWindow *window, GtkWidget *widget)
G_CALLBACK(handle_widget_button_event), plug, 0);
gtk_widget_show(GTK_WIDGET(plug));
- // Gtk+ should keep a reference to plug as it is a "top level" widget.
- // Otherwise I failed to parse the documentation.
- g_warn_if_fail(G_OBJECT(plug)->ref_count == 1);
-
Window plug_xwin = gtk_plug_get_id(plug);
Atom atom = XInternAtom(display, ATOM_TOPMENU_WINDOW, False);
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