[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bc604417f8: Respond to changes to the size of the root window
From: |
Po Lu |
Subject: |
master bc604417f8: Respond to changes to the size of the root window |
Date: |
Wed, 18 May 2022 21:30:48 -0400 (EDT) |
branch: master
commit bc604417f87f9fce865e70b3bc88b6bf2a8fd415
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/xterm.c | 33 +++++++++++++++++++++++++++++++++
src/xterm.h | 19 ++++++++-----------
2 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index b5fbb474ec..b12aa4b843 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -14506,6 +14506,24 @@ x_dnd_update_state (struct x_display_info *dpyinfo,
Time timestamp)
}
}
+int
+x_display_pixel_height (struct x_display_info *dpyinfo)
+{
+ if (dpyinfo->screen_height)
+ return dpyinfo->screen_height;
+
+ return HeightOfScreen (dpyinfo->screen);
+}
+
+int
+x_display_pixel_width (struct x_display_info *dpyinfo)
+{
+ if (dpyinfo->screen_width)
+ return dpyinfo->screen_width;
+
+ return WidthOfScreen (dpyinfo->screen);
+}
+
/* Handles the XEvent EVENT on display DPYINFO.
*FINISH is X_EVENT_GOTO_OUT if caller should stop reading events.
@@ -16514,6 +16532,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
So if this ConfigureNotify is immediately followed by another
for the same window, use the info from the latest update, and
consider the events all handled. */
+
/* Opaque resize may be trickier; ConfigureNotify events are
mixed with Expose events for multiple windows. */
configureEvent = *event;
@@ -16535,6 +16554,15 @@ handle_one_xevent (struct x_display_info *dpyinfo,
configureEvent = next_event;
}
+ /* If we get a ConfigureNotify for the root window, this means
+ the dimensions of the screen it's on changed. */
+
+ if (configureEvent.xconfigure.window == dpyinfo->root_window)
+ {
+ dpyinfo->screen_width = configureEvent.xconfigure.width;
+ dpyinfo->screen_height = configureEvent.xconfigure.height;
+ }
+
if (x_dnd_in_progress && x_dnd_use_toplevels
&& dpyinfo == FRAME_DISPLAY_INFO (x_dnd_frame))
{
@@ -23870,6 +23898,11 @@ x_term_init (Lisp_Object display_name, char
*xrm_option, char *resource_name)
}
#endif
+ /* Select for structure events on the root window, since this allows
+ us to record changes to the size of the screen. */
+
+ XSelectInput (dpy, DefaultRootWindow (dpy), StructureNotifyMask);
+
/* We have definitely succeeded. Record the new connection. */
dpyinfo = xzalloc (sizeof *dpyinfo);
diff --git a/src/xterm.h b/src/xterm.h
index 3437037e67..a05bc404f6 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -690,6 +690,12 @@ struct x_display_info
int n_protected_windows;
int protected_windows_max;
#endif
+
+ /* The current dimensions of the screen. This is updated when a
+ ConfigureNotify is received for the root window, and is zero if
+ that didn't happen. */
+ int screen_width;
+ int screen_height;
};
#ifdef HAVE_X_I18N
@@ -1439,17 +1445,8 @@ extern void x_dnd_do_unsupported_drop (struct
x_display_info *, Lisp_Object,
int, Time);
extern void x_set_dnd_targets (Atom *, int);
-INLINE int
-x_display_pixel_height (struct x_display_info *dpyinfo)
-{
- return HeightOfScreen (dpyinfo->screen);
-}
-
-INLINE int
-x_display_pixel_width (struct x_display_info *dpyinfo)
-{
- return WidthOfScreen (dpyinfo->screen);
-}
+extern int x_display_pixel_height (struct x_display_info *);
+extern int x_display_pixel_width (struct x_display_info *);
INLINE unsigned long
x_make_truecolor_pixel (struct x_display_info *dpyinfo, int r, int g, int b)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bc604417f8: Respond to changes to the size of the root window,
Po Lu <=