← Back to team overview

ayatana-commits team mailing list archive

[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 159: Putting the passing up the event stack in a timeout.

 

Merge authors:
  Ted Gould (ted)
Related merge proposals:
  https://code.launchpad.net/~ted/dbusmenu/messages-and-signals/+merge/35456
  proposed by: Ted Gould (ted)
  review: Approve - Cody Russell (bratsche)
------------------------------------------------------------
revno: 159 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-09-14 16:21:28 -0500
message:
  Putting the passing up the event stack in a timeout.
modified:
  libdbusmenu-glib/server.c


--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk

Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-glib/server.c'
--- libdbusmenu-glib/server.c	2010-08-20 19:50:41 +0000
+++ libdbusmenu-glib/server.c	2010-09-14 18:34:32 +0000
@@ -659,6 +659,33 @@
 	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 @@
 		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;
 }