summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2018-03-29 16:09:16 -0400
committerraveit65 <[email protected]>2018-04-05 09:08:43 +0200
commit1a14801e9e24139efd5bff2a351405fd05d44096 (patch)
treee45d017bb1a88502acd70494bafff05d1888d86b
parent4c377bad72d5c873999c09fcbc8a2ac6aa76d4d6 (diff)
downloadcaja-1a14801e9e24139efd5bff2a351405fd05d44096.tar.bz2
caja-1a14801e9e24139efd5bff2a351405fd05d44096.tar.xz
Scale screen dimensions
-rw-r--r--eel/eel-background.c5
-rw-r--r--eel/eel-editable-label.c10
-rw-r--r--eel/eel-gtk-extensions.c26
-rw-r--r--libcaja-private/caja-icon-container.c18
-rw-r--r--src/caja-desktop-window.c14
-rw-r--r--src/caja-window.c6
-rw-r--r--src/file-manager/fm-desktop-icon-view.c6
7 files changed, 60 insertions, 25 deletions
diff --git a/eel/eel-background.c b/eel/eel-background.c
index e9b4b2cf..02b4d857 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -308,8 +308,9 @@ drawable_get_adjusted_size (EelBackground *self,
if (self->details->is_desktop)
{
GdkScreen *screen = gtk_widget_get_screen (self->details->widget);
- *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ gint scale = gtk_widget_get_scale_factor (self->details->widget);
+ *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
}
else
{
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index 7cdbc491..26ffed44 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -1047,6 +1047,7 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
else
{
gint wrap_width;
+ gint scale;
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
@@ -1057,9 +1058,10 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
longest_paragraph = width;
wrap_width = get_label_wrap_width (label);
+ scale = gtk_widget_get_scale_factor (widget);
width = MIN (width, wrap_width);
width = MIN (width,
- PANGO_SCALE * (WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) + 1) / 2);
+ PANGO_SCALE * (WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale + 1) / 2);
pango_layout_set_width (label->layout, width);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
@@ -3043,6 +3045,7 @@ popup_position_func (GtkMenu *menu,
GtkWidget *widget;
GtkRequisition req;
GtkAllocation allocation;
+ gint scale;
label = EEL_EDITABLE_LABEL (user_data);
widget = GTK_WIDGET (label);
@@ -3053,12 +3056,13 @@ popup_position_func (GtkMenu *menu,
gtk_widget_get_preferred_size (widget, &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
+ scale = gtk_widget_get_scale_factor (widget);
*x += allocation.width / 2;
*y += allocation.height;
- *x = CLAMP (*x, 0, MAX (0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.width));
- *y = CLAMP (*y, 0, MAX (0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.height));
+ *x = CLAMP (*x, 0, MAX (0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - req.width));
+ *y = CLAMP (*y, 0, MAX (0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - req.height));
}
static void
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index c3cff2f5..3fe0153d 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
diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index eb13b23f..5f941eab 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -326,6 +326,7 @@ icon_set_position (CajaIcon *icon,
int item_width, item_height;
int height_above, width_left;
int min_x, max_x, min_y, max_y;
+ int scale;
if (icon->x == x && icon->y == y)
{
@@ -354,12 +355,13 @@ icon_set_position (CajaIcon *icon,
For now, we have a cheesy workaround:
*/
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
container_x = 0;
container_y = 0;
- container_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - container_x
+ container_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - container_x
- container->details->left_margin
- container->details->right_margin;
- container_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - container_y
+ container_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - container_y
- container->details->top_margin
- container->details->bottom_margin;
pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
@@ -5239,6 +5241,7 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
gint x, y;
gint cont_x, cont_y;
gint cont_width, cont_height;
+ gint scale;
GdkWindow *cont_window;
GdkScreen *screen;
GtkRequisition requisition;
@@ -5247,6 +5250,7 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
cont_window = gtk_widget_get_window (GTK_WIDGET (container));
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
screen = gdk_window_get_screen (cont_window);
monitor_num = gdk_display_get_monitor_at_window (gdk_screen_get_display (screen),
@@ -5262,9 +5266,9 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
gtk_widget_get_preferred_size (search_dialog, &requisition, NULL);
- if (cont_x + cont_width - requisition.width > WidthOfScreen (gdk_x11_screen_get_xscreen (screen)))
+ if (cont_x + cont_width - requisition.width > WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale)
{
- x = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.width;
+ x = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - requisition.width;
}
else if (cont_x + cont_width - requisition.width < 0)
{
@@ -6025,6 +6029,7 @@ key_press_event (GtkWidget *widget,
GdkScreen *screen;
gboolean text_modified;
gulong popup_menu_id;
+ gint scale;
caja_icon_container_ensure_interactive_directory (container);
@@ -6040,9 +6045,10 @@ key_press_event (GtkWidget *widget,
/* Move the entry off screen */
screen = gtk_widget_get_screen (GTK_WIDGET (container));
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
gtk_window_move (GTK_WINDOW (container->details->search_window),
- WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) + 1,
- HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) + 1);
+ WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale + 1,
+ HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale + 1);
gtk_widget_show (container->details->search_window);
/* Send the event to the window. If the preedit_changed signal is emitted
diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c
index 2aa0c2f5..16242dcd 100644
--- a/src/caja-desktop-window.c
+++ b/src/caja-desktop-window.c
@@ -114,9 +114,12 @@ caja_desktop_window_screen_size_changed (GdkScreen *screen,
CajaDesktopWindow *window)
{
int width_request, height_request;
+ int scale;
- width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+
+ width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
g_object_set (window,
"width_request", width_request,
@@ -130,9 +133,12 @@ caja_desktop_window_new (CajaApplication *application,
{
CajaDesktopWindow *window;
int width_request, height_request;
+ int scale;
+
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
window = CAJA_DESKTOP_WINDOW
(gtk_widget_new (caja_desktop_window_get_type(),
diff --git a/src/caja-window.c b/src/caja-window.c
index ac22b6d8..132ffd96 100644
--- a/src/caja-window.c
+++ b/src/caja-window.c
@@ -507,7 +507,8 @@ caja_window_zoom_to_default (CajaWindow *window)
static guint
get_max_forced_height (GdkScreen *screen)
{
- return (HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) * 90) / 100;
+ gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+ return (HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100;
}
/* Code should never force the window wider than this size.
@@ -516,7 +517,8 @@ get_max_forced_height (GdkScreen *screen)
static guint
get_max_forced_width (GdkScreen *screen)
{
- return (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) * 90) / 100;
+ gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+ return (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100;
}
/* This must be called when construction of CajaWindow is finished,
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 8cbf0b62..42186a70 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -392,10 +392,12 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
GdkWindow *root_window;
GdkScreen *screen;
GtkAllocation allocation;
+ gint scale;
g_return_if_fail (desktop_icon_view->details->root_window == NULL);
screen = gtk_widget_get_screen (widget);
+ scale = gtk_widget_get_scale_factor (widget);
/* Ugly HACK for the problem that the views realize at the
* wrong size and then get resized. (This is a problem with
@@ -405,8 +407,8 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
*/
allocation.x = 0;
allocation.y = 0;
- allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
gtk_widget_size_allocate (GTK_WIDGET(get_icon_container(desktop_icon_view)),
&allocation);