[gtk+] x11: Return the exact pixel coverage in get_frame_extents
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Return the exact pixel coverage in get_frame_extents
- Date: Thu, 20 Nov 2014 11:42:10 +0000 (UTC)
commit 788478dff9466b6606d61aa977847b7d78077d0f
Author: Alexander Larsson <alexl redhat com>
Date: Thu Nov 20 10:42:55 2014 +0100
x11: Return the exact pixel coverage in get_frame_extents
Rather than just rounding down the position *and* the size separately
we correctly calculate a rectangle in scaled window coords that fully
covers the real window size. This really only makes a difference
when the window size/position isn't a multiple of the window scale.
https://bugzilla.gnome.org/show_bug.cgi?id=739750
gdk/x11/gdkwindow-x11.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index c4b90af..525a798 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3262,10 +3262,14 @@ gdk_x11_window_get_frame_extents (GdkWindow *window,
if (vroots)
XFree (vroots);
- rect->x /= impl->window_scale;
- rect->y /= impl->window_scale;
- rect->width /= impl->window_scale;
- rect->height /= impl->window_scale;
+ /* Here we extend the size to include the extra pixels if we round x/y down
+ as well as round the size up when we divide by scale so that the returned
+ size is guaranteed to cover the real pixels, but it may overshoot a bit
+ in case the window is not positioned/sized according to the scale */
+ 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 = rect->x / impl->window_scale;
+ rect->y = rect->y / impl->window_scale;
gdk_x11_display_error_trap_pop_ignored (display);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]