From: Yuuki Harano Date: Sat, 5 Jun 2021 11:53:31 +0000 (+0900) Subject: Support frame-scale-factor on pgtk frames X-Git-Tag: emacs-29.0.90~3691 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ce7a78d0a8e033f04978b0c0762378ba13d3fa64;p=emacs.git Support frame-scale-factor on pgtk frames * src/pgtkfns.c (pgtk_frame_scale_factor): New function to get frame scale factor. * src/frame.h: Call it when a pgtk frame. * src/pgtkterm.h: Add the declaration. --- diff --git a/src/frame.h b/src/frame.h index 1aba1e3bc47..b1ad525779c 100644 --- a/src/frame.h +++ b/src/frame.h @@ -920,6 +920,8 @@ default_pixels_per_inch_y (void) /* Scale factor of frame F. */ #if defined HAVE_NS # define FRAME_SCALE_FACTOR(f) (FRAME_NS_P (f) ? ns_frame_scale_factor (f) : 1) +#elif defined HAVE_PGTK +# define FRAME_SCALE_FACTOR(f) (FRAME_PGTK_P (f) ? pgtk_frame_scale_factor (f) : 1) #else # define FRAME_SCALE_FACTOR(f) 1 #endif diff --git a/src/pgtkfns.c b/src/pgtkfns.c index 5f114515c92..ceff279ad02 100644 --- a/src/pgtkfns.c +++ b/src/pgtkfns.c @@ -2728,6 +2728,26 @@ Internal use only, use `display-monitor-attributes-list' instead. */) return attributes_list; } +double +pgtk_frame_scale_factor (struct frame *f) +{ + struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); + GdkDisplay *gdpy = dpyinfo->gdpy; + + block_input (); + + GdkWindow *gwin = gtk_widget_get_window (FRAME_GTK_WIDGET (f)); + GdkMonitor *gmon = gdk_display_get_monitor_at_window (gdpy, gwin); + + /* GTK returns scaled sizes for the workareas. */ + double scale = pgtk_get_monitor_scale_factor (gdk_monitor_get_model (gmon)); + if (scale == 0.0) + scale = gdk_monitor_get_scale_factor (gmon); + + unblock_input (); + + return scale; +} DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 0, 1, 0, doc: /* Return the number of bitplanes of the display TERMINAL. diff --git a/src/pgtkterm.h b/src/pgtkterm.h index 07d7fc10c65..c87a5e13ec0 100644 --- a/src/pgtkterm.h +++ b/src/pgtkterm.h @@ -663,4 +663,6 @@ extern bool xg_set_icon_from_xpm_data (struct frame *f, const char **data); extern bool pgtk_text_icon (struct frame *f, const char *icon_name); +extern double pgtk_frame_scale_factor (struct frame *); + #endif /* HAVE_PGTK */