diff options
author | Ted Gould <ted@gould.cx> | 2010-09-14 16:26:34 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-09-14 16:26:34 -0500 |
commit | 7d11db0d26f2353db16100e21df9c55a2e57fa9e (patch) | |
tree | 1fcc9be41a15b1f3fa541e7835f4d9ca9c309aca /libdbusmenu-glib | |
parent | c732391fbdece4d144e8e3f40cb0bf00b2c64f14 (diff) | |
parent | 3c00a42823a7dd818732412d4034a9866388f812 (diff) | |
download | libdbusmenu-7d11db0d26f2353db16100e21df9c55a2e57fa9e.tar.gz libdbusmenu-7d11db0d26f2353db16100e21df9c55a2e57fa9e.tar.bz2 libdbusmenu-7d11db0d26f2353db16100e21df9c55a2e57fa9e.zip |
* Upstream Merge
* Making a callback for the event dbus function happen off
of the mainloop so it returns a response. (LP: #636756)
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/server.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 26e7a0d..d2f4096 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -659,6 +659,33 @@ _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * pro return TRUE; } +/* Structure for holding the event data for the idle function + to pick it up. */ +typedef struct _idle_event_t idle_event_t; +struct _idle_event_t { + DbusmenuMenuitem * mi; + gchar * eventid; + GValue data; + guint timestamp; +}; + +/* A handler for else where in the main loop so that the dbusmenu + event response doesn't get blocked */ +static gboolean +event_local_handler (gpointer user_data) +{ + idle_event_t * data = (idle_event_t *)user_data; + + dbusmenu_menuitem_handle_event(data->mi, data->eventid, &data->data, data->timestamp); + + g_object_unref(data->mi); + g_free(data->eventid); + g_value_unset(&data->data); + g_free(data); + return FALSE; +} + +/* Handles the even coming off of DBus */ static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error) { @@ -676,7 +703,15 @@ _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValu return FALSE; } - dbusmenu_menuitem_handle_event(mi, eventid, data, timestamp); + idle_event_t * event_data = g_new0(idle_event_t, 1); + event_data->mi = mi; + g_object_ref(event_data->mi); + event_data->eventid = g_strdup(eventid); + event_data->timestamp = timestamp; + g_value_init(&(event_data->data), G_VALUE_TYPE(data)); + g_value_copy(data, &(event_data->data)); + + g_timeout_add(0, event_local_handler, event_data); return TRUE; } |