diff options
| author | Noam Postavsky | 2017-08-30 23:12:22 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-09-29 18:40:06 -0400 |
| commit | e1f6e3127a292e6ba66d27c49ddda4fe949569f5 (patch) | |
| tree | db6e5880027257ae04a6655a0b619a4b9efb51d4 /src | |
| parent | bccf635217b0ba887d95b429f7d5d6903007a7b1 (diff) | |
| download | emacs-e1f6e3127a292e6ba66d27c49ddda4fe949569f5.tar.gz emacs-e1f6e3127a292e6ba66d27c49ddda4fe949569f5.zip | |
Bring back the busy wait after x_make_frame_visible (Bug#25521)
But wait specfically for a MapNotify event, and only for a
configurable amount of time.
* src/xterm.c (syms_of_xterm) [x-wait-for-event-timeout]: New
variable.
(x_wait_for_event): Use it instead of hardcoding the wait to 0.1s.
(x_make_frame_visible): Call x_wait_for_event at the end.
* etc/NEWS: Announce x_wait_for_event.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/xterm.c b/src/xterm.c index 0b321909c85..90275763cbe 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -11029,17 +11029,22 @@ x_sync_with_move (struct frame *f, int left, int top, bool fuzzy) | |||
| 11029 | void | 11029 | void |
| 11030 | x_wait_for_event (struct frame *f, int eventtype) | 11030 | x_wait_for_event (struct frame *f, int eventtype) |
| 11031 | { | 11031 | { |
| 11032 | int level = interrupt_input_blocked; | 11032 | if (!FLOATP (Vx_wait_for_event_timeout)) |
| 11033 | return; | ||
| 11033 | 11034 | ||
| 11035 | int level = interrupt_input_blocked; | ||
| 11034 | fd_set fds; | 11036 | fd_set fds; |
| 11035 | struct timespec tmo, tmo_at, time_now; | 11037 | struct timespec tmo, tmo_at, time_now; |
| 11036 | int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); | 11038 | int fd = ConnectionNumber (FRAME_X_DISPLAY (f)); |
| 11037 | 11039 | ||
| 11038 | f->wait_event_type = eventtype; | 11040 | f->wait_event_type = eventtype; |
| 11039 | 11041 | ||
| 11040 | /* Set timeout to 0.1 second. Hopefully not noticeable. | 11042 | /* Default timeout is 0.1 second. Hopefully not noticeable. */ |
| 11041 | Maybe it should be configurable. */ | 11043 | double timeout = XFLOAT_DATA (Vx_wait_for_event_timeout); |
| 11042 | tmo = make_timespec (0, 100 * 1000 * 1000); | 11044 | time_t timeout_seconds = (time_t) timeout; |
| 11045 | tmo = make_timespec | ||
| 11046 | (timeout_seconds, (long int) ((timeout - timeout_seconds) | ||
| 11047 | * 1000 * 1000 * 1000)); | ||
| 11043 | tmo_at = timespec_add (current_timespec (), tmo); | 11048 | tmo_at = timespec_add (current_timespec (), tmo); |
| 11044 | 11049 | ||
| 11045 | while (f->wait_event_type) | 11050 | while (f->wait_event_type) |
| @@ -11365,8 +11370,13 @@ xembed_send_message (struct frame *f, Time t, enum xembed_message msg, | |||
| 11365 | 11370 | ||
| 11366 | /* Change of visibility. */ | 11371 | /* Change of visibility. */ |
| 11367 | 11372 | ||
| 11368 | /* This function sends the request to make the frame visible, but may | 11373 | /* This tries to wait until the frame is really visible, depending on |
| 11369 | return before it the frame's visibility is changed. */ | 11374 | the value of Vx_wait_for_event_timeout. |
| 11375 | However, if the window manager asks the user where to position | ||
| 11376 | the frame, this will return before the user finishes doing that. | ||
| 11377 | The frame will not actually be visible at that time, | ||
| 11378 | but it will become visible later when the window manager | ||
| 11379 | finishes with it. */ | ||
| 11370 | 11380 | ||
| 11371 | void | 11381 | void |
| 11372 | x_make_frame_visible (struct frame *f) | 11382 | x_make_frame_visible (struct frame *f) |
| @@ -11437,11 +11447,14 @@ x_make_frame_visible (struct frame *f) | |||
| 11437 | before we do anything else. We do this loop with input not blocked | 11447 | before we do anything else. We do this loop with input not blocked |
| 11438 | so that incoming events are handled. */ | 11448 | so that incoming events are handled. */ |
| 11439 | { | 11449 | { |
| 11450 | Lisp_Object frame; | ||
| 11440 | /* This must be before UNBLOCK_INPUT | 11451 | /* This must be before UNBLOCK_INPUT |
| 11441 | since events that arrive in response to the actions above | 11452 | since events that arrive in response to the actions above |
| 11442 | will set it when they are handled. */ | 11453 | will set it when they are handled. */ |
| 11443 | bool previously_visible = f->output_data.x->has_been_visible; | 11454 | bool previously_visible = f->output_data.x->has_been_visible; |
| 11444 | 11455 | ||
| 11456 | XSETFRAME (frame, f); | ||
| 11457 | |||
| 11445 | int original_left = f->left_pos; | 11458 | int original_left = f->left_pos; |
| 11446 | int original_top = f->top_pos; | 11459 | int original_top = f->top_pos; |
| 11447 | 11460 | ||
| @@ -11488,6 +11501,10 @@ x_make_frame_visible (struct frame *f) | |||
| 11488 | 11501 | ||
| 11489 | unblock_input (); | 11502 | unblock_input (); |
| 11490 | } | 11503 | } |
| 11504 | |||
| 11505 | /* Try to wait for a MapNotify event (that is what tells us when a | ||
| 11506 | frame becomes visible). */ | ||
| 11507 | x_wait_for_event (f, MapNotify); | ||
| 11491 | } | 11508 | } |
| 11492 | } | 11509 | } |
| 11493 | 11510 | ||
| @@ -13283,6 +13300,17 @@ This should be one of the symbols `ctrl', `alt', `hyper', `meta', | |||
| 13283 | keysyms. The default is nil, which is the same as `super'. */); | 13300 | keysyms. The default is nil, which is the same as `super'. */); |
| 13284 | Vx_super_keysym = Qnil; | 13301 | Vx_super_keysym = Qnil; |
| 13285 | 13302 | ||
| 13303 | DEFVAR_LISP ("x-wait-for-event-timeout", Vx_wait_for_event_timeout, | ||
| 13304 | doc: /* How long to wait for X events. | ||
| 13305 | |||
| 13306 | Emacs will wait up to this many seconds to receive X events after | ||
| 13307 | making changes which affect the state of the graphical interface. | ||
| 13308 | Under some window managers this can take an indefinite amount of time, | ||
| 13309 | so it is important to limit the wait. | ||
| 13310 | |||
| 13311 | If set to a non-float value, there will be no wait at all. */); | ||
| 13312 | Vx_wait_for_event_timeout = make_float (0.1); | ||
| 13313 | |||
| 13286 | DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, | 13314 | DEFVAR_LISP ("x-keysym-table", Vx_keysym_table, |
| 13287 | doc: /* Hash table of character codes indexed by X keysym codes. */); | 13315 | doc: /* Hash table of character codes indexed by X keysym codes. */); |
| 13288 | Vx_keysym_table = make_hash_table (hashtest_eql, 900, | 13316 | Vx_keysym_table = make_hash_table (hashtest_eql, 900, |