From ca2d031cddf6948f646a67305619e556c4986f61 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 7 Aug 2016 00:08:06 +0200 Subject: fix potential client crash after applet crash --- libtopmenu-client/topmenu-monitor.c | 5 +++-- libtopmenu-client/topmenu-monitor.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libtopmenu-client/topmenu-monitor.c b/libtopmenu-client/topmenu-monitor.c index c67e3cd..915bc47 100644 --- a/libtopmenu-client/topmenu-monitor.c +++ b/libtopmenu-client/topmenu-monitor.c @@ -55,10 +55,10 @@ static GdkFilterReturn handle_cur_server_event(GdkXEvent *xevent, GdkEvent *even { XEvent *e = (XEvent*)xevent; if (e->type == DestroyNotify) { - g_debug("Current server has been destroyed"); TopMenuMonitor *self = TOPMENU_MONITOR(data); if (self->priv->cur_server && GDK_WINDOW_XID(self->priv->cur_server) == e->xdestroywindow.window) { + g_debug("Current server has been destroyed"); topmenu_monitor_update(self); } } @@ -71,13 +71,14 @@ static void topmenu_monitor_set_cur_server(TopMenuMonitor *self, GdkWindow *wind // Nothing to do return; } - g_debug("Setting current server to 0x%lx", GDK_WINDOW_XID(window)); if (self->priv->cur_server) { + g_debug("Removing current server"); gdk_window_remove_filter(window, handle_cur_server_event, self); g_object_unref(self->priv->cur_server); self->priv->cur_server = 0; } if (window) { + g_debug("Setting current server to 0x%lx", GDK_WINDOW_XID(window)); gdk_window_set_events(window, gdk_window_get_events(window) | GDK_STRUCTURE_MASK); gdk_window_add_filter(window, handle_cur_server_event, self); self->priv->cur_server = window; diff --git a/libtopmenu-client/topmenu-monitor.h b/libtopmenu-client/topmenu-monitor.h index 1128d6d..ed0cae3 100644 --- a/libtopmenu-client/topmenu-monitor.h +++ b/libtopmenu-client/topmenu-monitor.h @@ -31,6 +31,8 @@ G_BEGIN_DECLS #define TOPMENU_IS_MONITOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), TOPMENU_TYPE_MONITOR)) #define TOPMENU_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOPMENU_TYPE_MONITOR, TopMenuMonitorClass)) +/** The monitor object can be used to detect whether there is a TopMenu applet + on the current default display, and to be notified when the applet dies. */ typedef struct _TopMenuMonitor TopMenuMonitor; typedef struct _TopMenuMonitorClass TopMenuMonitorClass; typedef struct _TopMenuMonitorPrivate TopMenuMonitorPrivate; @@ -51,6 +53,8 @@ GType topmenu_monitor_get_type(void); TopMenuMonitor * topmenu_monitor_get_instance(void); +/** Returns TRUE if there is a TopMenu applet on the current default display. + Subscribe to the property notification signal to monitor changes. */ gboolean topmenu_monitor_is_topmenu_available(TopMenuMonitor * self); G_END_DECLS -- cgit v1.2.3