aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gtkutil.c35
-rw-r--r--src/gtkutil.h4
-rw-r--r--src/xfns.c4
3 files changed, 12 insertions, 31 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 255091559e9..ccc42773217 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -845,21 +845,6 @@ xg_set_geometry (struct frame *f)
845 } 845 }
846} 846}
847 847
848static int
849xg_get_gdk_scale (void)
850{
851 const char *sscale = getenv ("GDK_SCALE");
852
853 if (sscale)
854 {
855 long scale = atol (sscale);
856 if (0 < scale)
857 return min (scale, INT_MAX);
858 }
859
860 return 1;
861}
862
863/* Function to handle resize of our frame. As we have a Gtk+ tool bar 848/* Function to handle resize of our frame. As we have a Gtk+ tool bar
864 and a Gtk+ menu bar, we get resize events for the edit part of the 849 and a Gtk+ menu bar, we get resize events for the edit part of the
865 frame only. We let Gtk+ deal with the Gtk+ parts. 850 frame only. We let Gtk+ deal with the Gtk+ parts.
@@ -921,12 +906,8 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
921 /* Do this before resize, as we don't know yet if we will be resized. */ 906 /* Do this before resize, as we don't know yet if we will be resized. */
922 x_clear_under_internal_border (f); 907 x_clear_under_internal_border (f);
923 908
924 if (FRAME_VISIBLE_P (f)) 909 totalheight /= xg_get_scale (f);
925 { 910 totalwidth /= xg_get_scale (f);
926 int scale = xg_get_gdk_scale ();
927 totalheight /= scale;
928 totalwidth /= scale;
929 }
930 911
931 x_wm_set_size_hint (f, 0, 0); 912 x_wm_set_size_hint (f, 0, 0);
932 913
@@ -1352,7 +1333,7 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
1352 int min_rows = 0, min_cols = 0; 1333 int min_rows = 0, min_cols = 0;
1353 int win_gravity = f->win_gravity; 1334 int win_gravity = f->win_gravity;
1354 Lisp_Object fs_state, frame; 1335 Lisp_Object fs_state, frame;
1355 int scale = xg_get_gdk_scale (); 1336 int scale = xg_get_scale (f);
1356 1337
1357 /* Don't set size hints during initialization; that apparently leads 1338 /* Don't set size hints during initialization; that apparently leads
1358 to a race condition. See the thread at 1339 to a race condition. See the thread at
@@ -3668,16 +3649,16 @@ update_theme_scrollbar_height (void)
3668} 3649}
3669 3650
3670int 3651int
3671xg_get_default_scrollbar_width (void) 3652xg_get_default_scrollbar_width (struct frame *f)
3672{ 3653{
3673 return scroll_bar_width_for_theme * xg_get_gdk_scale (); 3654 return scroll_bar_width_for_theme * xg_get_scale (f);
3674} 3655}
3675 3656
3676int 3657int
3677xg_get_default_scrollbar_height (void) 3658xg_get_default_scrollbar_height (struct frame *f)
3678{ 3659{
3679 /* Apparently there's no default height for themes. */ 3660 /* Apparently there's no default height for themes. */
3680 return scroll_bar_width_for_theme * xg_get_gdk_scale (); 3661 return scroll_bar_width_for_theme * xg_get_scale (f);
3681} 3662}
3682 3663
3683/* Return the scrollbar id for X Window WID on display DPY. 3664/* Return the scrollbar id for X Window WID on display DPY.
@@ -3867,7 +3848,7 @@ xg_update_scrollbar_pos (struct frame *f,
3867 GtkWidget *wfixed = f->output_data.x->edit_widget; 3848 GtkWidget *wfixed = f->output_data.x->edit_widget;
3868 GtkWidget *wparent = gtk_widget_get_parent (wscroll); 3849 GtkWidget *wparent = gtk_widget_get_parent (wscroll);
3869 gint msl; 3850 gint msl;
3870 int scale = xg_get_gdk_scale (); 3851 int scale = xg_get_scale (f);
3871 3852
3872 top /= scale; 3853 top /= scale;
3873 left /= scale; 3854 left /= scale;
diff --git a/src/gtkutil.h b/src/gtkutil.h
index a252cbef99c..f0f2981418c 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -143,8 +143,8 @@ extern void xg_set_toolkit_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
143 int position, 143 int position,
144 int whole); 144 int whole);
145extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *); 145extern bool xg_event_is_for_scrollbar (struct frame *, const XEvent *);
146extern int xg_get_default_scrollbar_width (void); 146extern int xg_get_default_scrollbar_width (struct frame *f);
147extern int xg_get_default_scrollbar_height (void); 147extern int xg_get_default_scrollbar_height (struct frame *f);
148 148
149extern void update_frame_tool_bar (struct frame *f); 149extern void update_frame_tool_bar (struct frame *f);
150extern void free_frame_tool_bar (struct frame *f); 150extern void free_frame_tool_bar (struct frame *f);
diff --git a/src/xfns.c b/src/xfns.c
index d8bf9747191..2f8c9c25416 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -2062,7 +2062,7 @@ x_set_scroll_bar_default_width (struct frame *f)
2062 int unit = FRAME_COLUMN_WIDTH (f); 2062 int unit = FRAME_COLUMN_WIDTH (f);
2063#ifdef USE_TOOLKIT_SCROLL_BARS 2063#ifdef USE_TOOLKIT_SCROLL_BARS
2064#ifdef USE_GTK 2064#ifdef USE_GTK
2065 int minw = xg_get_default_scrollbar_width (); 2065 int minw = xg_get_default_scrollbar_width (f);
2066#else 2066#else
2067 int minw = 16; 2067 int minw = 16;
2068#endif 2068#endif
@@ -2083,7 +2083,7 @@ x_set_scroll_bar_default_height (struct frame *f)
2083 int height = FRAME_LINE_HEIGHT (f); 2083 int height = FRAME_LINE_HEIGHT (f);
2084#ifdef USE_TOOLKIT_SCROLL_BARS 2084#ifdef USE_TOOLKIT_SCROLL_BARS
2085#ifdef USE_GTK 2085#ifdef USE_GTK
2086 int min_height = xg_get_default_scrollbar_height (); 2086 int min_height = xg_get_default_scrollbar_height (f);
2087#else 2087#else
2088 int min_height = 16; 2088 int min_height = 16;
2089#endif 2089#endif