aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorMichael R. Mauger2017-07-24 22:15:04 -0400
committerMichael R. Mauger2017-07-24 22:15:04 -0400
commitdf1a71272e5cdd10b511e2ffd702ca50ddd8a773 (patch)
tree9b9ac725394ee80891e2bff57b6407d0e491e71a /src/gtkutil.c
parenteb27fc4d49e8c914cd0e6a8a2d02159601542141 (diff)
parent32daa3cb54523006c88717cbeac87964cd687a1b (diff)
downloademacs-df1a71272e5cdd10b511e2ffd702ca50ddd8a773.tar.gz
emacs-df1a71272e5cdd10b511e2ffd702ca50ddd8a773.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c63
1 files changed, 35 insertions, 28 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 2d4abefa969..0c8395efe9b 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -204,6 +204,31 @@ xg_display_open (char *display_name, Display **dpy)
204 *dpy = gdpy ? GDK_DISPLAY_XDISPLAY (gdpy) : NULL; 204 *dpy = gdpy ? GDK_DISPLAY_XDISPLAY (gdpy) : NULL;
205} 205}
206 206
207/* Scaling/HiDPI functions. */
208static int
209xg_get_gdk_scale (void)
210{
211 const char *sscale = getenv ("GDK_SCALE");
212
213 if (sscale)
214 {
215 long scale = atol (sscale);
216 if (0 < scale)
217 return min (scale, INT_MAX);
218 }
219
220 return 1;
221}
222
223int
224xg_get_scale (struct frame *f)
225{
226#if GTK_CHECK_VERSION (3, 10, 0)
227 if (FRAME_GTK_WIDGET (f))
228 return gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
229#endif
230 return xg_get_gdk_scale ();
231}
207 232
208/* Close display DPY. */ 233/* Close display DPY. */
209 234
@@ -724,7 +749,8 @@ xg_show_tooltip (struct frame *f, int root_x, int root_y)
724 if (x->ttip_window) 749 if (x->ttip_window)
725 { 750 {
726 block_input (); 751 block_input ();
727 gtk_window_move (x->ttip_window, root_x, root_y); 752 gtk_window_move (x->ttip_window, root_x / xg_get_scale (f),
753 root_y / xg_get_scale (f));
728 gtk_widget_show_all (GTK_WIDGET (x->ttip_window)); 754 gtk_widget_show_all (GTK_WIDGET (x->ttip_window));
729 unblock_input (); 755 unblock_input ();
730 } 756 }
@@ -836,21 +862,6 @@ xg_set_geometry (struct frame *f)
836 } 862 }
837} 863}
838 864
839static int
840xg_get_gdk_scale (void)
841{
842 const char *sscale = getenv ("GDK_SCALE");
843
844 if (sscale)
845 {
846 long scale = atol (sscale);
847 if (0 < scale)
848 return min (scale, INT_MAX);
849 }
850
851 return 1;
852}
853
854/* Function to handle resize of our frame. As we have a Gtk+ tool bar 865/* Function to handle resize of our frame. As we have a Gtk+ tool bar
855 and a Gtk+ menu bar, we get resize events for the edit part of the 866 and a Gtk+ menu bar, we get resize events for the edit part of the
856 frame only. We let Gtk+ deal with the Gtk+ parts. 867 frame only. We let Gtk+ deal with the Gtk+ parts.
@@ -912,12 +923,8 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
912 /* Do this before resize, as we don't know yet if we will be resized. */ 923 /* Do this before resize, as we don't know yet if we will be resized. */
913 x_clear_under_internal_border (f); 924 x_clear_under_internal_border (f);
914 925
915 if (FRAME_VISIBLE_P (f)) 926 totalheight /= xg_get_scale (f);
916 { 927 totalwidth /= xg_get_scale (f);
917 int scale = xg_get_gdk_scale ();
918 totalheight /= scale;
919 totalwidth /= scale;
920 }
921 928
922 x_wm_set_size_hint (f, 0, 0); 929 x_wm_set_size_hint (f, 0, 0);
923 930
@@ -1343,7 +1350,7 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
1343 int min_rows = 0, min_cols = 0; 1350 int min_rows = 0, min_cols = 0;
1344 int win_gravity = f->win_gravity; 1351 int win_gravity = f->win_gravity;
1345 Lisp_Object fs_state, frame; 1352 Lisp_Object fs_state, frame;
1346 int scale = xg_get_gdk_scale (); 1353 int scale = xg_get_scale (f);
1347 1354
1348 /* Don't set size hints during initialization; that apparently leads 1355 /* Don't set size hints during initialization; that apparently leads
1349 to a race condition. See the thread at 1356 to a race condition. See the thread at
@@ -3659,16 +3666,16 @@ update_theme_scrollbar_height (void)
3659} 3666}
3660 3667
3661int 3668int
3662xg_get_default_scrollbar_width (void) 3669xg_get_default_scrollbar_width (struct frame *f)
3663{ 3670{
3664 return scroll_bar_width_for_theme * xg_get_gdk_scale (); 3671 return scroll_bar_width_for_theme * xg_get_scale (f);
3665} 3672}
3666 3673
3667int 3674int
3668xg_get_default_scrollbar_height (void) 3675xg_get_default_scrollbar_height (struct frame *f)
3669{ 3676{
3670 /* Apparently there's no default height for themes. */ 3677 /* Apparently there's no default height for themes. */
3671 return scroll_bar_width_for_theme * xg_get_gdk_scale (); 3678 return scroll_bar_width_for_theme * xg_get_scale (f);
3672} 3679}
3673 3680
3674/* Return the scrollbar id for X Window WID on display DPY. 3681/* Return the scrollbar id for X Window WID on display DPY.
@@ -3858,7 +3865,7 @@ xg_update_scrollbar_pos (struct frame *f,
3858 GtkWidget *wfixed = f->output_data.x->edit_widget; 3865 GtkWidget *wfixed = f->output_data.x->edit_widget;
3859 GtkWidget *wparent = gtk_widget_get_parent (wscroll); 3866 GtkWidget *wparent = gtk_widget_get_parent (wscroll);
3860 gint msl; 3867 gint msl;
3861 int scale = xg_get_gdk_scale (); 3868 int scale = xg_get_scale (f);
3862 3869
3863 top /= scale; 3870 top /= scale;
3864 left /= scale; 3871 left /= scale;