From: Po Lu Date: Sun, 29 May 2022 07:49:48 +0000 (+0800) Subject: Keep display mm width and height up to date after changes X-Git-Tag: emacs-29.0.90~1910^2~359 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6f8e856ada08abf4cd29f03fe379a66693a78ba3;p=emacs.git Keep display mm width and height up to date after changes * src/xfns.c (Fx_display_mm_width, Fx_display_mm_height): Use new fields if they are set. * src/xterm.c (handle_one_xevent): Set new fields on RRNotify if the screen is correct. * src/xterm.h (struct x_display_info): New fields `screen_mm_width', `screen_mm_height'. --- diff --git a/src/xfns.c b/src/xfns.c index 401ad816955..8237e8870cd 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5434,6 +5434,9 @@ for each physical monitor, use `display-monitor-attributes-list'. */) { struct x_display_info *dpyinfo = check_x_display_info (terminal); + if (dpyinfo->screen_mm_height) + return make_fixnum (dpyinfo->screen_mm_height); + return make_fixnum (HeightMMOfScreen (dpyinfo->screen)); } @@ -5451,6 +5454,9 @@ for each physical monitor, use `display-monitor-attributes-list'. */) { struct x_display_info *dpyinfo = check_x_display_info (terminal); + if (dpyinfo->screen_mm_width) + return make_fixnum (dpyinfo->screen_mm_width); + return make_fixnum (WidthMMOfScreen (dpyinfo->screen)); } diff --git a/src/xterm.c b/src/xterm.c index 65d3eaf83f2..908185c3d10 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -20417,8 +20417,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, notify = ((XRRScreenChangeNotifyEvent *) event); timestamp = notify->timestamp; - dpyinfo->screen_width = notify->width; - dpyinfo->screen_height = notify->height; + /* Don't set screen dimensions if the notification is + for a different screen. */ + if (notify->root == dpyinfo->root_window) + { + dpyinfo->screen_width = notify->width; + dpyinfo->screen_height = notify->height; + dpyinfo->screen_mm_width = notify->mwidth; + dpyinfo->screen_mm_height = notify->mheight; + } } else timestamp = 0; diff --git a/src/xterm.h b/src/xterm.h index bc2e138aa99..c8e86d5d094 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -708,6 +708,11 @@ struct x_display_info that didn't happen. */ int screen_width; int screen_height; + + /* The mm width and height of the screen. Updated on + RRScreenChangeNotify. */ + int screen_mm_width; + int screen_mm_height; }; #ifdef HAVE_X_I18N