From: Dmitry Antipov Date: Thu, 24 Jan 2013 05:41:28 +0000 (+0400) Subject: Drop async_visible and async_iconified fields of struct frame. X-Git-Tag: emacs-24.3.90~173^2~7^2~228 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=edfa7fa092c303265edeb2a0b530463cdfe63ab7;p=emacs.git Drop async_visible and async_iconified fields of struct frame. This is possible because async input is gone; for details, see http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00734.html. * frame.h (struct frame): Remove async_visible and async_iconified members, convert garbaged to unsigned bitfield. Adjust comments. (FRAME_SAMPLE_VISIBILITY): Remove. Adjust all users. (SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED): New macros. * frame.c, gtkutil.c, term.c, w32fns.c, window.c, xdisp.c: Consistently use SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED, FRAME_VISIBLE_P and FRAME_ICONIFIED_P macros where appropriate. * w32term.c: Ditto. (w32_read_socket): Save iconified state to generate DEICONIFY_EVENT properly. Likewise for obscured. * xterm.c: Ditto. (handle_one_xevent): Save visible state go generate ICONIFY_EVENT properly. * nsterm.m: Ditto. (windowDidDeminiaturize): Generate DEICONIFY_EVENT. --- diff --git a/src/ChangeLog b/src/ChangeLog index 0ee2dbfd53f..e89196a15c5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2013-01-24 Dmitry Antipov + + Drop async_visible and async_iconified fields of struct frame. + This is possible because async input is gone; for details, see + http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00734.html. + * frame.h (struct frame): Remove async_visible and async_iconified + members, convert garbaged to unsigned bitfield. Adjust comments. + (FRAME_SAMPLE_VISIBILITY): Remove. Adjust all users. + (SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED): New macros. + * frame.c, gtkutil.c, term.c, w32fns.c, window.c, xdisp.c: + Consistently use SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED, + FRAME_VISIBLE_P and FRAME_ICONIFIED_P macros where appropriate. + * w32term.c: Ditto. + (w32_read_socket): Save iconified state to generate DEICONIFY_EVENT + properly. Likewise for obscured. + * xterm.c: Ditto. + (handle_one_xevent): Save visible state go generate ICONIFY_EVENT + properly. + * nsterm.m: Ditto. + (windowDidDeminiaturize): Generate DEICONIFY_EVENT. + 2013-01-24 Dmitry Antipov * insdel.c (prepare_to_modify_buffer): Revert last change as suggested diff --git a/src/frame.c b/src/frame.c index 11886783e4c..9c26af819bc 100644 --- a/src/frame.c +++ b/src/frame.c @@ -500,8 +500,7 @@ make_initial_frame (void) tty_frame_count = 1; fset_name (f, build_pure_c_string ("F1")); - f->visible = 1; - f->async_visible = 1; + SET_FRAME_VISIBLE (f, 1); f->output_method = terminal->type; f->terminal = terminal; @@ -540,8 +539,8 @@ make_terminal_frame (struct terminal *terminal) fset_name (f, make_formatted_string (name, "F%"pMd, ++tty_frame_count)); - f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ - f->async_visible = 1; /* Don't let visible be cleared later. */ + SET_FRAME_VISIBLE (f, 1); + f->terminal = terminal; f->terminal->reference_count++; #ifdef MSDOS @@ -565,7 +564,7 @@ make_terminal_frame (struct terminal *terminal) /* Set the top frame to the newly created frame. */ if (FRAMEP (FRAME_TTY (f)->top_frame) && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame))) - XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */ + SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f)->top_frame), 2); /* obscured */ FRAME_TTY (f)->top_frame = frame; @@ -806,8 +805,8 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor { if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame)) /* Mark previously displayed frame as now obscured. */ - XFRAME (FRAME_TTY (XFRAME (frame))->top_frame)->async_visible = 2; - XFRAME (frame)->async_visible = 1; + SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (XFRAME (frame))->top_frame), 2); + SET_FRAME_VISIBLE (XFRAME (frame), 1); FRAME_TTY (XFRAME (frame))->top_frame = frame; } @@ -914,7 +913,6 @@ candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf) } else if (EQ (minibuf, Qvisible)) { - FRAME_SAMPLE_VISIBILITY (c); if (FRAME_VISIBLE_P (c)) return candidate; } @@ -928,7 +926,6 @@ candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf) } else if (XFASTINT (minibuf) == 0) { - FRAME_SAMPLE_VISIBILITY (c); if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c)) return candidate; } @@ -1052,10 +1049,7 @@ other_visible_frames (FRAME_PTR f) and note any recent change in visibility. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (XFRAME (this))) - { - x_sync (XFRAME (this)); - FRAME_SAMPLE_VISIBILITY (XFRAME (this)); - } + x_sync (XFRAME (this)); #endif if (FRAME_VISIBLE_P (XFRAME (this)) @@ -1231,7 +1225,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) fset_root_window (f, Qnil); Vframe_list = Fdelq (frame, Vframe_list); - FRAME_SET_VISIBLE (f, 0); + SET_FRAME_VISIBLE (f, 0); /* Allow the vector of menu bar contents to be freed in the next garbage collection. The frame object itself may not be garbage @@ -1579,10 +1573,7 @@ If omitted, FRAME defaults to the currently selected frame. */) /* I think this should be done with a hook. */ #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) - { - FRAME_SAMPLE_VISIBILITY (f); - x_make_frame_visible (f); - } + x_make_frame_visible (f); #endif make_frame_visible_1 (f->root_window); @@ -1705,8 +1696,6 @@ currently being displayed on the terminal. */) { CHECK_LIVE_FRAME (frame); - FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); - if (FRAME_VISIBLE_P (XFRAME (frame))) return Qt; if (FRAME_ICONIFIED_P (XFRAME (frame))) @@ -2891,7 +2880,6 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr) make_formatted_string (buf, "%"pMu, w)); #endif store_in_alist (alistptr, Qicon_name, f->icon_name); - FRAME_SAMPLE_VISIBILITY (f); store_in_alist (alistptr, Qvisibility, (FRAME_VISIBLE_P (f) ? Qt : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); diff --git a/src/frame.h b/src/frame.h index c2821066c82..c18b7662079 100644 --- a/src/frame.h +++ b/src/frame.h @@ -353,46 +353,30 @@ struct frame unsigned int external_menu_bar : 1; #endif - /* visible is nonzero if the frame is currently displayed; we check + /* Next two bitfields are mutually exclusive. They might both be + zero if the frame has been made invisible without an icon. */ + + /* Nonzero if the frame is currently displayed; we check it to see if we should bother updating the frame's contents. - DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE. Note that, since invisible frames aren't updated, whenever a - frame becomes visible again, it must be marked as garbaged. The - FRAME_SAMPLE_VISIBILITY macro takes care of this. + frame becomes visible again, it must be marked as garbaged. On ttys and on Windows NT/9X, to avoid wasting effort updating visible frames that are actually completely obscured by other windows on the display, we bend the meaning of visible slightly: - if greater than 1, then the frame is obscured - we still consider + if equal to 2, then the frame is obscured - we still consider it to be "visible" as seen from lisp, but we don't bother updating it. We must take care to garbage the frame when it - ceases to be obscured though. - - iconified is nonzero if the frame is currently iconified. - - Asynchronous input handlers should NOT change these directly; - instead, they should change async_visible or async_iconified, and - let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified - at the next redisplay. - - These should probably be considered read-only by everyone except - FRAME_SAMPLE_VISIBILITY. - - These two are mutually exclusive. They might both be zero, if the - frame has been made invisible without an icon. */ + ceases to be obscured though. See SET_FRAME_VISIBLE below. */ unsigned visible : 2; - unsigned iconified : 1; - - /* Let's not use bitfields for volatile variables. */ - /* Asynchronous input handlers change these, and - FRAME_SAMPLE_VISIBILITY copies them into visible and iconified. - See FRAME_SAMPLE_VISIBILITY, below. */ - volatile char async_visible, async_iconified; + /* Nonzero if the frame is currently iconified. Do not + set this directly, use SET_FRAME_ICONIFIED instead. */ + unsigned iconified : 1; /* Nonzero if this frame should be redrawn. */ - volatile char garbaged; + unsigned garbaged : 1; /* True if frame actually has a minibuffer window on it. 0 if using a minibuffer window that isn't on this frame. */ @@ -711,7 +695,7 @@ typedef struct frame *FRAME_PTR; #else #define FRAME_EXTERNAL_MENU_BAR(f) 0 #endif -#define FRAME_VISIBLE_P(f) ((f)->visible != 0) +#define FRAME_VISIBLE_P(f) (f)->visible /* Nonzero if frame F is currently visible but hidden. */ #define FRAME_OBSCURED_P(f) ((f)->visible > 1) @@ -719,9 +703,10 @@ typedef struct frame *FRAME_PTR; /* Nonzero if frame F is currently iconified. */ #define FRAME_ICONIFIED_P(f) (f)->iconified -#define FRAME_SET_VISIBLE(f,p) \ - ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f)) +/* Mark frame F as currently garbaged. */ #define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1) + +/* Nonzero if frame F is currently garbaged. */ #define FRAME_GARBAGED_P(f) (f)->garbaged /* Nonzero means do not allow splitting this frame's window. */ @@ -866,39 +851,6 @@ typedef struct frame *FRAME_PTR; #define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4) -/* Emacs's redisplay code could become confused if a frame's - visibility changes at arbitrary times. For example, if a frame is - visible while the desired glyphs are being built, but becomes - invisible before they are updated, then some rows of the - desired_glyphs will be left marked as enabled after redisplay is - complete, which should never happen. The next time the frame - becomes visible, redisplay will probably barf. - - Currently, there are no similar situations involving iconified, but - the principle is the same. - - So instead of having asynchronous input handlers directly set and - clear the frame's visibility and iconification flags, they just set - the async_visible and async_iconified flags; the redisplay code - calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay, - which sets visible and iconified from their asynchronous - counterparts. - - Synchronous code must use the FRAME_SET_VISIBLE macro. - - Also, if a frame used to be invisible, but has just become visible, - it must be marked as garbaged, since redisplay hasn't been keeping - up its contents. - - Note that a tty frame is visible if and only if it is the topmost - frame. */ - -#define FRAME_SAMPLE_VISIBILITY(f) \ - (((f)->async_visible && (f)->visible != (f)->async_visible) ? \ - SET_FRAME_GARBAGED (f) : 0, \ - (f)->visible = (f)->async_visible, \ - (f)->iconified = (f)->async_iconified) - #define CHECK_FRAME(x) \ CHECK_TYPE (FRAMEP (x), Qframep, x) @@ -932,12 +884,24 @@ typedef struct frame *FRAME_PTR; block_input (); \ if (hlinfo->mouse_face_mouse_frame) \ note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \ - hlinfo->mouse_face_mouse_x, \ - hlinfo->mouse_face_mouse_y); \ + hlinfo->mouse_face_mouse_x, \ + hlinfo->mouse_face_mouse_y); \ unblock_input (); \ } \ } while (0) +/* Set visibility of frame F, marking F as garbaged if needed. */ + +#define SET_FRAME_VISIBLE(f, v) \ + (((f)->visible == 0 || ((f)->visible == 2)) \ + && ((v) == 1) ? SET_FRAME_GARBAGED (f) : 0, \ + (f)->visible = (eassert (0 <= (v) && (v) <= 2), (v))) + +/* Set iconify of frame F. */ + +#define SET_FRAME_ICONIFIED(f, i) \ + (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i)) + extern Lisp_Object Qframep, Qframe_live_p; extern Lisp_Object Qtty, Qtty_type; extern Lisp_Object Qtty_color_mode; diff --git a/src/gtkutil.c b/src/gtkutil.c index d5bc159c063..4771d34b4a0 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -983,7 +983,7 @@ xg_frame_set_char_size (FRAME_PTR f, int cols, int rows) size as fast as possible. For unmapped windows, we can set rows/cols. When the frame is mapped again we will (hopefully) get the correct size. */ - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) { /* Must call this to flush out events */ (void)gtk_events_pending (); diff --git a/src/nsterm.m b/src/nsterm.m index d346f05624b..3544cfd79a0 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1000,11 +1000,8 @@ ns_raise_frame (struct frame *f) NSView *view = FRAME_NS_VIEW (f); check_ns (); block_input (); - FRAME_SAMPLE_VISIBILITY (f); if (FRAME_VISIBLE_P (f)) - { - [[view window] makeKeyAndOrderFront: NSApp]; - } + [[view window] makeKeyAndOrderFront: NSApp]; unblock_input (); } @@ -1093,7 +1090,8 @@ x_make_frame_visible (struct frame *f) if (!FRAME_VISIBLE_P (f)) { EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); - f->async_visible = 1; + + SET_FRAME_VISIBLE (f, 1); ns_raise_frame (f); #ifdef NEW_STYLE_FS @@ -1123,8 +1121,8 @@ x_make_frame_invisible (struct frame *f) NSTRACE (x_make_frame_invisible); check_ns (); [[view window] orderOut: NSApp]; - f->async_visible = 0; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 0); } @@ -1354,7 +1352,9 @@ ns_fullscreen_hook (FRAME_PTR f) { EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); - if (! f->async_visible) return; + if (!FRAME_VISIBLE_P (f)) + return; + #ifndef NEW_STYLE_FS if (f->want_fullscreen == FULLSCREEN_BOTH) { @@ -5824,13 +5824,14 @@ not_in_argv (NSString *arg) NSTRACE (windowDidDeminiaturize); if (!emacsframe->output_data.ns) return; - emacsframe->async_iconified = 0; - emacsframe->async_visible = 1; + + SET_FRAME_ICONIFIED (emacsframe, 0); + SET_FRAME_VISIBLE (emacsframe, 1); windows_or_buffers_changed++; if (emacs_event) { - emacs_event->kind = ICONIFY_EVENT; + emacs_event->kind = DEICONIFY_EVENT; EV_TRAILER ((id)nil); } } @@ -5841,7 +5842,8 @@ not_in_argv (NSString *arg) NSTRACE (windowDidExpose); if (!emacsframe->output_data.ns) return; - emacsframe->async_visible = 1; + + SET_FRAME_VISIBLE (emacsframe, 1); SET_FRAME_GARBAGED (emacsframe); if (send_appdefined) @@ -5855,8 +5857,8 @@ not_in_argv (NSString *arg) if (!emacsframe->output_data.ns) return; - emacsframe->async_iconified = 1; - emacsframe->async_visible = 0; + SET_FRAME_ICONIFIED (emacsframe, 1); + SET_FRAME_VISIBLE (emacsframe, 0); if (emacs_event) { diff --git a/src/term.c b/src/term.c index f66a0bddc33..a31fd51084e 100644 --- a/src/term.c +++ b/src/term.c @@ -2374,7 +2374,7 @@ A suspended tty may be resumed by calling `resume-tty' on it. */) t->display_info.tty->output = 0; if (FRAMEP (t->display_info.tty->top_frame)) - FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0); + SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0); } @@ -2444,7 +2444,7 @@ frame's terminal). */) get_tty_size (fileno (t->display_info.tty->input), &width, &height); if (width != old_width || height != old_height) change_frame_size (f, height, width, 0, 0, 0); - FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); + SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); } set_tty_hooks (t); diff --git a/src/w32fns.c b/src/w32fns.c index 355ee96b9f3..6c098cae3a3 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -5943,7 +5943,7 @@ Text larger than the specified size is clipped. */) SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); /* Let redisplay know that we have made the frame visible already. */ - f->async_visible = 1; + SET_FRAME_VISIBLE (f, 1); ShowWindow (FRAME_W32_WINDOW (f), SW_SHOWNOACTIVATE); } diff --git a/src/w32term.c b/src/w32term.c index 0cb2effcda1..c83ee31d200 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -4319,24 +4319,25 @@ w32_read_socket (struct terminal *terminal, DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f, SDATA (f->name))); } - else if (f->async_visible != 1) + else if (FRAME_VISIBLE_P (f) != 1) { + bool iconified = FRAME_ICONIFIED_P (f); + /* Definitely not obscured, so mark as visible. */ - f->async_visible = 1; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, 0); SET_FRAME_GARBAGED (f); DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f, SDATA (f->name))); /* WM_PAINT serves as MapNotify as well, so report visibility changes properly. */ - if (f->iconified) + if (iconified) { inev.kind = DEICONIFY_EVENT; XSETFRAME (inev.frame_or_window, f); } - else if (! NILP (Vframe_list) - && ! NILP (XCDR (Vframe_list))) + else if (!NILP (Vframe_list) && !NILP (XCDR (Vframe_list))) /* Force a redisplay sooner or later to update the frame titles in case this is the second frame. */ record_asynch_buffer_change (); @@ -4379,7 +4380,7 @@ w32_read_socket (struct terminal *terminal, case WM_SYSKEYDOWN: f = x_window_to_frame (dpyinfo, msg.msg.hwnd); - if (f && !f->iconified) + if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) @@ -4404,7 +4405,7 @@ w32_read_socket (struct terminal *terminal, case WM_CHAR: f = x_window_to_frame (dpyinfo, msg.msg.hwnd); - if (f && !f->iconified) + if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) @@ -4482,7 +4483,7 @@ w32_read_socket (struct terminal *terminal, case WM_APPCOMMAND: f = x_window_to_frame (dpyinfo, msg.msg.hwnd); - if (f && !f->iconified) + if (f && !FRAME_ICONIFIED_P (f)) { if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) @@ -4722,7 +4723,7 @@ w32_read_socket (struct terminal *terminal, case WM_MOVE: f = x_window_to_frame (dpyinfo, msg.msg.hwnd); - if (f && !f->async_iconified) + if (f && !FRAME_ICONIFIED_P (f)) { int x, y; @@ -4770,8 +4771,8 @@ w32_read_socket (struct terminal *terminal, switch (msg.msg.wParam) { case SIZE_MINIMIZED: - f->async_visible = 0; - f->async_iconified = 1; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 1); inev.kind = ICONIFY_EVENT; XSETFRAME (inev.frame_or_window, f); @@ -4779,40 +4780,44 @@ w32_read_socket (struct terminal *terminal, case SIZE_MAXIMIZED: case SIZE_RESTORED: - f->async_visible = 1; - f->async_iconified = 0; + { + bool iconified = FRAME_ICONIFIED_P (f); - /* wait_reading_process_output will notice this and update - the frame's display structures. */ - SET_FRAME_GARBAGED (f); + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, 0); - if (f->iconified) - { - int x, y; - - /* Reset top and left positions of the Window - here since Windows sends a WM_MOVE message - BEFORE telling us the Window is minimized - when the Window is iconified, with 3000,3000 - as the co-ords. */ - x_real_positions (f, &x, &y); - f->left_pos = x; - f->top_pos = y; + /* wait_reading_process_output will notice this + and update the frame's display structures. */ + SET_FRAME_GARBAGED (f); - inev.kind = DEICONIFY_EVENT; - XSETFRAME (inev.frame_or_window, f); - } - else if (! NILP (Vframe_list) - && ! NILP (XCDR (Vframe_list))) - /* Force a redisplay sooner or later - to update the frame titles - in case this is the second frame. */ - record_asynch_buffer_change (); + if (iconified) + { + int x, y; + + /* Reset top and left positions of the Window + here since Windows sends a WM_MOVE message + BEFORE telling us the Window is minimized + when the Window is iconified, with 3000,3000 + as the co-ords. */ + x_real_positions (f, &x, &y); + f->left_pos = x; + f->top_pos = y; + + inev.kind = DEICONIFY_EVENT; + XSETFRAME (inev.frame_or_window, f); + } + else if (! NILP (Vframe_list) + && ! NILP (XCDR (Vframe_list))) + /* Force a redisplay sooner or later + to update the frame titles + in case this is the second frame. */ + record_asynch_buffer_change (); + } break; } } - if (f && !f->async_iconified && msg.msg.wParam != SIZE_MINIMIZED) + if (f && !FRAME_ICONIFIED_P (f) && msg.msg.wParam != SIZE_MINIMIZED) { RECT rect; int rows; @@ -5040,12 +5045,13 @@ w32_read_socket (struct terminal *terminal, continue; /* Check "visible" frames and mark each as obscured or not. - Note that async_visible is nonzero for unobscured and - obscured frames, but zero for hidden and iconified frames. */ - if (FRAME_W32_P (f) && f->async_visible) + Note that visible is nonzero for unobscured and obscured + frames, but zero for hidden and iconified frames. */ + if (FRAME_W32_P (f) && FRAME_VISIBLE_P (f)) { RECT clipbox; HDC hdc; + bool obscured; enter_crit (); /* Query clipping rectangle for the entire window area @@ -5059,31 +5065,28 @@ w32_read_socket (struct terminal *terminal, ReleaseDC (FRAME_W32_WINDOW (f), hdc); leave_crit (); - if (clipbox.right == clipbox.left - || clipbox.bottom == clipbox.top) + obscured = FRAME_OBSCURED_P (f); + + if (clipbox.right == clipbox.left || clipbox.bottom == clipbox.top) { - /* Frame has become completely obscured so mark as - such (we do this by setting async_visible to 2 so - that FRAME_VISIBLE_P is still true, but redisplay - will skip it). */ - f->async_visible = 2; + /* Frame has become completely obscured so mark as such (we + do this by setting visible to 2 so that FRAME_VISIBLE_P + is still true, but redisplay will skip it). */ + SET_FRAME_VISIBLE (f, 2); - if (!FRAME_OBSCURED_P (f)) - { - DebPrint (("frame %p (%s) obscured\n", f, - SDATA (f->name))); - } + if (!obscured) + DebPrint (("frame %p (%s) obscured\n", f, SDATA (f->name))); } else { /* Frame is not obscured, so mark it as such. */ - f->async_visible = 1; + SET_FRAME_VISIBLE (f, 1); - if (FRAME_OBSCURED_P (f)) + if (obscured) { SET_FRAME_GARBAGED (f); - DebPrint (("obscured frame %p (%s) found to be visible\n", f, - SDATA (f->name))); + DebPrint (("obscured frame %p (%s) found to be visible\n", + f, SDATA (f->name))); /* Force a redisplay sooner or later. */ record_asynch_buffer_change (); @@ -5654,7 +5657,7 @@ w32fullscreen_hook (FRAME_PTR f) { static int normal_width, normal_height; - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) { int width, height, top_pos, left_pos, pixel_height, pixel_width; int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f); @@ -6023,11 +6026,11 @@ x_make_frame_visible (struct frame *f) causes unexpected behavior when unminimizing frames that were previously maximized. But only SW_SHOWNORMAL works properly for frames that were truely hidden (using make-frame-invisible), so - we need it to avoid Bug#5482. It seems that async_iconified - is only set for minimized windows that are still visible, so - use that to determine the appropriate flag to pass ShowWindow. */ + we need it to avoid Bug#5482. It seems that iconified is only + set for minimized windows that are still visible, so use that to + determine the appropriate flag to pass ShowWindow. */ my_show_window (f, FRAME_W32_WINDOW (f), - f->async_iconified ? SW_RESTORE : SW_SHOWNORMAL); + FRAME_ICONIFIED_P (f) ? SW_RESTORE : SW_SHOWNORMAL); } /* Synchronize to ensure Emacs knows the frame is visible @@ -6066,7 +6069,6 @@ x_make_frame_visible (struct frame *f) poll_suppress_count = old_poll_suppress_count; } } - FRAME_SAMPLE_VISIBILITY (f); } } @@ -6090,10 +6092,8 @@ x_make_frame_invisible (struct frame *f) So we can't win using the usual strategy of letting FRAME_SAMPLE_VISIBILITY set this. So do it by hand, and synchronize with the server to make sure we agree. */ - f->visible = 0; - FRAME_ICONIFIED_P (f) = 0; - f->async_visible = 0; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 0); unblock_input (); } @@ -6109,7 +6109,7 @@ x_iconify_frame (struct frame *f) if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f) FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0; - if (f->async_iconified) + if (FRAME_ICONIFIED_P (f)) return; block_input (); diff --git a/src/window.c b/src/window.c index db00bc26482..a0ebe4b4484 100644 --- a/src/window.c +++ b/src/window.c @@ -2231,7 +2231,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf } else if (EQ (all_frames, Qvisible)) { - FRAME_SAMPLE_VISIBILITY (f); candidate_p = FRAME_VISIBLE_P (f) && (FRAME_TERMINAL (XFRAME (w->frame)) == FRAME_TERMINAL (XFRAME (selected_frame))); @@ -2239,7 +2238,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf } else if (INTEGERP (all_frames) && XINT (all_frames) == 0) { - FRAME_SAMPLE_VISIBILITY (f); candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) #ifdef HAVE_X_WINDOWS /* Yuck!! If we've just created the frame and the diff --git a/src/xdisp.c b/src/xdisp.c index ba4c5a71bc9..68ee4417c72 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -9644,8 +9644,7 @@ message3_nolog (Lisp_Object m) /* Error messages get reported properly by cmd_error, so this must be just an informative message; if the frame hasn't really been initialized yet, just toss it. */ - else if (INTERACTIVE - && sf->glyphs_initialized_p) + else if (INTERACTIVE && sf->glyphs_initialized_p) { /* Get the frame containing the mini-buffer that the selected frame is using. */ @@ -9653,9 +9652,7 @@ message3_nolog (Lisp_Object m) Lisp_Object frame = XWINDOW (mini_window)->frame; struct frame *f = XFRAME (frame); - FRAME_SAMPLE_VISIBILITY (f); - if (FRAME_VISIBLE_P (sf) - && !FRAME_VISIBLE_P (f)) + if (FRAME_VISIBLE_P (sf) && !FRAME_VISIBLE_P (f)) Fmake_frame_visible (frame); if (STRINGP (m) && SCHARS (m) > 0) @@ -12924,7 +12921,6 @@ redisplay_internal (void) { struct frame *f = XFRAME (frame); - FRAME_SAMPLE_VISIBILITY (f); if (FRAME_VISIBLE_P (f)) ++number_of_visible_frames; clear_desired_matrices (f); @@ -13470,9 +13466,6 @@ redisplay_internal (void) { int this_is_visible = 0; - if (XFRAME (frame)->visible) - this_is_visible = 1; - FRAME_SAMPLE_VISIBILITY (XFRAME (frame)); if (XFRAME (frame)->visible) this_is_visible = 1; diff --git a/src/xterm.c b/src/xterm.c index 26d40859ed3..eef4edf17f6 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -6102,16 +6102,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, last_user_time = event.xproperty.time; f = x_top_window_to_frame (dpyinfo, event.xproperty.window); if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state) - if (x_handle_net_wm_state (f, &event.xproperty) && f->iconified - && f->output_data.x->net_wm_state_hidden_seen) + if (x_handle_net_wm_state (f, &event.xproperty) + && FRAME_ICONIFIED_P (f) + && f->output_data.x->net_wm_state_hidden_seen) { - /* Gnome shell does not iconify us when C-z is pressed. It hides - the frame. So if our state says we aren't hidden anymore, - treat it as deiconified. */ - if (! f->async_iconified) - SET_FRAME_GARBAGED (f); - f->async_visible = 1; - f->async_iconified = 0; + /* Gnome shell does not iconify us when C-z is pressed. + It hides the frame. So if our state says we aren't + hidden anymore, treat it as deiconified. */ + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, 0); f->output_data.x->has_been_visible = 1; f->output_data.x->net_wm_state_hidden_seen = 0; inev.ie.kind = DEICONIFY_EVENT; @@ -6152,10 +6151,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, event.xexpose.width, event.xexpose.height, FALSE); #endif - if (f->async_visible == 0) + if (!FRAME_VISIBLE_P (f)) { - f->async_visible = 1; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, 0); f->output_data.x->has_been_visible = 1; SET_FRAME_GARBAGED (f); } @@ -6232,20 +6231,20 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, if (f) /* F may no longer exist if the frame was deleted. */ { + bool visible = FRAME_VISIBLE_P (f); /* While a frame is unmapped, display generation is disabled; you don't want to spend time updating a display that won't ever be seen. */ - f->async_visible = 0; + SET_FRAME_VISIBLE (f, 0); /* We can't distinguish, from the event, whether the window has become iconified or invisible. So assume, if it was previously visible, than now it is iconified. But x_make_frame_invisible clears both the visible flag and the iconified flag; and that way, we know the window is not iconified now. */ - if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) + if (visible || FRAME_ICONIFIED_P (f)) { - f->async_iconified = 1; - + SET_FRAME_ICONIFIED (f, 1); inev.ie.kind = ICONIFY_EVENT; XSETFRAME (inev.ie.frame_or_window, f); } @@ -6264,13 +6263,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, f = x_top_window_to_frame (dpyinfo, event.xmap.window); if (f) { + bool iconified = FRAME_ICONIFIED_P (f); /* wait_reading_process_output will notice this and update the frame's display structures. If we where iconified, we should not set garbaged, because that stops redrawing on Expose events. This looks bad if we are called from a recursive event loop (x_dispatch_event), for example when a dialog is up. */ - if (! f->async_iconified) + if (!iconified) SET_FRAME_GARBAGED (f); /* Check if fullscreen was specified before we where mapped the @@ -6278,20 +6278,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr, if (!f->output_data.x->has_been_visible) x_check_fullscreen (f); - f->async_visible = 1; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 1); + SET_FRAME_ICONIFIED (f, 0); f->output_data.x->has_been_visible = 1; - if (f->iconified) + if (iconified) { inev.ie.kind = DEICONIFY_EVENT; XSETFRAME (inev.ie.frame_or_window, f); } - else if (! NILP (Vframe_list) - && ! NILP (XCDR (Vframe_list))) - /* Force a redisplay sooner or later - to update the frame titles - in case this is the second frame. */ + else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list))) + /* Force a redisplay sooner or later to update the + frame titles in case this is the second frame. */ record_asynch_buffer_change (); #ifdef USE_GTK @@ -8417,7 +8415,7 @@ get_current_wm_state (struct frame *f, if (tmp_data) XFree (tmp_data); x_uncatch_errors (); unblock_input (); - return ! f->iconified; + return !FRAME_ICONIFIED_P (f); } x_uncatch_errors (); @@ -8529,7 +8527,7 @@ do_ewmh_fullscreen (struct frame *f) static void XTfullscreen_hook (FRAME_PTR f) { - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) { block_input (); x_check_fullscreen (f); @@ -8793,7 +8791,7 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows) /* But the ConfigureNotify may in fact never arrive, and then this is not right if the frame is visible. Instead wait (with timeout) for the ConfigureNotify. */ - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) x_wait_for_event (f, ConfigureNotify); else { @@ -8905,9 +8903,8 @@ void x_raise_frame (struct frame *f) { block_input (); - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); - XFlush (FRAME_X_DISPLAY (f)); unblock_input (); } @@ -8917,7 +8914,7 @@ x_raise_frame (struct frame *f) static void x_lower_frame (struct frame *f) { - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) { block_input (); XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); @@ -8933,7 +8930,7 @@ xembed_request_focus (FRAME_PTR f) { /* See XEmbed Protocol Specification at http://freedesktop.org/wiki/Specifications/xembed-spec */ - if (f->async_visible) + if (FRAME_VISIBLE_P (f)) xembed_send_message (f, CurrentTime, XEMBED_REQUEST_FOCUS, 0, 0, 0); } @@ -8947,7 +8944,8 @@ x_ewmh_activate_frame (FRAME_PTR f) http://freedesktop.org/wiki/Specifications/wm-spec */ struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); - if (f->async_visible && wm_supports (f, dpyinfo->Xatom_net_active_window)) + + if (FRAME_VISIBLE_P (f) && wm_supports (f, dpyinfo->Xatom_net_active_window)) { Lisp_Object frame; XSETFRAME (frame, f); @@ -9159,9 +9157,6 @@ x_make_frame_visible (struct frame *f) poll_for_input_1 (); poll_suppress_count = old_poll_suppress_count; } - - /* See if a MapNotify event has been processed. */ - FRAME_SAMPLE_VISIBILITY (f); } /* 2000-09-28: In @@ -9229,10 +9224,8 @@ x_make_frame_invisible (struct frame *f) So we can't win using the usual strategy of letting FRAME_SAMPLE_VISIBILITY set this. So do it by hand, and synchronize with the server to make sure we agree. */ - f->visible = 0; - FRAME_ICONIFIED_P (f) = 0; - f->async_visible = 0; - f->async_iconified = 0; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 0); x_sync (f); @@ -9253,13 +9246,11 @@ x_iconify_frame (struct frame *f) if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; - if (f->async_iconified) + if (FRAME_ICONIFIED_P (f)) return; block_input (); - FRAME_SAMPLE_VISIBILITY (f); - type = x_icon_type (f); if (!NILP (type)) x_bitmap_icon (f, type); @@ -9271,10 +9262,8 @@ x_iconify_frame (struct frame *f) gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); - f->iconified = 1; - f->visible = 1; - f->async_iconified = 1; - f->async_visible = 0; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 1); unblock_input (); return; } @@ -9291,10 +9280,8 @@ x_iconify_frame (struct frame *f) /* The server won't give us any event to indicate that an invisible frame was changed to an icon, so we have to record it here. */ - f->iconified = 1; - f->visible = 1; - f->async_iconified = 1; - f->async_visible = 0; + SET_FRAME_VISIBLE (f, 0); + SET_FRAME_ICONIFIED (f, 1); unblock_input (); return; } @@ -9307,9 +9294,8 @@ x_iconify_frame (struct frame *f) if (!result) error ("Can't notify window manager of iconification"); - f->async_iconified = 1; - f->async_visible = 0; - + SET_FRAME_ICONIFIED (f, 1); + SET_FRAME_VISIBLE (f, 0); block_input (); XFlush (FRAME_X_DISPLAY (f)); @@ -9358,8 +9344,8 @@ x_iconify_frame (struct frame *f) XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); } - f->async_iconified = 1; - f->async_visible = 0; + SET_FRAME_ICONIFIED (f, 1); + SET_FRAME_VISIBLE (f, 0); XFlush (FRAME_X_DISPLAY (f)); unblock_input ();