[gtk+/gtk-2-24-win32] win32: Fix modal_hint handling



commit 4b5b28b64f2ae099682b3bd607f5a1db75131805
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 27 22:13:54 2011 +0200

    win32: Fix modal_hint handling
    
    Modal hints are not really a stack. All windows that are modal
    are allowed to get input, not just the top one.
    
    This fixes bug #604156

 gdk/win32/gdkevents-win32.c  |   22 ++++------------------
 gdk/win32/gdkprivate-win32.h |    2 +-
 gdk/win32/gdkwindow-win32.c  |   38 +++++++++++++++++++++++++++-----------
 3 files changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 99441e5..b3dd781 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -98,8 +98,6 @@ static gboolean gdk_event_dispatch (GSource     *source,
 				    GSourceFunc  callback,
 				    gpointer     user_data);
 
-static gboolean is_modally_blocked (GdkWindow   *window);
-
 /* Private variable declarations
  */
 
@@ -2761,15 +2759,10 @@ gdk_event_translate (MSG  *msg,
 	     return_val = TRUE;
 	   }
 
-	 tmp = _gdk_modal_current ();
-
-	 if (tmp != NULL)
+	 if (_gdk_modal_blocked (gdk_window_get_toplevel (window)))
 	   {
-	     if (gdk_window_get_toplevel (window) != tmp)
-	       {
-		 *ret_valp = MA_NOACTIVATEANDEAT;
-		 return_val = TRUE;
-	       }
+	     *ret_valp = MA_NOACTIVATEANDEAT;
+	     return_val = TRUE;
 	   }
        }
 
@@ -3441,7 +3434,7 @@ gdk_event_translate (MSG  *msg,
        * but we still need to deal with alt-tab, or with SetActiveWindow() type
        * situations.
        */
-      if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
+      if (_gdk_modal_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
 	{
 	  GdkWindow *modal_current = _gdk_modal_current ();
 	  SetActiveWindow (GDK_WINDOW_HWND (modal_current));
@@ -3607,13 +3600,6 @@ gdk_win32_set_modal_dialog_libgtk_only (HWND window)
   modal_win32_dialog = window;
 }
 
-static gboolean
-is_modally_blocked (GdkWindow *window)
-{
-  GdkWindow *modal_current = _gdk_modal_current ();
-  return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
-}
-
 static void
 check_for_too_much_data (GdkEvent *event)
 {
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 1fb28a0..f9779f7 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -305,7 +305,7 @@ void    _gdk_wchar_text_handle    (GdkFont       *font,
 void       _gdk_push_modal_window   (GdkWindow *window);
 void       _gdk_remove_modal_window (GdkWindow *window);
 GdkWindow *_gdk_modal_current       (void);
-
+gboolean   _gdk_modal_blocked       (GdkWindow *window);
 
 #ifdef G_ENABLE_DEBUG
 gchar *_gdk_win32_color_to_string      (const GdkColor *color);
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 98a14ef..19652f2 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -2135,24 +2135,40 @@ _gdk_remove_modal_window (GdkWindow *window)
     }
 }
 
-GdkWindow *
-_gdk_modal_current (void)
+gboolean
+_gdk_modal_blocked (GdkWindow *window)
 {
-  if (modal_window_stack != NULL)
+  GSList *l;
+  gboolean found_any = FALSE;
+
+  for (l = modal_window_stack; l != NULL; l = l->next)
     {
-      GSList *tmp = modal_window_stack;
+      GdkWindow *modal = l->data;
 
-      while (tmp != NULL && !GDK_WINDOW_IS_MAPPED (tmp->data))
-	{
-	  tmp = g_slist_next (tmp);
-	}
+      if (modal == window)
+	return FALSE;
 
-      return tmp != NULL ? tmp->data : NULL;
+      if (GDK_WINDOW_IS_MAPPED (modal))
+	found_any = TRUE;
     }
-  else
+
+  return found_any;
+}
+
+GdkWindow *
+_gdk_modal_current (void)
+{
+  GSList *l;
+
+  for (l = modal_window_stack; l != NULL; l = l->next)
     {
-      return NULL;
+      GdkWindow *modal = l->data;
+
+      if (GDK_WINDOW_IS_MAPPED (modal))
+	return modal;
     }
+
+  return NULL;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]