diff options
| author | Ken Raeburn | 2015-10-10 03:26:42 -0400 |
|---|---|---|
| committer | Ken Raeburn | 2015-10-11 01:15:25 -0400 |
| commit | ce402dd77fe39c3a6d968e23d7a4a20f2b04ccf0 (patch) | |
| tree | 2d47ffff86a201eee5fa6c48386d2fc85fb30045 | |
| parent | ec2d99026ff2f928b0669da2c2cf909b62aeb6c1 (diff) | |
| download | emacs-ce402dd77fe39c3a6d968e23d7a4a20f2b04ccf0.tar.gz emacs-ce402dd77fe39c3a6d968e23d7a4a20f2b04ccf0.zip | |
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.
| -rw-r--r-- | src/xterm.c | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/src/xterm.c b/src/xterm.c index 7ff6b17c30a..dd57a548393 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -7480,6 +7480,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 7480 | says that a portable program can't use this, but Stephen Gildea assures | 7480 | says that a portable program can't use this, but Stephen Gildea assures |
| 7481 | me that letting the compiler initialize it to zeros will work okay. */ | 7481 | me that letting the compiler initialize it to zeros will work okay. */ |
| 7482 | static XComposeStatus compose_status; | 7482 | static XComposeStatus compose_status; |
| 7483 | XEvent configureEvent; | ||
| 7484 | XEvent next_event; | ||
| 7483 | 7485 | ||
| 7484 | USE_SAFE_ALLOCA; | 7486 | USE_SAFE_ALLOCA; |
| 7485 | 7487 | ||
| @@ -8389,17 +8391,41 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8389 | } | 8391 | } |
| 8390 | 8392 | ||
| 8391 | case ConfigureNotify: | 8393 | 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); | ||
| 8393 | #ifdef USE_CAIRO | 8419 | #ifdef USE_CAIRO |
| 8394 | if (f) x_cr_destroy_surface (f); | 8420 | if (f) x_cr_destroy_surface (f); |
| 8395 | #endif | 8421 | #endif |
| 8396 | #ifdef USE_GTK | 8422 | #ifdef USE_GTK |
| 8397 | if (!f | 8423 | if (!f |
| 8398 | && (f = any) | 8424 | && (f = any) |
| 8399 | && event->xconfigure.window == FRAME_X_WINDOW (f)) | 8425 | && configureEvent.xconfigure.window == FRAME_X_WINDOW (f)) |
| 8400 | { | 8426 | { |
| 8401 | xg_frame_resized (f, event->xconfigure.width, | 8427 | xg_frame_resized (f, configureEvent.xconfigure.width, |
| 8402 | event->xconfigure.height); | 8428 | configureEvent.xconfigure.height); |
| 8403 | #ifdef USE_CAIRO | 8429 | #ifdef USE_CAIRO |
| 8404 | x_cr_destroy_surface (f); | 8430 | x_cr_destroy_surface (f); |
| 8405 | #endif | 8431 | #endif |
| @@ -8408,24 +8434,26 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8408 | #endif | 8434 | #endif |
| 8409 | if (f) | 8435 | if (f) |
| 8410 | { | 8436 | { |
| 8411 | x_net_wm_state (f, event->xconfigure.window); | 8437 | x_net_wm_state (f, configureEvent.xconfigure.window); |
| 8412 | 8438 | ||
| 8413 | #ifdef USE_X_TOOLKIT | 8439 | #ifdef USE_X_TOOLKIT |
| 8414 | /* Tip frames are pure X window, set size for them. */ | 8440 | /* Tip frames are pure X window, set size for them. */ |
| 8415 | if (! NILP (tip_frame) && XFRAME (tip_frame) == f) | 8441 | if (! NILP (tip_frame) && XFRAME (tip_frame) == f) |
| 8416 | { | 8442 | { |
| 8417 | if (FRAME_PIXEL_HEIGHT (f) != event->xconfigure.height | 8443 | if (FRAME_PIXEL_HEIGHT (f) != configureEvent.xconfigure.height |
| 8418 | || FRAME_PIXEL_WIDTH (f) != event->xconfigure.width) | 8444 | || FRAME_PIXEL_WIDTH (f) != configureEvent.xconfigure.width) |
| 8419 | SET_FRAME_GARBAGED (f); | 8445 | SET_FRAME_GARBAGED (f); |
| 8420 | FRAME_PIXEL_HEIGHT (f) = event->xconfigure.height; | 8446 | FRAME_PIXEL_HEIGHT (f) = configureEvent.xconfigure.height; |
| 8421 | FRAME_PIXEL_WIDTH (f) = event->xconfigure.width; | 8447 | FRAME_PIXEL_WIDTH (f) = configureEvent.xconfigure.width; |
| 8422 | } | 8448 | } |
| 8423 | #endif | 8449 | #endif |
| 8424 | 8450 | ||
| 8425 | #ifndef USE_X_TOOLKIT | 8451 | #ifndef USE_X_TOOLKIT |
| 8426 | #ifndef USE_GTK | 8452 | #ifndef USE_GTK |
| 8427 | int width = FRAME_PIXEL_TO_TEXT_WIDTH (f, event->xconfigure.width); | 8453 | int width = |
| 8428 | int height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, event->xconfigure.height); | 8454 | FRAME_PIXEL_TO_TEXT_WIDTH (f, configureEvent.xconfigure.width); |
| 8455 | int height = | ||
| 8456 | FRAME_PIXEL_TO_TEXT_HEIGHT (f, configureEvent.xconfigure.height); | ||
| 8429 | 8457 | ||
| 8430 | /* In the toolkit version, change_frame_size | 8458 | /* In the toolkit version, change_frame_size |
| 8431 | is called by the code that handles resizing | 8459 | is called by the code that handles resizing |
| @@ -8436,8 +8464,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 8436 | to check the pixel dimensions as well. */ | 8464 | to check the pixel dimensions as well. */ |
| 8437 | if (width != FRAME_TEXT_WIDTH (f) | 8465 | if (width != FRAME_TEXT_WIDTH (f) |
| 8438 | || height != FRAME_TEXT_HEIGHT (f) | 8466 | || height != FRAME_TEXT_HEIGHT (f) |
| 8439 | || event->xconfigure.width != FRAME_PIXEL_WIDTH (f) | 8467 | || configureEvent.xconfigure.width != FRAME_PIXEL_WIDTH (f) |
| 8440 | || event->xconfigure.height != FRAME_PIXEL_HEIGHT (f)) | 8468 | || configureEvent.xconfigure.height != FRAME_PIXEL_HEIGHT (f)) |
| 8441 | { | 8469 | { |
| 8442 | change_frame_size (f, width, height, false, true, false, true); | 8470 | change_frame_size (f, width, height, false, true, false, true); |
| 8443 | x_clear_under_internal_border (f); | 8471 | x_clear_under_internal_border (f); |