]> Pileus Git - ~andy/gtk/commitdiff
On Win32 call gtk_status_icon_button_press() in an idle callback and not
authorTor Lillqvist <tml@novell.com>
Wed, 4 Jul 2007 08:20:18 +0000 (08:20 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Wed, 4 Jul 2007 08:20:18 +0000 (08:20 +0000)
2007-07-04  Tor Lillqvist  <tml@novell.com>

* gtk/gtkstatusicon.c: On Win32 call
gtk_status_icon_button_press() in an idle callback and not
directly from the window procedure to avoid "g_main_loop_run():
called recursively from within a source's check() or prepare()
member, iteration not possible" warnings.

svn path=/trunk/; revision=18377

ChangeLog
gtk/gtkstatusicon.c

index e0a7d456176a74e790f3bda3cfb1599ed59e3be4..02273abbbb08df379d3a6d99ea0a2140e1ff80bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-07-04  Tor Lillqvist  <tml@novell.com>
+
+       * gtk/gtkstatusicon.c: On Win32 call
+       gtk_status_icon_button_press() in an idle callback and not
+       directly from the window procedure to avoid "g_main_loop_run():
+       called recursively from within a source's check() or prepare()
+       member, iteration not possible" warnings.
+
 2007-07-04  Chris Wilson  <chris@chris-wilson.co.uk>
 
        * gtk/gtkrecentchoosermenu.c (idle_populate_func),
index c55948001275787e791729861dcab09913506542..5355183f915c55a78ebb57f657d887f0a76821f2 100755 (executable)
@@ -362,7 +362,6 @@ gtk_status_icon_class_init (GtkStatusIconClass *class)
 static void
 build_button_event (GtkStatusIconPrivate *priv,
                    GdkEventButton       *e,
-                   GdkEventType          type,
                    guint                 button)
 {
   POINT pos;
@@ -370,8 +369,7 @@ build_button_event (GtkStatusIconPrivate *priv,
 
   /* We know that gdk/win32 puts the primary monitor at index 0 */
   gdk_screen_get_monitor_geometry (gdk_screen_get_default (), 0, &monitor0);
-  e->type = type;
-  e->window = gdk_get_default_root_window ();
+  e->window = g_object_ref (gdk_get_default_root_window ());
   e->send_event = TRUE;
   e->time = GetTickCount ();
   GetCursorPos (&pos);
@@ -385,6 +383,25 @@ build_button_event (GtkStatusIconPrivate *priv,
   e->y_root = e->y;
 }
 
+typedef struct
+{
+  GtkStatusIcon *status_icon;
+  GdkEventButton *event;
+} ButtonCallbackData;
+
+static gboolean
+button_callback (gpointer data)
+{
+  ButtonCallbackData *bc = (ButtonCallbackData *) data;
+
+  gtk_status_icon_button_press (bc->status_icon, bc->event);
+
+  gdk_event_free ((GdkEvent *) bc->event);
+  g_free (data);
+
+  return FALSE;
+}
+
 static LRESULT CALLBACK
 wndproc (HWND   hwnd,
         UINT   message,
@@ -393,16 +410,17 @@ wndproc (HWND   hwnd,
 {
   if (message == WM_GTK_TRAY_NOTIFICATION)
     {
-      GdkEventButton e;
-      GtkStatusIcon *status_icon = GTK_STATUS_ICON (wparam);
+      ButtonCallbackData *bc;
       
       switch (lparam)
        {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
-         build_button_event (status_icon->priv, &e, GDK_BUTTON_PRESS,
-                             (lparam == WM_LBUTTONDOWN) ? 1 : 3);
-         gtk_status_icon_button_press (status_icon, &e);
+         bc = g_new (ButtonCallbackData, 1);
+         bc->event = (GdkEventButton *) gdk_event_new (GDK_BUTTON_PRESS);
+         bc->status_icon = GTK_STATUS_ICON (wparam);
+         build_button_event (bc->status_icon->priv, bc->event, (lparam == WM_LBUTTONDOWN) ? 1 : 3);
+         g_idle_add (button_callback, bc);
          break;
        default :
          break;