From 6a788d2fc18c23dcfc5d0352649b2f690e9cbff7 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 13 Jan 2017 19:47:22 -0500 Subject: [PATCH] Don't wait for frame to become visible * src/xterm.c (x_make_frame_visible): Remove code that waits for the frame to become visible. We have to deal with invisible frames anyway, the loop could sometimes before the frame turned visible, and for some window managers (e.g., XMonad, i3wm) it caused Emacs to get stuck in a busy loop (Bug#24091). --- src/xterm.c | 58 ++++------------------------------------------------------ 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index adc02e2768d..db561c902a6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10993,19 +10993,12 @@ xembed_send_message (struct frame *f, Time t, enum xembed_message msg, /* Change of visibility. */ -/* This tries to wait until the frame is really visible. - However, if the window manager asks the user where to position - the frame, this will return before the user finishes doing that. - The frame will not actually be visible at that time, - but it will become visible later when the window manager - finishes with it. */ +/* This function sends the request to make the frame visible, but may + return before it the frame's visibility is changed. */ void x_make_frame_visible (struct frame *f) { - int original_top, original_left; - int tries = 0; - block_input (); x_set_bitmap_icon (f); @@ -11052,16 +11045,13 @@ x_make_frame_visible (struct frame *f) before we do anything else. We do this loop with input not blocked so that incoming events are handled. */ { - Lisp_Object frame; /* This must be before UNBLOCK_INPUT since events that arrive in response to the actions above will set it when they are handled. */ bool previously_visible = f->output_data.x->has_been_visible; - XSETFRAME (frame, f); - - original_left = f->left_pos; - original_top = f->top_pos; + int original_left = f->left_pos; + int original_top = f->top_pos; /* This must come after we set COUNT. */ unblock_input (); @@ -11105,46 +11095,6 @@ x_make_frame_visible (struct frame *f) unblock_input (); } - - /* Process X events until a MapNotify event has been seen. */ - while (!FRAME_VISIBLE_P (f)) - { - /* Force processing of queued events. */ - x_sync (f); - - /* If on another desktop, the deiconify/map may be ignored and the - frame never becomes visible. XMonad does this. - Prevent an endless loop. */ - if (FRAME_ICONIFIED_P (f) && ++tries > 100) - break; - - /* This hack is still in use at least for Cygwin. See - http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00351.html. - - Machines that do polling rather than SIGIO have been - observed to go into a busy-wait here. So we'll fake an - alarm signal to let the handler know that there's something - to be read. We used to raise a real alarm, but it seems - that the handler isn't always enabled here. This is - probably a bug. */ - if (input_polling_used ()) - { - /* It could be confusing if a real alarm arrives while - processing the fake one. Turn it off and let the - handler reset it. */ - int old_poll_suppress_count = poll_suppress_count; - poll_suppress_count = 1; - poll_for_input_1 (); - poll_suppress_count = old_poll_suppress_count; - } - - if (XPending (FRAME_X_DISPLAY (f))) - { - XEvent xev; - XNextEvent (FRAME_X_DISPLAY (f), &xev); - x_dispatch_event (&xev, FRAME_X_DISPLAY (f)); - } - } } } -- 2.11.4.GIT