diff options
| author | Noam Postavsky | 2017-09-25 21:58:55 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2017-09-29 18:40:06 -0400 |
| commit | 695cf5300b4f5b0a8f3bd615b3259a99c5532b5e (patch) | |
| tree | 637ed4f56c402f039ee5da782f415ac8dbdf96e3 /src | |
| parent | e1f6e3127a292e6ba66d27c49ddda4fe949569f5 (diff) | |
| download | emacs-695cf5300b4f5b0a8f3bd615b3259a99c5532b5e.tar.gz emacs-695cf5300b4f5b0a8f3bd615b3259a99c5532b5e.zip | |
Wait for frame visibility with timeout in w32term too
* src/w32term.c (syms_of_w32term) [x-wait-for-event-timeout]: New
variable.
(x_make_frame_visible): Wait for frame to become visible according to
its value.
(input_signal_count): Remove.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32term.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/w32term.c b/src/w32term.c index d7ec40118f3..0a44a8fb223 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -163,10 +163,6 @@ int last_scroll_bar_drag_pos; | |||
| 163 | /* Keyboard code page - may be changed by language-change events. */ | 163 | /* Keyboard code page - may be changed by language-change events. */ |
| 164 | int w32_keyboard_codepage; | 164 | int w32_keyboard_codepage; |
| 165 | 165 | ||
| 166 | /* Incremented by w32_read_socket whenever it really tries to read | ||
| 167 | events. */ | ||
| 168 | static int volatile input_signal_count; | ||
| 169 | |||
| 170 | #ifdef CYGWIN | 166 | #ifdef CYGWIN |
| 171 | int w32_message_fd = -1; | 167 | int w32_message_fd = -1; |
| 172 | #endif /* CYGWIN */ | 168 | #endif /* CYGWIN */ |
| @@ -4658,9 +4654,6 @@ w32_read_socket (struct terminal *terminal, | |||
| 4658 | 4654 | ||
| 4659 | block_input (); | 4655 | block_input (); |
| 4660 | 4656 | ||
| 4661 | /* So people can tell when we have read the available input. */ | ||
| 4662 | input_signal_count++; | ||
| 4663 | |||
| 4664 | /* Process any incoming thread messages. */ | 4657 | /* Process any incoming thread messages. */ |
| 4665 | drain_message_queue (); | 4658 | drain_message_queue (); |
| 4666 | 4659 | ||
| @@ -6614,7 +6607,8 @@ w32_frame_raise_lower (struct frame *f, bool raise_flag) | |||
| 6614 | 6607 | ||
| 6615 | /* Change of visibility. */ | 6608 | /* Change of visibility. */ |
| 6616 | 6609 | ||
| 6617 | /* This tries to wait until the frame is really visible. | 6610 | /* This tries to wait until the frame is really visible, depending on |
| 6611 | the value of Vx_visible_frame_timeout. | ||
| 6618 | However, if the window manager asks the user where to position | 6612 | However, if the window manager asks the user where to position |
| 6619 | the frame, this will return before the user finishes doing that. | 6613 | the frame, this will return before the user finishes doing that. |
| 6620 | The frame will not actually be visible at that time, | 6614 | The frame will not actually be visible at that time, |
| @@ -6673,12 +6667,16 @@ x_make_frame_visible (struct frame *f) | |||
| 6673 | : SW_SHOWNORMAL); | 6667 | : SW_SHOWNORMAL); |
| 6674 | } | 6668 | } |
| 6675 | 6669 | ||
| 6670 | if (!FLOATP (Vx_wait_for_event_timeout)) | ||
| 6671 | return; | ||
| 6672 | |||
| 6676 | /* Synchronize to ensure Emacs knows the frame is visible | 6673 | /* Synchronize to ensure Emacs knows the frame is visible |
| 6677 | before we do anything else. We do this loop with input not blocked | 6674 | before we do anything else. We do this loop with input not blocked |
| 6678 | so that incoming events are handled. */ | 6675 | so that incoming events are handled. */ |
| 6679 | { | 6676 | { |
| 6680 | Lisp_Object frame; | 6677 | Lisp_Object frame; |
| 6681 | int count; | 6678 | double timeout = XFLOAT_DATA (Vx_wait_for_event_timeout); |
| 6679 | double start_time = XFLOAT_DATA (Ffloat_time (Qnil)); | ||
| 6682 | 6680 | ||
| 6683 | /* This must come after we set COUNT. */ | 6681 | /* This must come after we set COUNT. */ |
| 6684 | unblock_input (); | 6682 | unblock_input (); |
| @@ -6688,8 +6686,8 @@ x_make_frame_visible (struct frame *f) | |||
| 6688 | /* Wait until the frame is visible. Process X events until a | 6686 | /* Wait until the frame is visible. Process X events until a |
| 6689 | MapNotify event has been seen, or until we think we won't get a | 6687 | MapNotify event has been seen, or until we think we won't get a |
| 6690 | MapNotify at all.. */ | 6688 | MapNotify at all.. */ |
| 6691 | for (count = input_signal_count + 10; | 6689 | while (timeout > (XFLOAT_DATA (Ffloat_time (Qnil)) - start_time) && |
| 6692 | input_signal_count < count && !FRAME_VISIBLE_P (f);) | 6690 | !FRAME_VISIBLE_P (f)) |
| 6693 | { | 6691 | { |
| 6694 | /* Force processing of queued events. */ | 6692 | /* Force processing of queued events. */ |
| 6695 | /* TODO: x_sync equivalent? */ | 6693 | /* TODO: x_sync equivalent? */ |
| @@ -7321,6 +7319,17 @@ syms_of_w32term (void) | |||
| 7321 | DEFSYM (Qrenamed_from, "renamed-from"); | 7319 | DEFSYM (Qrenamed_from, "renamed-from"); |
| 7322 | DEFSYM (Qrenamed_to, "renamed-to"); | 7320 | DEFSYM (Qrenamed_to, "renamed-to"); |
| 7323 | 7321 | ||
| 7322 | DEFVAR_LISP ("x-wait-for-event-timeout", Vx_wait_for_event_timeout, | ||
| 7323 | doc: /* How long to wait for X events. | ||
| 7324 | |||
| 7325 | Emacs will wait up to this many seconds to receive X events after | ||
| 7326 | making changes which affect the state of the graphical interface. | ||
| 7327 | Under some window managers this can take an indefinite amount of time, | ||
| 7328 | so it is important to limit the wait. | ||
| 7329 | |||
| 7330 | If set to a non-float value, there will be no wait at all. */); | ||
| 7331 | Vx_wait_for_event_timeout = make_float (0.1); | ||
| 7332 | |||
| 7324 | DEFVAR_INT ("w32-num-mouse-buttons", | 7333 | DEFVAR_INT ("w32-num-mouse-buttons", |
| 7325 | w32_num_mouse_buttons, | 7334 | w32_num_mouse_buttons, |
| 7326 | doc: /* Number of physical mouse buttons. */); | 7335 | doc: /* Number of physical mouse buttons. */); |