summaryrefslogtreecommitdiff
path: root/gdk/win32
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2011-11-02 12:15:53 +0100
committerAlexander Larsson <alexl@redhat.com>2011-11-10 17:41:10 +0100
commitc563765574fea4e3afe2101f8c005f8b57dc2f66 (patch)
treec5a1afc48b759718d2c391da58bca1d64e65c140 /gdk/win32
parentd441044569f4fcf4e5f97d3c84056f1f6099d09b (diff)
downloadgtk+-c563765574fea4e3afe2101f8c005f8b57dc2f66.tar.gz
win32: Fix placement at initial position
Positioning windows at 0,0 post creation failed, because it was mapped with CW_USEDFAULT, but private->x/y still said 0, so moving it to 0,0 did nothing. We now always position the window at the right place, even when not mapped, but we create it at CW_USEDEFAULT initially and store that position before moving it to the right place. This fixes the window sizing test in testgtk and the inital position for the gimp toolbar.
Diffstat (limited to 'gdk/win32')
-rw-r--r--gdk/win32/gdkwindow-win32.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 6e39c981ce..f2154abf2f 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -445,7 +445,7 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
gboolean override_redirect;
gint window_width, window_height;
gint offset_x = 0, offset_y = 0;
- gint x, y;
+ gint x, y, real_x = 0, real_y = 0;
/* check consistency of redundant information */
guint remaining_mask = attributes_mask;
@@ -562,8 +562,21 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
AdjustWindowRectEx (&rect, dwStyle, FALSE, dwExStyle);
- /* non child windows are placed by the OS/window manager */
- x = y = CW_USEDEFAULT;
+ real_x = window->x - offset_x;
+ real_y = window->y - offset_y;
+
+ if (window->window_type == GDK_WINDOW_TOPLEVEL)
+ {
+ /* We initially place it at default so that we can get the
+ default window positioning if we want */
+ x = y = CW_USEDEFAULT;
+ }
+ else
+ {
+ /* TEMP, FOREIGN: Put these where requested */
+ x = real_x;
+ y = real_y;
+ }
window_width = rect.right - rect.left;
window_height = rect.bottom - rect.top;
@@ -629,9 +642,21 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
# endif
}
- GetWindowRect (GDK_WINDOW_HWND (window), &rect);
- impl->initial_x = rect.left;
- impl->initial_y = rect.top;
+
+ if (window->window_type != GDK_WINDOW_CHILD)
+ {
+ GetWindowRect (GDK_WINDOW_HWND (window), &rect);
+ impl->initial_x = rect.left;
+ impl->initial_y = rect.top;
+
+ /* Now we know the initial position, move to actually specified position */
+ if (real_x != x || real_y != y)
+ {
+ API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
+ real_x, real_y, 0, 0,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER));
+ }
+ }
g_object_ref (window);
gdk_win32_handle_table_insert (&GDK_WINDOW_HWND (window), window);