[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pgtk 0af4e75 3/3: Fix display-pixel-width/height to return physi
From: |
Yuuki Harano |
Subject: |
feature/pgtk 0af4e75 3/3: Fix display-pixel-width/height to return physical pixel size. |
Date: |
Sun, 3 Jan 2021 02:29:41 -0500 (EST) |
branch: feature/pgtk
commit 0af4e7587e1b5ac9066e17b875952cb5a16e63c0
Author: Yuuki Harano <masm+github@masm11.me>
Commit: Yuuki Harano <masm+github@masm11.me>
Fix display-pixel-width/height to return physical pixel size.
* src/pgtkfns.c (Fx_display_pixel_width):
(Fx_display_pixel_height): Return bottom/right-most of all the monitors.
---
src/pgtkfns.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/src/pgtkfns.c b/src/pgtkfns.c
index 3e55b83..7d2183d 100644
--- a/src/pgtkfns.c
+++ b/src/pgtkfns.c
@@ -2408,8 +2408,35 @@ each physical monitor, use
`display-monitor-attributes-list'. */)
(Lisp_Object terminal)
{
struct pgtk_display_info *dpyinfo = check_pgtk_display_info (terminal);
+ GdkDisplay *gdpy;
+ gint n_monitors, i;
+ int width = 0;
+
+ block_input ();
+ gdpy = dpyinfo->gdpy;
+ n_monitors = gdk_display_get_n_monitors (gdpy);
+
+ for (i = 0; i < n_monitors; ++i)
+ {
+ GdkRectangle rec;
+ int scale = 1;
+
+ GdkMonitor *monitor = gdk_display_get_monitor (gdpy, i);
+ gdk_monitor_get_geometry (monitor, &rec);
+
+ /* GTK returns scaled sizes for the workareas. */
+ scale = gdk_monitor_get_scale_factor (monitor);
+ rec.x *= scale;
+ rec.y *= scale;
+ rec.width *= scale;
+ rec.height *= scale;
+
+ width = max(width, rec.x + rec.width);
+ }
+
+ unblock_input ();
- return make_fixnum (x_display_pixel_width (dpyinfo));
+ return make_fixnum (width);
}
@@ -2425,8 +2452,35 @@ each physical monitor, use
`display-monitor-attributes-list'. */)
(Lisp_Object terminal)
{
struct pgtk_display_info *dpyinfo = check_pgtk_display_info (terminal);
+ GdkDisplay *gdpy;
+ gint n_monitors, i;
+ int height = 0;
+
+ block_input ();
+ gdpy = dpyinfo->gdpy;
+ n_monitors = gdk_display_get_n_monitors (gdpy);
+
+ for (i = 0; i < n_monitors; ++i)
+ {
+ GdkRectangle rec;
+ int scale = 1;
+
+ GdkMonitor *monitor = gdk_display_get_monitor (gdpy, i);
+ gdk_monitor_get_geometry (monitor, &rec);
+
+ /* GTK returns scaled sizes for the workareas. */
+ scale = gdk_monitor_get_scale_factor (monitor);
+ rec.x *= scale;
+ rec.y *= scale;
+ rec.width *= scale;
+ rec.height *= scale;
+
+ height = max(height, rec.y + rec.height);
+ }
+
+ unblock_input ();
- return make_fixnum (x_display_pixel_height (dpyinfo));
+ return make_fixnum (height);
}
DEFUN ("pgtk-display-monitor-attributes-list",
Fpgtk_display_monitor_attributes_list,