aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2022-05-19 09:30:33 +0800
committerPo Lu2022-05-19 09:30:33 +0800
commitbc604417f87f9fce865e70b3bc88b6bf2a8fd415 (patch)
tree601ada2e80a31e062f12298ef00cd77aac75e9a4
parent9178428b02500005aeaaa4ea40353589a029a63e (diff)
downloademacs-bc604417f87f9fce865e70b3bc88b6bf2a8fd415.tar.gz
emacs-bc604417f87f9fce865e70b3bc88b6bf2a8fd415.zip
Respond to changes to the size of the root window
* src/xterm.c (x_display_pixel_height, x_display_pixel_width): Move here instead. (handle_one_xevent): Handle ConfigureNotify for the root window. (x_term_init): Select for structure events on the root window. * src/xterm.h (struct x_display_info): New fields `screen_width' and `screen_height'. (x_display_pixel_height, x_display_pixel_width): Make prototypes.
-rw-r--r--src/xterm.c33
-rw-r--r--src/xterm.h19
2 files changed, 41 insertions, 11 deletions
diff --git a/src/xterm.c b/src/xterm.c
index b5fbb474ecc..b12aa4b8438 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -14506,6 +14506,24 @@ x_dnd_update_state (struct x_display_info *dpyinfo, Time timestamp)
14506 } 14506 }
14507} 14507}
14508 14508
14509int
14510x_display_pixel_height (struct x_display_info *dpyinfo)
14511{
14512 if (dpyinfo->screen_height)
14513 return dpyinfo->screen_height;
14514
14515 return HeightOfScreen (dpyinfo->screen);
14516}
14517
14518int
14519x_display_pixel_width (struct x_display_info *dpyinfo)
14520{
14521 if (dpyinfo->screen_width)
14522 return dpyinfo->screen_width;
14523
14524 return WidthOfScreen (dpyinfo->screen);
14525}
14526
14509/* Handles the XEvent EVENT on display DPYINFO. 14527/* Handles the XEvent EVENT on display DPYINFO.
14510 14528
14511 *FINISH is X_EVENT_GOTO_OUT if caller should stop reading events. 14529 *FINISH is X_EVENT_GOTO_OUT if caller should stop reading events.
@@ -16514,6 +16532,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
16514 So if this ConfigureNotify is immediately followed by another 16532 So if this ConfigureNotify is immediately followed by another
16515 for the same window, use the info from the latest update, and 16533 for the same window, use the info from the latest update, and
16516 consider the events all handled. */ 16534 consider the events all handled. */
16535
16517 /* Opaque resize may be trickier; ConfigureNotify events are 16536 /* Opaque resize may be trickier; ConfigureNotify events are
16518 mixed with Expose events for multiple windows. */ 16537 mixed with Expose events for multiple windows. */
16519 configureEvent = *event; 16538 configureEvent = *event;
@@ -16535,6 +16554,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
16535 configureEvent = next_event; 16554 configureEvent = next_event;
16536 } 16555 }
16537 16556
16557 /* If we get a ConfigureNotify for the root window, this means
16558 the dimensions of the screen it's on changed. */
16559
16560 if (configureEvent.xconfigure.window == dpyinfo->root_window)
16561 {
16562 dpyinfo->screen_width = configureEvent.xconfigure.width;
16563 dpyinfo->screen_height = configureEvent.xconfigure.height;
16564 }
16565
16538 if (x_dnd_in_progress && x_dnd_use_toplevels 16566 if (x_dnd_in_progress && x_dnd_use_toplevels
16539 && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame)) 16567 && dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame))
16540 { 16568 {
@@ -23870,6 +23898,11 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
23870 } 23898 }
23871#endif 23899#endif
23872 23900
23901 /* Select for structure events on the root window, since this allows
23902 us to record changes to the size of the screen. */
23903
23904 XSelectInput (dpy, DefaultRootWindow (dpy), StructureNotifyMask);
23905
23873 /* We have definitely succeeded. Record the new connection. */ 23906 /* We have definitely succeeded. Record the new connection. */
23874 23907
23875 dpyinfo = xzalloc (sizeof *dpyinfo); 23908 dpyinfo = xzalloc (sizeof *dpyinfo);
diff --git a/src/xterm.h b/src/xterm.h
index 3437037e674..a05bc404f69 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -690,6 +690,12 @@ struct x_display_info
690 int n_protected_windows; 690 int n_protected_windows;
691 int protected_windows_max; 691 int protected_windows_max;
692#endif 692#endif
693
694 /* The current dimensions of the screen. This is updated when a
695 ConfigureNotify is received for the root window, and is zero if
696 that didn't happen. */
697 int screen_width;
698 int screen_height;
693}; 699};
694 700
695#ifdef HAVE_X_I18N 701#ifdef HAVE_X_I18N
@@ -1439,17 +1445,8 @@ extern void x_dnd_do_unsupported_drop (struct x_display_info *, Lisp_Object,
1439 int, Time); 1445 int, Time);
1440extern void x_set_dnd_targets (Atom *, int); 1446extern void x_set_dnd_targets (Atom *, int);
1441 1447
1442INLINE int 1448extern int x_display_pixel_height (struct x_display_info *);
1443x_display_pixel_height (struct x_display_info *dpyinfo) 1449extern int x_display_pixel_width (struct x_display_info *);
1444{
1445 return HeightOfScreen (dpyinfo->screen);
1446}
1447
1448INLINE int
1449x_display_pixel_width (struct x_display_info *dpyinfo)
1450{
1451 return WidthOfScreen (dpyinfo->screen);
1452}
1453 1450
1454INLINE unsigned long 1451INLINE unsigned long
1455x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b) 1452x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)