Skip to content

Commit ce402dd

Browse files
author
Ken Raeburn
committed
Handle an opaque-move X11 window manager operation more efficiently.
* src/xterm.c (handle_one_xevent): If a ConfigureNotify event is followed by more ConfigureNotify events for the same window, process only the last one.
1 parent ec2d990 commit ce402dd

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

src/xterm.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7480,6 +7480,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
74807480
says that a portable program can't use this, but Stephen Gildea assures
74817481
me that letting the compiler initialize it to zeros will work okay. */
74827482
static XComposeStatus compose_status;
7483+
XEvent configureEvent;
7484+
XEvent next_event;
74837485

74847486
USE_SAFE_ALLOCA;
74857487

@@ -8389,17 +8391,41 @@ handle_one_xevent (struct x_display_info *dpyinfo,
83898391
}
83908392

83918393
case ConfigureNotify:
8392-
f = x_top_window_to_frame (dpyinfo, event->xconfigure.window);
8394+
/* An opaque move can generate a stream of events as the window
8395+
is dragged around. If the connection round trip time isn't
8396+
really short, they may come faster than we can respond to
8397+
them, given the multiple queries we can do to check window
8398+
manager state, translate coordinates, etc.
8399+
8400+
So if this ConfigureNotify is immediately followed by another
8401+
for the same window, use the info from the latest update, and
8402+
consider the events all handled. */
8403+
/* Opaque resize may be trickier; ConfigureNotify events are
8404+
mixed with Expose events for multiple windows. */
8405+
configureEvent = *event;
8406+
while (XPending (dpyinfo->display))
8407+
{
8408+
XNextEvent (dpyinfo->display, &next_event);
8409+
if (next_event.type != ConfigureNotify
8410+
|| next_event.xconfigure.window != event->xconfigure.window)
8411+
{
8412+
XPutBackEvent (dpyinfo->display, &next_event);
8413+
break;
8414+
}
8415+
else
8416+
configureEvent = next_event;
8417+
}
8418+
f = x_top_window_to_frame (dpyinfo, configureEvent.xconfigure.window);
83938419
#ifdef USE_CAIRO
83948420
if (f) x_cr_destroy_surface (f);
83958421
#endif
83968422
#ifdef USE_GTK
83978423
if (!f
83988424
&& (f = any)
8399-
&& event->xconfigure.window == FRAME_X_WINDOW (f))
8425+
&& configureEvent.xconfigure.window == FRAME_X_WINDOW (f))
84008426
{
8401-
xg_frame_resized (f, event->xconfigure.width,
8402-
event->xconfigure.height);
8427+
xg_frame_resized (f, configureEvent.xconfigure.width,
8428+
configureEvent.xconfigure.height);
84038429
#ifdef USE_CAIRO
84048430
x_cr_destroy_surface (f);
84058431
#endif
@@ -8408,24 +8434,26 @@ handle_one_xevent (struct x_display_info *dpyinfo,
84088434
#endif
84098435
if (f)
84108436
{
8411-
x_net_wm_state (f, event->xconfigure.window);
8437+
x_net_wm_state (f, configureEvent.xconfigure.window);
84128438

84138439
#ifdef USE_X_TOOLKIT
84148440
/* Tip frames are pure X window, set size for them. */
84158441
if (! NILP (tip_frame) && XFRAME (tip_frame) == f)
84168442
{
8417-
if (FRAME_PIXEL_HEIGHT (f) != event->xconfigure.height
8418-
|| FRAME_PIXEL_WIDTH (f) != event->xconfigure.width)
8443+
if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height
8444+
|| FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width)
84198445
SET_FRAME_GARBAGED (f);
8420-
FRAME_PIXEL_HEIGHT (f) = event->xconfigure.height;
8421-
FRAME_PIXEL_WIDTH (f) = event->xconfigure.width;
8446+
FRAME_PIXEL_HEIGHT (f) = configureEvent.xconfigure.height;
8447+
FRAME_PIXEL_WIDTH (f) = configureEvent.xconfigure.width;
84228448
}
84238449
#endif
84248450

84258451
#ifndef USE_X_TOOLKIT
84268452
#ifndef USE_GTK
8427-
int width = FRAME_PIXEL_TO_TEXT_WIDTH (f, event->xconfigure.width);
8428-
int height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, event->xconfigure.height);
8453+
int width =
8454+
FRAME_PIXEL_TO_TEXT_WIDTH (f, configureEvent.xconfigure.width);
8455+
int height =
8456+
FRAME_PIXEL_TO_TEXT_HEIGHT (f, configureEvent.xconfigure.height);
84298457

84308458
/* In the toolkit version, change_frame_size
84318459
is called by the code that handles resizing
@@ -8436,8 +8464,8 @@ handle_one_xevent (struct x_display_info *dpyinfo,
84368464
to check the pixel dimensions as well. */
84378465
if (width != FRAME_TEXT_WIDTH (f)
84388466
|| height != FRAME_TEXT_HEIGHT (f)
8439-
|| event->xconfigure.width != FRAME_PIXEL_WIDTH (f)
8440-
|| event->xconfigure.height != FRAME_PIXEL_HEIGHT (f))
8467+
|| configureEvent.xconfigure.width != FRAME_PIXEL_WIDTH (f)
8468+
|| configureEvent.xconfigure.height != FRAME_PIXEL_HEIGHT (f))
84418469
{
84428470
change_frame_size (f, width, height, false, true, false, true);
84438471
x_clear_under_internal_border (f);

0 commit comments

Comments
 (0)