diff options
author | Ernestas Kulik <ernestask@gnome.org> | 2018-01-10 17:02:16 +0200 |
---|---|---|
committer | Ernestas Kulik <ernestask@gnome.org> | 2018-01-18 14:47:44 +0200 |
commit | 3fb716870ef706a74fd5d62a5e54e0364eaa5201 (patch) | |
tree | 5d759bb81a8f299a29eabd968757d189ead900c9 | |
parent | d36326a8b5d7e2e4af76a05b194f29031cd3287a (diff) | |
download | nautilus-3fb716870ef706a74fd5d62a5e54e0364eaa5201.tar.gz |
eel: gtk-extensions: fix window position checking
Currently, windows are confined to the geometry of the primary monitor
(minus a constant size) with the assumption that its position is (0, 0).
This breaks cases where the primary monitor is above or to the left of
the window. This commit fixes that by using a monitor nearest to the
stored position.
Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/197.
-rw-r--r-- | eel/eel-gtk-extensions.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 335aa01b1..5fc5293bd 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -82,12 +82,17 @@ static void sanity_check_window_position (int *left, int *top) { + GdkDisplay *display; + GdkMonitor *monitor; GdkRectangle geometry; g_assert (left != NULL); g_assert (top != NULL); - gdk_monitor_get_geometry (gdk_display_get_monitor (gdk_display_get_default (), 0), &geometry); + display = gdk_display_get_default (); + monitor = gdk_display_get_monitor_at_point (display, *left, *top); + + gdk_monitor_get_geometry (monitor, &geometry); /* Make sure the top of the window is on screen, for * draggability (might not be necessary with all window managers, @@ -95,7 +100,9 @@ sanity_check_window_position (int *left, * isn't off the bottom of the screen, or so close to the bottom * that it might be obscured by the panel. */ - *top = CLAMP (*top, 0, geometry.height - MINIMUM_ON_SCREEN_HEIGHT); + *top = CLAMP (*top, + geometry.y, + geometry.y + geometry.height - MINIMUM_ON_SCREEN_HEIGHT); /* FIXME bugzilla.eazel.com 669: * If window has negative left coordinate, set_uposition sends it @@ -108,7 +115,9 @@ sanity_check_window_position (int *left, * the screen, or so close to the right edge that it might be * obscured by the panel. */ - *left = CLAMP (*left, 0, geometry.width - MINIMUM_ON_SCREEN_WIDTH); + *left = CLAMP (*left, + geometry.x, + geometry.x + geometry.width - MINIMUM_ON_SCREEN_WIDTH); } static void |