1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-17 00:30:37 -08:00

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.
This commit is contained in:
Po Lu 2022-05-19 09:30:33 +08:00
parent 9178428b02
commit bc604417f8
2 changed files with 41 additions and 11 deletions

View file

@ -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);

View file

@ -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)