aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-29 15:49:48 +0800
committerPo Lu2022-05-29 15:49:48 +0800
commit6f8e856ada08abf4cd29f03fe379a66693a78ba3 (patch)
tree5bff0a1a26bdf44a63bf7bc0173d5cdbb675a742 /src
parent22a3e92dc6e3106fe5a7afdf3c1de95e2b3e1fb7 (diff)
downloademacs-6f8e856ada08abf4cd29f03fe379a66693a78ba3.tar.gz
emacs-6f8e856ada08abf4cd29f03fe379a66693a78ba3.zip
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'.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c6
-rw-r--r--src/xterm.c11
-rw-r--r--src/xterm.h5
3 files changed, 20 insertions, 2 deletions
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'. */)
5434{ 5434{
5435 struct x_display_info *dpyinfo = check_x_display_info (terminal); 5435 struct x_display_info *dpyinfo = check_x_display_info (terminal);
5436 5436
5437 if (dpyinfo->screen_mm_height)
5438 return make_fixnum (dpyinfo->screen_mm_height);
5439
5437 return make_fixnum (HeightMMOfScreen (dpyinfo->screen)); 5440 return make_fixnum (HeightMMOfScreen (dpyinfo->screen));
5438} 5441}
5439 5442
@@ -5451,6 +5454,9 @@ for each physical monitor, use `display-monitor-attributes-list'. */)
5451{ 5454{
5452 struct x_display_info *dpyinfo = check_x_display_info (terminal); 5455 struct x_display_info *dpyinfo = check_x_display_info (terminal);
5453 5456
5457 if (dpyinfo->screen_mm_width)
5458 return make_fixnum (dpyinfo->screen_mm_width);
5459
5454 return make_fixnum (WidthMMOfScreen (dpyinfo->screen)); 5460 return make_fixnum (WidthMMOfScreen (dpyinfo->screen));
5455} 5461}
5456 5462
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,
20417 notify = ((XRRScreenChangeNotifyEvent *) event); 20417 notify = ((XRRScreenChangeNotifyEvent *) event);
20418 timestamp = notify->timestamp; 20418 timestamp = notify->timestamp;
20419 20419
20420 dpyinfo->screen_width = notify->width; 20420 /* Don't set screen dimensions if the notification is
20421 dpyinfo->screen_height = notify->height; 20421 for a different screen. */
20422 if (notify->root == dpyinfo->root_window)
20423 {
20424 dpyinfo->screen_width = notify->width;
20425 dpyinfo->screen_height = notify->height;
20426 dpyinfo->screen_mm_width = notify->mwidth;
20427 dpyinfo->screen_mm_height = notify->mheight;
20428 }
20422 } 20429 }
20423 else 20430 else
20424 timestamp = 0; 20431 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
708 that didn't happen. */ 708 that didn't happen. */
709 int screen_width; 709 int screen_width;
710 int screen_height; 710 int screen_height;
711
712 /* The mm width and height of the screen. Updated on
713 RRScreenChangeNotify. */
714 int screen_mm_width;
715 int screen_mm_height;
711}; 716};
712 717
713#ifdef HAVE_X_I18N 718#ifdef HAVE_X_I18N