]> git.eshelyaron.com Git - emacs.git/commitdiff
Keep display mm width and height up to date after changes
authorPo Lu <luangruo@yahoo.com>
Sun, 29 May 2022 07:49:48 +0000 (15:49 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 29 May 2022 07:49:48 +0000 (15:49 +0800)
* 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'.

src/xfns.c
src/xterm.c
src/xterm.h

index 401ad816955a25cccc49697f21ba8f5ce6f82bc4..8237e8870cd0faabdf39fc30b6d92ac93c2a74d4 100644 (file)
@@ -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));
 }
 
index 65d3eaf83f2e4c04a2100de5b5e94940d0ca9675..908185c3d10fbd7a6b922cf61fe511a3d5a740b5 100644 (file)
@@ -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;
index bc2e138aa994b0a44d48a78042bf5fbec8643464..c8e86d5d0940ff0510711bd77bb4afe26a0257a8 100644 (file)
@@ -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