diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2017-09-29 12:50:03 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2017-12-02 10:38:28 +0000 |
commit | 50bbac60054b1558dcd459bdd8a5a93bda078b38 (patch) | |
tree | fb0f663531118419c500107b6e2a5363fe8dd044 /gdk/win32 | |
parent | eb6d5b6b276ea37fadd9ccd88faef173e72dd2f4 (diff) | |
download | gtk+-50bbac60054b1558dcd459bdd8a5a93bda078b38.tar.gz |
GDK W32: Correctly report window position in HiDPI mode
Window position returned by get_frame_extents() should be scaled.
Also take this opportunity to apply the same rounding that X11 backend
applies.
https://bugzilla.gnome.org/show_bug.cgi?id=788053
Diffstat (limited to 'gdk/win32')
-rw-r--r-- | gdk/win32/gdkwindow-win32.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 9a20761034..4616d734a0 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -2114,16 +2114,25 @@ gdk_win32_window_get_frame_extents (GdkWindow *window, hwnd = GDK_WINDOW_HWND (window); API_CALL (GetWindowRect, (hwnd, &r)); - rect->x = r.left + _gdk_offset_x; - rect->y = r.top + _gdk_offset_y; - rect->width = (r.right - r.left) / impl->window_scale; - rect->height = (r.bottom - r.top) / impl->window_scale; + /* Initialize to real, unscaled size */ + rect->x = r.left + _gdk_offset_x * impl->window_scale; + rect->y = r.top + _gdk_offset_y * impl->window_scale; + rect->width = (r.right - r.left); + rect->height = (r.bottom - r.top); + + /* Extend width and height to ensure that they cover the real size when de-scaled, + * and replace everyting with scaled values + */ + rect->width = (rect->width + rect->x % impl->window_scale + impl->window_scale - 1) / impl->window_scale; + rect->height = (rect->height + rect->y % impl->window_scale + impl->window_scale - 1) / impl->window_scale; + rect->x = r.left / impl->window_scale + _gdk_offset_x; + rect->y = r.top / impl->window_scale + _gdk_offset_y; GDK_NOTE (MISC, g_print ("gdk_window_get_frame_extents: %p: %ldx%ld@%+ld%+ld\n", - GDK_WINDOW_HWND (window), - (r.right - r.left) / impl->window_scale, - (r.bottom - r.top) / impl->window_scale, - r.left, r.top)); + GDK_WINDOW_HWND (window), + rect->width, + rect->height, + rect->x, rect->y)); } static gboolean |