]> Pileus Git - ~andy/gtk/commitdiff
win32: Ensure we always send a configure event when changing size/pos
authorAlexander Larsson <alexl@redhat.com>
Wed, 26 Oct 2011 19:46:19 +0000 (21:46 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 10 Nov 2011 16:41:04 +0000 (17:41 +0100)
There are some cases where we don't get a WINDOWPOSCHANGE such that
we generate a configure event, even if we called gdk_window_move_resize()
or similar. For instance:
* The window is fullscreen
* The window is maximized
* The specified pos/size is the same as the current one

However, as per X11 ConfigureNotify semantics we *always* want one, or
we could run into issue like e.g. bug #537296 where we're waiting for
the CONFIGURE to call gdk_window_thaw_toplevel_updates_libgtk_only().

gdk/win32/gdkevents-win32.c
gdk/win32/gdkprivate-win32.h
gdk/win32/gdkwindow-win32.c

index 0182895d1c179c3b49653454a75ce9731a186ba4..ebb36c03ce6c014c622f645e0db804d3dc2d1309 100644 (file)
@@ -1475,21 +1475,23 @@ doesnt_want_char (gint mask,
   return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));
 }
 
-static void
-handle_configure_event (MSG       *msg,
-                       GdkWindow *window)
+void
+_gdk_win32_emit_configure_event (GdkWindow *window)
 {
   RECT client_rect;
   POINT point;
+  HWND hwnd;
+
+  hwnd = GDK_WINDOW_HWND (window);
 
-  GetClientRect (msg->hwnd, &client_rect);
+  GetClientRect (hwnd, &client_rect);
   point.x = client_rect.left; /* always 0 */
   point.y = client_rect.top;
 
   /* top level windows need screen coords */
   if (gdk_window_get_parent (window) == _gdk_root)
     {
-      ClientToScreen (msg->hwnd, &point);
+      ClientToScreen (hwnd, &point);
       point.x += _gdk_offset_x;
       point.y += _gdk_offset_y;
     }
@@ -2791,7 +2793,7 @@ gdk_event_translate (MSG  *msg,
          if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
              !IsIconic (msg->hwnd) &&
              !GDK_WINDOW_DESTROYED (window))
-           handle_configure_event (msg, window);
+           _gdk_win32_emit_configure_event (window);
 
          if (window->extension_events != 0)
            _gdk_device_wintab_update_window_coords (window);
index 9ecfc6e3f9f66d7f599426d84a097c82fc5da702..cdba1eb43f20f99c5dfe9b4f3b2e365f0567cd47 100644 (file)
@@ -496,6 +496,7 @@ GdkAtom _gdk_win32_display_manager_atom_intern (GdkDisplayManager *manager,
 gchar *_gdk_win32_display_manager_get_atom_name (GdkDisplayManager *manager, 
                                                 GdkAtom            atom);
 void _gdk_win32_append_event (GdkEvent *event);
+void _gdk_win32_emit_configure_event (GdkWindow *window);
 
 /* Initialization */
 void _gdk_win32_windowing_init (void);
index de66ac9361ec546ffa456a06556481978c4cbf15..c1a78580768c984c97796e5944646471a45c212e 100644 (file)
@@ -1066,7 +1066,10 @@ gdk_win32_window_move (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
-    return;
+    {
+      _gdk_win32_emit_configure_event (window);
+      return;
+    }
 
   /* Don't check GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD.
    * Foreign windows (another app's windows) might be children of our
@@ -1079,6 +1082,7 @@ gdk_win32_window_move (GdkWindow *window,
   else
     {
       RECT outer_rect;
+      RECT current_rect;
 
       get_outer_rect (window, window->width, window->height, &outer_rect);
 
@@ -1092,6 +1096,14 @@ 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);
     }
 }
 
@@ -1117,7 +1129,10 @@ gdk_win32_window_resize (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
-    return;
+    {
+      _gdk_win32_emit_configure_event (window);
+      return;
+    }
 
   if (GetAncestor (GDK_WINDOW_HWND (window), GA_PARENT) != GetDesktopWindow ())
     {
@@ -1126,6 +1141,7 @@ gdk_win32_window_resize (GdkWindow *window,
   else
     {
       RECT outer_rect;
+      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1141,6 +1157,14 @@ 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);
     }
 }
 
@@ -1166,7 +1190,10 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
 
   if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
-    return;
+    {
+      _gdk_win32_emit_configure_event (window);
+      return;
+    }
 
   GDK_NOTE (MISC, g_print ("gdk_win32_window_move_resize: %p: %dx%d@%+d%+d\n",
                            GDK_WINDOW_HWND (window),
@@ -1179,6 +1206,7 @@ gdk_win32_window_move_resize_internal (GdkWindow *window,
   else
     {
       RECT outer_rect;
+      RECT current_rect;
 
       get_outer_rect (window, width, height, &outer_rect);
 
@@ -1196,6 +1224,16 @@ 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);
     }
 }