summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
}
}
+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 3437037e674..a05bc404f69 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)