]> Pileus Git - ~andy/gtk/commitdiff
win32: More robust way to ensure we get a configure event after move/resize
authorAlexander Larsson <alexl@redhat.com>
Thu, 27 Oct 2011 08:42:07 +0000 (10:42 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 10 Nov 2011 16:41:05 +0000 (17:41 +0100)
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
gdk/win32/gdkwindow-win32.c
gdk/win32/gdkwindow-win32.h

index ebb36c03ce6c014c622f645e0db804d3dc2d1309..bfb56092a907912e0023b7fffe54338b302e6e89 100644 (file)
@@ -1478,10 +1478,15 @@ doesnt_want_char (gint mask,
 void
 _gdk_win32_emit_configure_event (GdkWindow *window)
 {
+  GdkWindowImplWin32 *window_impl;
   RECT client_rect;
   POINT point;
   HWND hwnd;
 
+  window_impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
+  if (window_impl->inhibit_configure)
+    return;
+
   hwnd = GDK_WINDOW_HWND (window);
 
   GetClientRect (hwnd, &client_rect);
index c1a78580768c984c97796e5944646471a45c212e..2b3317860fca2e75115de8340f7645537ebdebdb 100644 (file)
@@ -1066,10 +1066,7 @@ gdk_win32_window_move (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
-    {
-      _gdk_win32_emit_configure_event (window);
-      return;
-    }
+    return;
 
   /* Don't check GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD.
    * Foreign windows (another app's windows) might be children of our
@@ -1082,7 +1079,6 @@ gdk_win32_window_move (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, window->width, window->height, &outer_rect);
 
@@ -1096,14 +1092,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);
     }
 }
 
@@ -1129,10 +1117,7 @@ gdk_win32_window_resize (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
-    {
-      _gdk_win32_emit_configure_event (window);
-      return;
-    }
+    return;
 
   if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
     {
@@ -1141,7 +1126,6 @@ gdk_win32_window_resize (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1157,14 +1141,6 @@ gdk_win32_window_resize (GdkWindow *window,
                                outer_rect.bottom - outer_rect.top,
                                SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
       window->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);
     }
 }
 
@@ -1190,10 +1166,7 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->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),
@@ -1206,7 +1179,6 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   else
     {
       RECT outer_rect;
-      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1224,16 +1196,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);
     }
 }
 
@@ -1245,10 +1207,15 @@ gdk_win32_window_move_resize (GdkWindow *window,
                              gint       width,
                              gint       height)
 {
+  GdkWindowImplWin32 *window_impl;
+
+  window_impl = GDK_WINDOW_IMPL_WIN32 (window->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))
     {
@@ -1265,6 +1232,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
index 8aad9d3dada82c1b3b1718cbbd0a56c8c606174c..648ae116d0bf0513673732d130eefd66d7e96486 100644 (file)
@@ -77,6 +77,7 @@ struct _GdkWindowImplWin32
   gboolean   changing_state;
 
   guint no_bg : 1;
+  guint inhibit_configure : 1;
 
   cairo_surface_t *cairo_surface;
   HDC              hdc;