[gtk+/gtk-2-24-win32] win32: More robust way to ensure we get a configure event after move/resize



commit ac00340d4c67db25874f45ef9d1f85d64af5daba
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Oct 27 10:42:07 2011 +0200

    win32: More robust way to ensure we get a configure event after move/resize
    
    There were still cases where we didn't get a WINDOWPOSCHANGED after
    a SetWindowPos() call, like e.g. with a larger minimum size than
    the set size (bug #574935)
    
    So, we revert the previous fix and now just always manually emit
    a configure notify after the move_resize call. Also, we inhibit
    the WINDOWPOSCHANGED configure event during the move_resize operation
    to avoid multiple Configures.

 gdk/win32/gdkevents-win32.c |    9 +++++-
 gdk/win32/gdkwindow-win32.c |   58 ++++++++++++-------------------------------
 gdk/win32/gdkwindow-win32.h |    1 +
 3 files changed, 24 insertions(+), 44 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index a046975..e7caf9c 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -1639,11 +1639,18 @@ doesnt_want_char (gint mask,
 void
 _gdk_win32_emit_configure_event (GdkWindow *window)
 {
+  GdkWindowImplWin32 *window_impl;
   RECT client_rect;
   POINT point;
   GdkWindowObject *window_object;
   HWND hwnd;
 
+  window_object = GDK_WINDOW_OBJECT (window);
+
+  window_impl = GDK_WINDOW_IMPL_WIN32 (window_object->impl);
+  if (window_impl->inhibit_configure)
+    return;
+
   hwnd = GDK_WINDOW_HWND (window);
 
   GetClientRect (hwnd, &client_rect);
@@ -1658,8 +1665,6 @@ _gdk_win32_emit_configure_event (GdkWindow *window)
       point.y += _gdk_offset_y;
     }
 
-  window_object = GDK_WINDOW_OBJECT (window);
-
   window_object->width = client_rect.right - client_rect.left;
   window_object->height = client_rect.bottom - client_rect.top;
   
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 47e4d44..505a52f 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -1170,10 +1170,7 @@ gdk_win32_window_move (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
 
   if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
-    {
-      _gdk_win32_emit_configure_event (window);
-      return;
-    }
+    return;
 
   /* Don't check GDK_WINDOW_TYPE (private) == GDK_WINDOW_CHILD.
    * Foreign windows (another app's windows) might be children of our
@@ -1186,7 +1183,6 @@ gdk_win32_window_move (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, private->width, private->height, &outer_rect);
 
@@ -1200,14 +1196,6 @@ gdk_win32_window_move (GdkWindow *window,
       API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
                                x - _gdk_offset_x, y - _gdk_offset_y, 0, 0,
                                SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
-
-      /* Ensure we always send a configure event, and SetWindowPos doesn't if the window
-	 is maximized, or the position/size doesn't change */
-      GetWindowRect (GDK_WINDOW_HWND (window), &current_rect);
-      if (IsZoomed (GDK_WINDOW_HWND (window)) ||
-	  (current_rect.left == x - _gdk_offset_x &&
-	   current_rect.top == y - _gdk_offset_y))
-	_gdk_win32_emit_configure_event (window);
     }
 }
 
@@ -1234,10 +1222,7 @@ gdk_win32_window_resize (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
 
   if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
-    {
-      _gdk_win32_emit_configure_event (window);
-      return;
-    }
+    return;
 
   if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
     {
@@ -1246,7 +1231,6 @@ gdk_win32_window_resize (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1262,14 +1246,6 @@ gdk_win32_window_resize (GdkWindow *window,
                                outer_rect.bottom - outer_rect.top,
                                SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
       private->resize_count += 1;
-
-      /* Ensure we always send a configure event, and SetWindowPos doesn't if the window
-	 is maximized, or the position/size doesn't change */
-      GetWindowRect (GDK_WINDOW_HWND (window), &current_rect);
-      if (IsZoomed (GDK_WINDOW_HWND (window)) ||
-	  (current_rect.right - current_rect.left == outer_rect.right - outer_rect.left &&
-	   current_rect.bottom - current_rect.top == outer_rect.bottom - outer_rect.top))
-	_gdk_win32_emit_configure_event (window);
     }
 }
 
@@ -1297,10 +1273,7 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
 
   if (private->state & GDK_WINDOW_STATE_FULLSCREEN)
-    {
-      _gdk_win32_emit_configure_event (window);
-      return;
-    }
+    return;
 
   GDK_NOTE (MISC, g_print ("gdk_win32_window_move_resize: %p: %dx%d %+d%+d\n",
                            GDK_WINDOW_HWND (window),
@@ -1313,7 +1286,6 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1331,16 +1303,6 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
                                outer_rect.right - outer_rect.left,
                                outer_rect.bottom - outer_rect.top,
                                SWP_NOACTIVATE | SWP_NOZORDER));
-
-      /* Ensure we always send a configure event, and SetWindowPos doesn't if the window
-	 is maximized, or the position/size doesn't change */
-      GetWindowRect (GDK_WINDOW_HWND (window), &current_rect);
-      if (IsZoomed (GDK_WINDOW_HWND (window)) ||
-	  (current_rect.left == x - _gdk_offset_x &&
-	   current_rect.top == y - _gdk_offset_y &&
-	   current_rect.right - current_rect.left == outer_rect.right - outer_rect.left &&
-	   current_rect.bottom - current_rect.top == outer_rect.bottom - outer_rect.top))
-	_gdk_win32_emit_configure_event (window);
     }
 }
 
@@ -1352,10 +1314,16 @@ gdk_win32_window_move_resize (GdkWindow *window,
 			      gint       width,
 			      gint       height)
 {
+  GdkWindowObject *private = (GdkWindowObject *)window;
+  GdkWindowImplWin32 *window_impl;
+
+  window_impl = GDK_WINDOW_IMPL_WIN32 (private->impl);
+  window_impl->inhibit_configure = TRUE;
+
   /* We ignore changes to the window being moved or resized by the 
      user, as we don't want to fight the user */
   if (GDK_WINDOW_HWND (window) == _modal_move_resize_window)
-    return;
+    goto out;
 
   if (with_move && (width < 0 && height < 0))
     {
@@ -1372,6 +1340,12 @@ gdk_win32_window_move_resize (GdkWindow *window,
 	  gdk_win32_window_resize (window, width, height);
 	}
     }
+
+ out:
+  window_impl->inhibit_configure = FALSE;
+
+  if (WINDOW_IS_TOPLEVEL (window))
+    _gdk_win32_emit_configure_event (window);
 }
 
 static gboolean
diff --git a/gdk/win32/gdkwindow-win32.h b/gdk/win32/gdkwindow-win32.h
index 1ba1ed3..6845e76 100644
--- a/gdk/win32/gdkwindow-win32.h
+++ b/gdk/win32/gdkwindow-win32.h
@@ -92,6 +92,7 @@ struct _GdkWindowImplWin32
   gboolean   changing_state;
 
   guint no_bg : 1;
+  guint inhibit_configure : 1;
 };
  
 struct _GdkWindowImplWin32Class 



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