summaryrefslogtreecommitdiff
path: root/eel/eel-gtk-extensions.c
diff options
context:
space:
mode:
Diffstat (limited to 'eel/eel-gtk-extensions.c')
-rw-r--r--eel/eel-gtk-extensions.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index 21366fb4..ede45cfe 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -86,16 +86,22 @@ eel_gtk_window_get_geometry_string (GtkWindow *window)
static void
sanity_check_window_position (int *left, int *top)
{
+ GdkScreen *screen;
+ gint scale;
+
g_assert (left != NULL);
g_assert (top != NULL);
+ screen = gdk_screen_get_default ();
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+
/* Make sure the top of the window is on screen, for
* draggability (might not be necessary with all window managers,
* but seems reasonable anyway). Make sure the top of the window
* 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, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - MINIMUM_ON_SCREEN_HEIGHT);
+ *top = CLAMP (*top, 0, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - MINIMUM_ON_SCREEN_HEIGHT);
/* FIXME bugzilla.eazel.com 669:
* If window has negative left coordinate, set_uposition sends it
@@ -108,22 +114,28 @@ sanity_check_window_position (int *left, int *top)
* the screen, or so close to the right edge that it might be
* obscured by the panel.
*/
- *left = CLAMP (*left, 0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - MINIMUM_ON_SCREEN_WIDTH);
+ *left = CLAMP (*left, 0, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - MINIMUM_ON_SCREEN_WIDTH);
}
static void
sanity_check_window_dimensions (guint *width, guint *height)
{
+ GdkScreen *screen;
+ gint scale;
+
g_assert (width != NULL);
g_assert (height != NULL);
+ screen = gdk_screen_get_default ();
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+
/* Pin the size of the window to the screen, so we don't end up in
* a state where the window is so big essential parts of it can't
* be reached (might not be necessary with all window managers,
* but seems reasonable anyway).
*/
- *width = MIN (*width, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())));
- *height = MIN (*height, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())));
+ *width = MIN (*width, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale);
+ *height = MIN (*height, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale);
}
/**
@@ -153,6 +165,7 @@ eel_gtk_window_set_initial_geometry (GtkWindow *window,
GdkScreen *screen;
int real_left, real_top;
int screen_width, screen_height;
+ int scale;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -168,8 +181,9 @@ eel_gtk_window_set_initial_geometry (GtkWindow *window,
real_top = top;
screen = gtk_window_get_screen (window);
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (window));
+ screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
/* This is sub-optimal. GDK doesn't allow us to set win_gravity
* to South/East types, which should be done if using negative