aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog21
-rw-r--r--src/frame.c30
-rw-r--r--src/frame.h94
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/nsterm.m30
-rw-r--r--src/term.c4
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32term.c138
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c11
-rw-r--r--src/xterm.c98
11 files changed, 192 insertions, 240 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0ee2dbfd53f..e89196a15c5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,26 @@
12013-01-24 Dmitry Antipov <dmantipov@yandex.ru> 12013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
2 2
3 Drop async_visible and async_iconified fields of struct frame.
4 This is possible because async input is gone; for details, see
5 http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00734.html.
6 * frame.h (struct frame): Remove async_visible and async_iconified
7 members, convert garbaged to unsigned bitfield. Adjust comments.
8 (FRAME_SAMPLE_VISIBILITY): Remove. Adjust all users.
9 (SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED): New macros.
10 * frame.c, gtkutil.c, term.c, w32fns.c, window.c, xdisp.c:
11 Consistently use SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED,
12 FRAME_VISIBLE_P and FRAME_ICONIFIED_P macros where appropriate.
13 * w32term.c: Ditto.
14 (w32_read_socket): Save iconified state to generate DEICONIFY_EVENT
15 properly. Likewise for obscured.
16 * xterm.c: Ditto.
17 (handle_one_xevent): Save visible state go generate ICONIFY_EVENT
18 properly.
19 * nsterm.m: Ditto.
20 (windowDidDeminiaturize): Generate DEICONIFY_EVENT.
21
222013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
23
3 * insdel.c (prepare_to_modify_buffer): Revert last change as suggested 24 * insdel.c (prepare_to_modify_buffer): Revert last change as suggested
4 in http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00555.html. 25 in http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00555.html.
5 26
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)
500 tty_frame_count = 1; 500 tty_frame_count = 1;
501 fset_name (f, build_pure_c_string ("F1")); 501 fset_name (f, build_pure_c_string ("F1"));
502 502
503 f->visible = 1; 503 SET_FRAME_VISIBLE (f, 1);
504 f->async_visible = 1;
505 504
506 f->output_method = terminal->type; 505 f->output_method = terminal->type;
507 f->terminal = terminal; 506 f->terminal = terminal;
@@ -540,8 +539,8 @@ make_terminal_frame (struct terminal *terminal)
540 539
541 fset_name (f, make_formatted_string (name, "F%"pMd, ++tty_frame_count)); 540 fset_name (f, make_formatted_string (name, "F%"pMd, ++tty_frame_count));
542 541
543 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ 542 SET_FRAME_VISIBLE (f, 1);
544 f->async_visible = 1; /* Don't let visible be cleared later. */ 543
545 f->terminal = terminal; 544 f->terminal = terminal;
546 f->terminal->reference_count++; 545 f->terminal->reference_count++;
547#ifdef MSDOS 546#ifdef MSDOS
@@ -565,7 +564,7 @@ make_terminal_frame (struct terminal *terminal)
565 /* Set the top frame to the newly created frame. */ 564 /* Set the top frame to the newly created frame. */
566 if (FRAMEP (FRAME_TTY (f)->top_frame) 565 if (FRAMEP (FRAME_TTY (f)->top_frame)
567 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame))) 566 && FRAME_LIVE_P (XFRAME (FRAME_TTY (f)->top_frame)))
568 XFRAME (FRAME_TTY (f)->top_frame)->async_visible = 2; /* obscured */ 567 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (f)->top_frame), 2); /* obscured */
569 568
570 FRAME_TTY (f)->top_frame = frame; 569 FRAME_TTY (f)->top_frame = frame;
571 570
@@ -806,8 +805,8 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
806 { 805 {
807 if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame)) 806 if (FRAMEP (FRAME_TTY (XFRAME (frame))->top_frame))
808 /* Mark previously displayed frame as now obscured. */ 807 /* Mark previously displayed frame as now obscured. */
809 XFRAME (FRAME_TTY (XFRAME (frame))->top_frame)->async_visible = 2; 808 SET_FRAME_VISIBLE (XFRAME (FRAME_TTY (XFRAME (frame))->top_frame), 2);
810 XFRAME (frame)->async_visible = 1; 809 SET_FRAME_VISIBLE (XFRAME (frame), 1);
811 FRAME_TTY (XFRAME (frame))->top_frame = frame; 810 FRAME_TTY (XFRAME (frame))->top_frame = frame;
812 } 811 }
813 812
@@ -914,7 +913,6 @@ candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf)
914 } 913 }
915 else if (EQ (minibuf, Qvisible)) 914 else if (EQ (minibuf, Qvisible))
916 { 915 {
917 FRAME_SAMPLE_VISIBILITY (c);
918 if (FRAME_VISIBLE_P (c)) 916 if (FRAME_VISIBLE_P (c))
919 return candidate; 917 return candidate;
920 } 918 }
@@ -928,7 +926,6 @@ candidate_frame (Lisp_Object candidate, Lisp_Object frame, Lisp_Object minibuf)
928 } 926 }
929 else if (XFASTINT (minibuf) == 0) 927 else if (XFASTINT (minibuf) == 0)
930 { 928 {
931 FRAME_SAMPLE_VISIBILITY (c);
932 if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c)) 929 if (FRAME_VISIBLE_P (c) || FRAME_ICONIFIED_P (c))
933 return candidate; 930 return candidate;
934 } 931 }
@@ -1052,10 +1049,7 @@ other_visible_frames (FRAME_PTR f)
1052 and note any recent change in visibility. */ 1049 and note any recent change in visibility. */
1053#ifdef HAVE_WINDOW_SYSTEM 1050#ifdef HAVE_WINDOW_SYSTEM
1054 if (FRAME_WINDOW_P (XFRAME (this))) 1051 if (FRAME_WINDOW_P (XFRAME (this)))
1055 { 1052 x_sync (XFRAME (this));
1056 x_sync (XFRAME (this));
1057 FRAME_SAMPLE_VISIBILITY (XFRAME (this));
1058 }
1059#endif 1053#endif
1060 1054
1061 if (FRAME_VISIBLE_P (XFRAME (this)) 1055 if (FRAME_VISIBLE_P (XFRAME (this))
@@ -1231,7 +1225,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1231 fset_root_window (f, Qnil); 1225 fset_root_window (f, Qnil);
1232 1226
1233 Vframe_list = Fdelq (frame, Vframe_list); 1227 Vframe_list = Fdelq (frame, Vframe_list);
1234 FRAME_SET_VISIBLE (f, 0); 1228 SET_FRAME_VISIBLE (f, 0);
1235 1229
1236 /* Allow the vector of menu bar contents to be freed in the next 1230 /* Allow the vector of menu bar contents to be freed in the next
1237 garbage collection. The frame object itself may not be garbage 1231 garbage collection. The frame object itself may not be garbage
@@ -1579,10 +1573,7 @@ If omitted, FRAME defaults to the currently selected frame. */)
1579 /* I think this should be done with a hook. */ 1573 /* I think this should be done with a hook. */
1580#ifdef HAVE_WINDOW_SYSTEM 1574#ifdef HAVE_WINDOW_SYSTEM
1581 if (FRAME_WINDOW_P (f)) 1575 if (FRAME_WINDOW_P (f))
1582 { 1576 x_make_frame_visible (f);
1583 FRAME_SAMPLE_VISIBILITY (f);
1584 x_make_frame_visible (f);
1585 }
1586#endif 1577#endif
1587 1578
1588 make_frame_visible_1 (f->root_window); 1579 make_frame_visible_1 (f->root_window);
@@ -1705,8 +1696,6 @@ currently being displayed on the terminal. */)
1705{ 1696{
1706 CHECK_LIVE_FRAME (frame); 1697 CHECK_LIVE_FRAME (frame);
1707 1698
1708 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
1709
1710 if (FRAME_VISIBLE_P (XFRAME (frame))) 1699 if (FRAME_VISIBLE_P (XFRAME (frame)))
1711 return Qt; 1700 return Qt;
1712 if (FRAME_ICONIFIED_P (XFRAME (frame))) 1701 if (FRAME_ICONIFIED_P (XFRAME (frame)))
@@ -2891,7 +2880,6 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
2891 make_formatted_string (buf, "%"pMu, w)); 2880 make_formatted_string (buf, "%"pMu, w));
2892#endif 2881#endif
2893 store_in_alist (alistptr, Qicon_name, f->icon_name); 2882 store_in_alist (alistptr, Qicon_name, f->icon_name);
2894 FRAME_SAMPLE_VISIBILITY (f);
2895 store_in_alist (alistptr, Qvisibility, 2883 store_in_alist (alistptr, Qvisibility,
2896 (FRAME_VISIBLE_P (f) ? Qt 2884 (FRAME_VISIBLE_P (f) ? Qt
2897 : FRAME_ICONIFIED_P (f) ? Qicon : Qnil)); 2885 : 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
353 unsigned int external_menu_bar : 1; 353 unsigned int external_menu_bar : 1;
354#endif 354#endif
355 355
356 /* visible is nonzero if the frame is currently displayed; we check 356 /* Next two bitfields are mutually exclusive. They might both be
357 zero if the frame has been made invisible without an icon. */
358
359 /* Nonzero if the frame is currently displayed; we check
357 it to see if we should bother updating the frame's contents. 360 it to see if we should bother updating the frame's contents.
358 DON'T SET IT DIRECTLY; instead, use FRAME_SET_VISIBLE.
359 361
360 Note that, since invisible frames aren't updated, whenever a 362 Note that, since invisible frames aren't updated, whenever a
361 frame becomes visible again, it must be marked as garbaged. The 363 frame becomes visible again, it must be marked as garbaged.
362 FRAME_SAMPLE_VISIBILITY macro takes care of this.
363 364
364 On ttys and on Windows NT/9X, to avoid wasting effort updating 365 On ttys and on Windows NT/9X, to avoid wasting effort updating
365 visible frames that are actually completely obscured by other 366 visible frames that are actually completely obscured by other
366 windows on the display, we bend the meaning of visible slightly: 367 windows on the display, we bend the meaning of visible slightly:
367 if greater than 1, then the frame is obscured - we still consider 368 if equal to 2, then the frame is obscured - we still consider
368 it to be "visible" as seen from lisp, but we don't bother 369 it to be "visible" as seen from lisp, but we don't bother
369 updating it. We must take care to garbage the frame when it 370 updating it. We must take care to garbage the frame when it
370 ceases to be obscured though. 371 ceases to be obscured though. See SET_FRAME_VISIBLE below. */
371
372 iconified is nonzero if the frame is currently iconified.
373
374 Asynchronous input handlers should NOT change these directly;
375 instead, they should change async_visible or async_iconified, and
376 let the FRAME_SAMPLE_VISIBILITY macro set visible and iconified
377 at the next redisplay.
378
379 These should probably be considered read-only by everyone except
380 FRAME_SAMPLE_VISIBILITY.
381
382 These two are mutually exclusive. They might both be zero, if the
383 frame has been made invisible without an icon. */
384 unsigned visible : 2; 372 unsigned visible : 2;
385 unsigned iconified : 1;
386
387 /* Let's not use bitfields for volatile variables. */
388 373
389 /* Asynchronous input handlers change these, and 374 /* Nonzero if the frame is currently iconified. Do not
390 FRAME_SAMPLE_VISIBILITY copies them into visible and iconified. 375 set this directly, use SET_FRAME_ICONIFIED instead. */
391 See FRAME_SAMPLE_VISIBILITY, below. */ 376 unsigned iconified : 1;
392 volatile char async_visible, async_iconified;
393 377
394 /* Nonzero if this frame should be redrawn. */ 378 /* Nonzero if this frame should be redrawn. */
395 volatile char garbaged; 379 unsigned garbaged : 1;
396 380
397 /* True if frame actually has a minibuffer window on it. 381 /* True if frame actually has a minibuffer window on it.
398 0 if using a minibuffer window that isn't on this frame. */ 382 0 if using a minibuffer window that isn't on this frame. */
@@ -711,7 +695,7 @@ typedef struct frame *FRAME_PTR;
711#else 695#else
712#define FRAME_EXTERNAL_MENU_BAR(f) 0 696#define FRAME_EXTERNAL_MENU_BAR(f) 0
713#endif 697#endif
714#define FRAME_VISIBLE_P(f) ((f)->visible != 0) 698#define FRAME_VISIBLE_P(f) (f)->visible
715 699
716/* Nonzero if frame F is currently visible but hidden. */ 700/* Nonzero if frame F is currently visible but hidden. */
717#define FRAME_OBSCURED_P(f) ((f)->visible > 1) 701#define FRAME_OBSCURED_P(f) ((f)->visible > 1)
@@ -719,9 +703,10 @@ typedef struct frame *FRAME_PTR;
719/* Nonzero if frame F is currently iconified. */ 703/* Nonzero if frame F is currently iconified. */
720#define FRAME_ICONIFIED_P(f) (f)->iconified 704#define FRAME_ICONIFIED_P(f) (f)->iconified
721 705
722#define FRAME_SET_VISIBLE(f,p) \ 706/* Mark frame F as currently garbaged. */
723 ((f)->async_visible = (p), FRAME_SAMPLE_VISIBILITY (f))
724#define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1) 707#define SET_FRAME_GARBAGED(f) (frame_garbaged = 1, f->garbaged = 1)
708
709/* Nonzero if frame F is currently garbaged. */
725#define FRAME_GARBAGED_P(f) (f)->garbaged 710#define FRAME_GARBAGED_P(f) (f)->garbaged
726 711
727/* Nonzero means do not allow splitting this frame's window. */ 712/* Nonzero means do not allow splitting this frame's window. */
@@ -866,39 +851,6 @@ typedef struct frame *FRAME_PTR;
866 851
867#define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4) 852#define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4)
868 853
869/* Emacs's redisplay code could become confused if a frame's
870 visibility changes at arbitrary times. For example, if a frame is
871 visible while the desired glyphs are being built, but becomes
872 invisible before they are updated, then some rows of the
873 desired_glyphs will be left marked as enabled after redisplay is
874 complete, which should never happen. The next time the frame
875 becomes visible, redisplay will probably barf.
876
877 Currently, there are no similar situations involving iconified, but
878 the principle is the same.
879
880 So instead of having asynchronous input handlers directly set and
881 clear the frame's visibility and iconification flags, they just set
882 the async_visible and async_iconified flags; the redisplay code
883 calls the FRAME_SAMPLE_VISIBILITY macro before doing any redisplay,
884 which sets visible and iconified from their asynchronous
885 counterparts.
886
887 Synchronous code must use the FRAME_SET_VISIBLE macro.
888
889 Also, if a frame used to be invisible, but has just become visible,
890 it must be marked as garbaged, since redisplay hasn't been keeping
891 up its contents.
892
893 Note that a tty frame is visible if and only if it is the topmost
894 frame. */
895
896#define FRAME_SAMPLE_VISIBILITY(f) \
897 (((f)->async_visible && (f)->visible != (f)->async_visible) ? \
898 SET_FRAME_GARBAGED (f) : 0, \
899 (f)->visible = (f)->async_visible, \
900 (f)->iconified = (f)->async_iconified)
901
902#define CHECK_FRAME(x) \ 854#define CHECK_FRAME(x) \
903 CHECK_TYPE (FRAMEP (x), Qframep, x) 855 CHECK_TYPE (FRAMEP (x), Qframep, x)
904 856
@@ -932,12 +884,24 @@ typedef struct frame *FRAME_PTR;
932 block_input (); \ 884 block_input (); \
933 if (hlinfo->mouse_face_mouse_frame) \ 885 if (hlinfo->mouse_face_mouse_frame) \
934 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \ 886 note_mouse_highlight (hlinfo->mouse_face_mouse_frame, \
935 hlinfo->mouse_face_mouse_x, \ 887 hlinfo->mouse_face_mouse_x, \
936 hlinfo->mouse_face_mouse_y); \ 888 hlinfo->mouse_face_mouse_y); \
937 unblock_input (); \ 889 unblock_input (); \
938 } \ 890 } \
939 } while (0) 891 } while (0)
940 892
893/* Set visibility of frame F, marking F as garbaged if needed. */
894
895#define SET_FRAME_VISIBLE(f, v) \
896 (((f)->visible == 0 || ((f)->visible == 2)) \
897 && ((v) == 1) ? SET_FRAME_GARBAGED (f) : 0, \
898 (f)->visible = (eassert (0 <= (v) && (v) <= 2), (v)))
899
900/* Set iconify of frame F. */
901
902#define SET_FRAME_ICONIFIED(f, i) \
903 (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
904
941extern Lisp_Object Qframep, Qframe_live_p; 905extern Lisp_Object Qframep, Qframe_live_p;
942extern Lisp_Object Qtty, Qtty_type; 906extern Lisp_Object Qtty, Qtty_type;
943extern Lisp_Object Qtty_color_mode; 907extern 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)
983 size as fast as possible. 983 size as fast as possible.
984 For unmapped windows, we can set rows/cols. When 984 For unmapped windows, we can set rows/cols. When
985 the frame is mapped again we will (hopefully) get the correct size. */ 985 the frame is mapped again we will (hopefully) get the correct size. */
986 if (f->async_visible) 986 if (FRAME_VISIBLE_P (f))
987 { 987 {
988 /* Must call this to flush out events */ 988 /* Must call this to flush out events */
989 (void)gtk_events_pending (); 989 (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)
1000 NSView *view = FRAME_NS_VIEW (f); 1000 NSView *view = FRAME_NS_VIEW (f);
1001 check_ns (); 1001 check_ns ();
1002 block_input (); 1002 block_input ();
1003 FRAME_SAMPLE_VISIBILITY (f);
1004 if (FRAME_VISIBLE_P (f)) 1003 if (FRAME_VISIBLE_P (f))
1005 { 1004 [[view window] makeKeyAndOrderFront: NSApp];
1006 [[view window] makeKeyAndOrderFront: NSApp];
1007 }
1008 unblock_input (); 1005 unblock_input ();
1009} 1006}
1010 1007
@@ -1093,7 +1090,8 @@ x_make_frame_visible (struct frame *f)
1093 if (!FRAME_VISIBLE_P (f)) 1090 if (!FRAME_VISIBLE_P (f))
1094 { 1091 {
1095 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); 1092 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1096 f->async_visible = 1; 1093
1094 SET_FRAME_VISIBLE (f, 1);
1097 ns_raise_frame (f); 1095 ns_raise_frame (f);
1098 1096
1099#ifdef NEW_STYLE_FS 1097#ifdef NEW_STYLE_FS
@@ -1123,8 +1121,8 @@ x_make_frame_invisible (struct frame *f)
1123 NSTRACE (x_make_frame_invisible); 1121 NSTRACE (x_make_frame_invisible);
1124 check_ns (); 1122 check_ns ();
1125 [[view window] orderOut: NSApp]; 1123 [[view window] orderOut: NSApp];
1126 f->async_visible = 0; 1124 SET_FRAME_VISIBLE (f, 0);
1127 f->async_iconified = 0; 1125 SET_FRAME_ICONIFIED (f, 0);
1128} 1126}
1129 1127
1130 1128
@@ -1354,7 +1352,9 @@ ns_fullscreen_hook (FRAME_PTR f)
1354{ 1352{
1355 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); 1353 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1356 1354
1357 if (! f->async_visible) return; 1355 if (!FRAME_VISIBLE_P (f))
1356 return;
1357
1358#ifndef NEW_STYLE_FS 1358#ifndef NEW_STYLE_FS
1359 if (f->want_fullscreen == FULLSCREEN_BOTH) 1359 if (f->want_fullscreen == FULLSCREEN_BOTH)
1360 { 1360 {
@@ -5824,13 +5824,14 @@ not_in_argv (NSString *arg)
5824 NSTRACE (windowDidDeminiaturize); 5824 NSTRACE (windowDidDeminiaturize);
5825 if (!emacsframe->output_data.ns) 5825 if (!emacsframe->output_data.ns)
5826 return; 5826 return;
5827 emacsframe->async_iconified = 0; 5827
5828 emacsframe->async_visible = 1; 5828 SET_FRAME_ICONIFIED (emacsframe, 0);
5829 SET_FRAME_VISIBLE (emacsframe, 1);
5829 windows_or_buffers_changed++; 5830 windows_or_buffers_changed++;
5830 5831
5831 if (emacs_event) 5832 if (emacs_event)
5832 { 5833 {
5833 emacs_event->kind = ICONIFY_EVENT; 5834 emacs_event->kind = DEICONIFY_EVENT;
5834 EV_TRAILER ((id)nil); 5835 EV_TRAILER ((id)nil);
5835 } 5836 }
5836} 5837}
@@ -5841,7 +5842,8 @@ not_in_argv (NSString *arg)
5841 NSTRACE (windowDidExpose); 5842 NSTRACE (windowDidExpose);
5842 if (!emacsframe->output_data.ns) 5843 if (!emacsframe->output_data.ns)
5843 return; 5844 return;
5844 emacsframe->async_visible = 1; 5845
5846 SET_FRAME_VISIBLE (emacsframe, 1);
5845 SET_FRAME_GARBAGED (emacsframe); 5847 SET_FRAME_GARBAGED (emacsframe);
5846 5848
5847 if (send_appdefined) 5849 if (send_appdefined)
@@ -5855,8 +5857,8 @@ not_in_argv (NSString *arg)
5855 if (!emacsframe->output_data.ns) 5857 if (!emacsframe->output_data.ns)
5856 return; 5858 return;
5857 5859
5858 emacsframe->async_iconified = 1; 5860 SET_FRAME_ICONIFIED (emacsframe, 1);
5859 emacsframe->async_visible = 0; 5861 SET_FRAME_VISIBLE (emacsframe, 0);
5860 5862
5861 if (emacs_event) 5863 if (emacs_event)
5862 { 5864 {
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. */)
2374 t->display_info.tty->output = 0; 2374 t->display_info.tty->output = 0;
2375 2375
2376 if (FRAMEP (t->display_info.tty->top_frame)) 2376 if (FRAMEP (t->display_info.tty->top_frame))
2377 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0); 2377 SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
2378 2378
2379 } 2379 }
2380 2380
@@ -2444,7 +2444,7 @@ frame's terminal). */)
2444 get_tty_size (fileno (t->display_info.tty->input), &width, &height); 2444 get_tty_size (fileno (t->display_info.tty->input), &width, &height);
2445 if (width != old_width || height != old_height) 2445 if (width != old_width || height != old_height)
2446 change_frame_size (f, height, width, 0, 0, 0); 2446 change_frame_size (f, height, width, 0, 0, 0);
2447 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); 2447 SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
2448 } 2448 }
2449 2449
2450 set_tty_hooks (t); 2450 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. */)
5943 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 5943 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
5944 5944
5945 /* Let redisplay know that we have made the frame visible already. */ 5945 /* Let redisplay know that we have made the frame visible already. */
5946 f->async_visible = 1; 5946 SET_FRAME_VISIBLE (f, 1);
5947 5947
5948 ShowWindow (FRAME_W32_WINDOW (f), SW_SHOWNOACTIVATE); 5948 ShowWindow (FRAME_W32_WINDOW (f), SW_SHOWNOACTIVATE);
5949 } 5949 }
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,
4319 DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f, 4319 DebPrint (("clipped frame %p (%s) got WM_PAINT - ignored\n", f,
4320 SDATA (f->name))); 4320 SDATA (f->name)));
4321 } 4321 }
4322 else if (f->async_visible != 1) 4322 else if (FRAME_VISIBLE_P (f) != 1)
4323 { 4323 {
4324 bool iconified = FRAME_ICONIFIED_P (f);
4325
4324 /* Definitely not obscured, so mark as visible. */ 4326 /* Definitely not obscured, so mark as visible. */
4325 f->async_visible = 1; 4327 SET_FRAME_VISIBLE (f, 1);
4326 f->async_iconified = 0; 4328 SET_FRAME_ICONIFIED (f, 0);
4327 SET_FRAME_GARBAGED (f); 4329 SET_FRAME_GARBAGED (f);
4328 DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f, 4330 DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f,
4329 SDATA (f->name))); 4331 SDATA (f->name)));
4330 4332
4331 /* WM_PAINT serves as MapNotify as well, so report 4333 /* WM_PAINT serves as MapNotify as well, so report
4332 visibility changes properly. */ 4334 visibility changes properly. */
4333 if (f->iconified) 4335 if (iconified)
4334 { 4336 {
4335 inev.kind = DEICONIFY_EVENT; 4337 inev.kind = DEICONIFY_EVENT;
4336 XSETFRAME (inev.frame_or_window, f); 4338 XSETFRAME (inev.frame_or_window, f);
4337 } 4339 }
4338 else if (! NILP (Vframe_list) 4340 else if (!NILP (Vframe_list) && !NILP (XCDR (Vframe_list)))
4339 && ! NILP (XCDR (Vframe_list)))
4340 /* Force a redisplay sooner or later to update the 4341 /* Force a redisplay sooner or later to update the
4341 frame titles in case this is the second frame. */ 4342 frame titles in case this is the second frame. */
4342 record_asynch_buffer_change (); 4343 record_asynch_buffer_change ();
@@ -4379,7 +4380,7 @@ w32_read_socket (struct terminal *terminal,
4379 case WM_SYSKEYDOWN: 4380 case WM_SYSKEYDOWN:
4380 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4381 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4381 4382
4382 if (f && !f->iconified) 4383 if (f && !FRAME_ICONIFIED_P (f))
4383 { 4384 {
4384 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4385 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4385 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) 4386 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
@@ -4404,7 +4405,7 @@ w32_read_socket (struct terminal *terminal,
4404 case WM_CHAR: 4405 case WM_CHAR:
4405 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4406 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4406 4407
4407 if (f && !f->iconified) 4408 if (f && !FRAME_ICONIFIED_P (f))
4408 { 4409 {
4409 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4410 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4410 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) 4411 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
@@ -4482,7 +4483,7 @@ w32_read_socket (struct terminal *terminal,
4482 case WM_APPCOMMAND: 4483 case WM_APPCOMMAND:
4483 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4484 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4484 4485
4485 if (f && !f->iconified) 4486 if (f && !FRAME_ICONIFIED_P (f))
4486 { 4487 {
4487 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4488 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4488 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window)) 4489 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
@@ -4722,7 +4723,7 @@ w32_read_socket (struct terminal *terminal,
4722 case WM_MOVE: 4723 case WM_MOVE:
4723 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4724 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4724 4725
4725 if (f && !f->async_iconified) 4726 if (f && !FRAME_ICONIFIED_P (f))
4726 { 4727 {
4727 int x, y; 4728 int x, y;
4728 4729
@@ -4770,8 +4771,8 @@ w32_read_socket (struct terminal *terminal,
4770 switch (msg.msg.wParam) 4771 switch (msg.msg.wParam)
4771 { 4772 {
4772 case SIZE_MINIMIZED: 4773 case SIZE_MINIMIZED:
4773 f->async_visible = 0; 4774 SET_FRAME_VISIBLE (f, 0);
4774 f->async_iconified = 1; 4775 SET_FRAME_ICONIFIED (f, 1);
4775 4776
4776 inev.kind = ICONIFY_EVENT; 4777 inev.kind = ICONIFY_EVENT;
4777 XSETFRAME (inev.frame_or_window, f); 4778 XSETFRAME (inev.frame_or_window, f);
@@ -4779,40 +4780,44 @@ w32_read_socket (struct terminal *terminal,
4779 4780
4780 case SIZE_MAXIMIZED: 4781 case SIZE_MAXIMIZED:
4781 case SIZE_RESTORED: 4782 case SIZE_RESTORED:
4782 f->async_visible = 1; 4783 {
4783 f->async_iconified = 0; 4784 bool iconified = FRAME_ICONIFIED_P (f);
4784 4785
4785 /* wait_reading_process_output will notice this and update 4786 SET_FRAME_VISIBLE (f, 1);
4786 the frame's display structures. */ 4787 SET_FRAME_ICONIFIED (f, 0);
4787 SET_FRAME_GARBAGED (f);
4788 4788
4789 if (f->iconified) 4789 /* wait_reading_process_output will notice this
4790 { 4790 and update the frame's display structures. */
4791 int x, y; 4791 SET_FRAME_GARBAGED (f);
4792
4793 /* Reset top and left positions of the Window
4794 here since Windows sends a WM_MOVE message
4795 BEFORE telling us the Window is minimized
4796 when the Window is iconified, with 3000,3000
4797 as the co-ords. */
4798 x_real_positions (f, &x, &y);
4799 f->left_pos = x;
4800 f->top_pos = y;
4801 4792
4802 inev.kind = DEICONIFY_EVENT; 4793 if (iconified)
4803 XSETFRAME (inev.frame_or_window, f); 4794 {
4804 } 4795 int x, y;
4805 else if (! NILP (Vframe_list) 4796
4806 && ! NILP (XCDR (Vframe_list))) 4797 /* Reset top and left positions of the Window
4807 /* Force a redisplay sooner or later 4798 here since Windows sends a WM_MOVE message
4808 to update the frame titles 4799 BEFORE telling us the Window is minimized
4809 in case this is the second frame. */ 4800 when the Window is iconified, with 3000,3000
4810 record_asynch_buffer_change (); 4801 as the co-ords. */
4802 x_real_positions (f, &x, &y);
4803 f->left_pos = x;
4804 f->top_pos = y;
4805
4806 inev.kind = DEICONIFY_EVENT;
4807 XSETFRAME (inev.frame_or_window, f);
4808 }
4809 else if (! NILP (Vframe_list)
4810 && ! NILP (XCDR (Vframe_list)))
4811 /* Force a redisplay sooner or later
4812 to update the frame titles
4813 in case this is the second frame. */
4814 record_asynch_buffer_change ();
4815 }
4811 break; 4816 break;
4812 } 4817 }
4813 } 4818 }
4814 4819
4815 if (f && !f->async_iconified && msg.msg.wParam != SIZE_MINIMIZED) 4820 if (f && !FRAME_ICONIFIED_P (f) && msg.msg.wParam != SIZE_MINIMIZED)
4816 { 4821 {
4817 RECT rect; 4822 RECT rect;
4818 int rows; 4823 int rows;
@@ -5040,12 +5045,13 @@ w32_read_socket (struct terminal *terminal,
5040 continue; 5045 continue;
5041 5046
5042 /* Check "visible" frames and mark each as obscured or not. 5047 /* Check "visible" frames and mark each as obscured or not.
5043 Note that async_visible is nonzero for unobscured and 5048 Note that visible is nonzero for unobscured and obscured
5044 obscured frames, but zero for hidden and iconified frames. */ 5049 frames, but zero for hidden and iconified frames. */
5045 if (FRAME_W32_P (f) && f->async_visible) 5050 if (FRAME_W32_P (f) && FRAME_VISIBLE_P (f))
5046 { 5051 {
5047 RECT clipbox; 5052 RECT clipbox;
5048 HDC hdc; 5053 HDC hdc;
5054 bool obscured;
5049 5055
5050 enter_crit (); 5056 enter_crit ();
5051 /* Query clipping rectangle for the entire window area 5057 /* Query clipping rectangle for the entire window area
@@ -5059,31 +5065,28 @@ w32_read_socket (struct terminal *terminal,
5059 ReleaseDC (FRAME_W32_WINDOW (f), hdc); 5065 ReleaseDC (FRAME_W32_WINDOW (f), hdc);
5060 leave_crit (); 5066 leave_crit ();
5061 5067
5062 if (clipbox.right == clipbox.left 5068 obscured = FRAME_OBSCURED_P (f);
5063 || clipbox.bottom == clipbox.top) 5069
5070 if (clipbox.right == clipbox.left || clipbox.bottom == clipbox.top)
5064 { 5071 {
5065 /* Frame has become completely obscured so mark as 5072 /* Frame has become completely obscured so mark as such (we
5066 such (we do this by setting async_visible to 2 so 5073 do this by setting visible to 2 so that FRAME_VISIBLE_P
5067 that FRAME_VISIBLE_P is still true, but redisplay 5074 is still true, but redisplay will skip it). */
5068 will skip it). */ 5075 SET_FRAME_VISIBLE (f, 2);
5069 f->async_visible = 2;
5070 5076
5071 if (!FRAME_OBSCURED_P (f)) 5077 if (!obscured)
5072 { 5078 DebPrint (("frame %p (%s) obscured\n", f, SDATA (f->name)));
5073 DebPrint (("frame %p (%s) obscured\n", f,
5074 SDATA (f->name)));
5075 }
5076 } 5079 }
5077 else 5080 else
5078 { 5081 {
5079 /* Frame is not obscured, so mark it as such. */ 5082 /* Frame is not obscured, so mark it as such. */
5080 f->async_visible = 1; 5083 SET_FRAME_VISIBLE (f, 1);
5081 5084
5082 if (FRAME_OBSCURED_P (f)) 5085 if (obscured)
5083 { 5086 {
5084 SET_FRAME_GARBAGED (f); 5087 SET_FRAME_GARBAGED (f);
5085 DebPrint (("obscured frame %p (%s) found to be visible\n", f, 5088 DebPrint (("obscured frame %p (%s) found to be visible\n",
5086 SDATA (f->name))); 5089 f, SDATA (f->name)));
5087 5090
5088 /* Force a redisplay sooner or later. */ 5091 /* Force a redisplay sooner or later. */
5089 record_asynch_buffer_change (); 5092 record_asynch_buffer_change ();
@@ -5654,7 +5657,7 @@ w32fullscreen_hook (FRAME_PTR f)
5654{ 5657{
5655 static int normal_width, normal_height; 5658 static int normal_width, normal_height;
5656 5659
5657 if (f->async_visible) 5660 if (FRAME_VISIBLE_P (f))
5658 { 5661 {
5659 int width, height, top_pos, left_pos, pixel_height, pixel_width; 5662 int width, height, top_pos, left_pos, pixel_height, pixel_width;
5660 int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f); 5663 int cur_w = FRAME_COLS (f), cur_h = FRAME_LINES (f);
@@ -6023,11 +6026,11 @@ x_make_frame_visible (struct frame *f)
6023 causes unexpected behavior when unminimizing frames that were 6026 causes unexpected behavior when unminimizing frames that were
6024 previously maximized. But only SW_SHOWNORMAL works properly for 6027 previously maximized. But only SW_SHOWNORMAL works properly for
6025 frames that were truely hidden (using make-frame-invisible), so 6028 frames that were truely hidden (using make-frame-invisible), so
6026 we need it to avoid Bug#5482. It seems that async_iconified 6029 we need it to avoid Bug#5482. It seems that iconified is only
6027 is only set for minimized windows that are still visible, so 6030 set for minimized windows that are still visible, so use that to
6028 use that to determine the appropriate flag to pass ShowWindow. */ 6031 determine the appropriate flag to pass ShowWindow. */
6029 my_show_window (f, FRAME_W32_WINDOW (f), 6032 my_show_window (f, FRAME_W32_WINDOW (f),
6030 f->async_iconified ? SW_RESTORE : SW_SHOWNORMAL); 6033 FRAME_ICONIFIED_P (f) ? SW_RESTORE : SW_SHOWNORMAL);
6031 } 6034 }
6032 6035
6033 /* Synchronize to ensure Emacs knows the frame is visible 6036 /* Synchronize to ensure Emacs knows the frame is visible
@@ -6066,7 +6069,6 @@ x_make_frame_visible (struct frame *f)
6066 poll_suppress_count = old_poll_suppress_count; 6069 poll_suppress_count = old_poll_suppress_count;
6067 } 6070 }
6068 } 6071 }
6069 FRAME_SAMPLE_VISIBILITY (f);
6070 } 6072 }
6071} 6073}
6072 6074
@@ -6090,10 +6092,8 @@ x_make_frame_invisible (struct frame *f)
6090 So we can't win using the usual strategy of letting 6092 So we can't win using the usual strategy of letting
6091 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, 6093 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
6092 and synchronize with the server to make sure we agree. */ 6094 and synchronize with the server to make sure we agree. */
6093 f->visible = 0; 6095 SET_FRAME_VISIBLE (f, 0);
6094 FRAME_ICONIFIED_P (f) = 0; 6096 SET_FRAME_ICONIFIED (f, 0);
6095 f->async_visible = 0;
6096 f->async_iconified = 0;
6097 6097
6098 unblock_input (); 6098 unblock_input ();
6099} 6099}
@@ -6109,7 +6109,7 @@ x_iconify_frame (struct frame *f)
6109 if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f) 6109 if (FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame == f)
6110 FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0; 6110 FRAME_W32_DISPLAY_INFO (f)->x_highlight_frame = 0;
6111 6111
6112 if (f->async_iconified) 6112 if (FRAME_ICONIFIED_P (f))
6113 return; 6113 return;
6114 6114
6115 block_input (); 6115 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
2231 } 2231 }
2232 else if (EQ (all_frames, Qvisible)) 2232 else if (EQ (all_frames, Qvisible))
2233 { 2233 {
2234 FRAME_SAMPLE_VISIBILITY (f);
2235 candidate_p = FRAME_VISIBLE_P (f) 2234 candidate_p = FRAME_VISIBLE_P (f)
2236 && (FRAME_TERMINAL (XFRAME (w->frame)) 2235 && (FRAME_TERMINAL (XFRAME (w->frame))
2237 == FRAME_TERMINAL (XFRAME (selected_frame))); 2236 == FRAME_TERMINAL (XFRAME (selected_frame)));
@@ -2239,7 +2238,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2239 } 2238 }
2240 else if (INTEGERP (all_frames) && XINT (all_frames) == 0) 2239 else if (INTEGERP (all_frames) && XINT (all_frames) == 0)
2241 { 2240 {
2242 FRAME_SAMPLE_VISIBILITY (f);
2243 candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) 2241 candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)
2244#ifdef HAVE_X_WINDOWS 2242#ifdef HAVE_X_WINDOWS
2245 /* Yuck!! If we've just created the frame and the 2243 /* 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)
9644 /* Error messages get reported properly by cmd_error, so this must be just an 9644 /* Error messages get reported properly by cmd_error, so this must be just an
9645 informative message; if the frame hasn't really been initialized yet, just 9645 informative message; if the frame hasn't really been initialized yet, just
9646 toss it. */ 9646 toss it. */
9647 else if (INTERACTIVE 9647 else if (INTERACTIVE && sf->glyphs_initialized_p)
9648 && sf->glyphs_initialized_p)
9649 { 9648 {
9650 /* Get the frame containing the mini-buffer 9649 /* Get the frame containing the mini-buffer
9651 that the selected frame is using. */ 9650 that the selected frame is using. */
@@ -9653,9 +9652,7 @@ message3_nolog (Lisp_Object m)
9653 Lisp_Object frame = XWINDOW (mini_window)->frame; 9652 Lisp_Object frame = XWINDOW (mini_window)->frame;
9654 struct frame *f = XFRAME (frame); 9653 struct frame *f = XFRAME (frame);
9655 9654
9656 FRAME_SAMPLE_VISIBILITY (f); 9655 if (FRAME_VISIBLE_P (sf) && !FRAME_VISIBLE_P (f))
9657 if (FRAME_VISIBLE_P (sf)
9658 && !FRAME_VISIBLE_P (f))
9659 Fmake_frame_visible (frame); 9656 Fmake_frame_visible (frame);
9660 9657
9661 if (STRINGP (m) && SCHARS (m) > 0) 9658 if (STRINGP (m) && SCHARS (m) > 0)
@@ -12924,7 +12921,6 @@ redisplay_internal (void)
12924 { 12921 {
12925 struct frame *f = XFRAME (frame); 12922 struct frame *f = XFRAME (frame);
12926 12923
12927 FRAME_SAMPLE_VISIBILITY (f);
12928 if (FRAME_VISIBLE_P (f)) 12924 if (FRAME_VISIBLE_P (f))
12929 ++number_of_visible_frames; 12925 ++number_of_visible_frames;
12930 clear_desired_matrices (f); 12926 clear_desired_matrices (f);
@@ -13472,9 +13468,6 @@ redisplay_internal (void)
13472 13468
13473 if (XFRAME (frame)->visible) 13469 if (XFRAME (frame)->visible)
13474 this_is_visible = 1; 13470 this_is_visible = 1;
13475 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
13476 if (XFRAME (frame)->visible)
13477 this_is_visible = 1;
13478 13471
13479 if (this_is_visible) 13472 if (this_is_visible)
13480 new_count++; 13473 new_count++;
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,
6102 last_user_time = event.xproperty.time; 6102 last_user_time = event.xproperty.time;
6103 f = x_top_window_to_frame (dpyinfo, event.xproperty.window); 6103 f = x_top_window_to_frame (dpyinfo, event.xproperty.window);
6104 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state) 6104 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state)
6105 if (x_handle_net_wm_state (f, &event.xproperty) && f->iconified 6105 if (x_handle_net_wm_state (f, &event.xproperty)
6106 && f->output_data.x->net_wm_state_hidden_seen) 6106 && FRAME_ICONIFIED_P (f)
6107 && f->output_data.x->net_wm_state_hidden_seen)
6107 { 6108 {
6108 /* Gnome shell does not iconify us when C-z is pressed. It hides 6109 /* Gnome shell does not iconify us when C-z is pressed.
6109 the frame. So if our state says we aren't hidden anymore, 6110 It hides the frame. So if our state says we aren't
6110 treat it as deiconified. */ 6111 hidden anymore, treat it as deiconified. */
6111 if (! f->async_iconified) 6112 SET_FRAME_VISIBLE (f, 1);
6112 SET_FRAME_GARBAGED (f); 6113 SET_FRAME_ICONIFIED (f, 0);
6113 f->async_visible = 1;
6114 f->async_iconified = 0;
6115 f->output_data.x->has_been_visible = 1; 6114 f->output_data.x->has_been_visible = 1;
6116 f->output_data.x->net_wm_state_hidden_seen = 0; 6115 f->output_data.x->net_wm_state_hidden_seen = 0;
6117 inev.ie.kind = DEICONIFY_EVENT; 6116 inev.ie.kind = DEICONIFY_EVENT;
@@ -6152,10 +6151,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6152 event.xexpose.width, event.xexpose.height, 6151 event.xexpose.width, event.xexpose.height,
6153 FALSE); 6152 FALSE);
6154#endif 6153#endif
6155 if (f->async_visible == 0) 6154 if (!FRAME_VISIBLE_P (f))
6156 { 6155 {
6157 f->async_visible = 1; 6156 SET_FRAME_VISIBLE (f, 1);
6158 f->async_iconified = 0; 6157 SET_FRAME_ICONIFIED (f, 0);
6159 f->output_data.x->has_been_visible = 1; 6158 f->output_data.x->has_been_visible = 1;
6160 SET_FRAME_GARBAGED (f); 6159 SET_FRAME_GARBAGED (f);
6161 } 6160 }
@@ -6232,20 +6231,20 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6232 if (f) /* F may no longer exist if 6231 if (f) /* F may no longer exist if
6233 the frame was deleted. */ 6232 the frame was deleted. */
6234 { 6233 {
6234 bool visible = FRAME_VISIBLE_P (f);
6235 /* While a frame is unmapped, display generation is 6235 /* While a frame is unmapped, display generation is
6236 disabled; you don't want to spend time updating a 6236 disabled; you don't want to spend time updating a
6237 display that won't ever be seen. */ 6237 display that won't ever be seen. */
6238 f->async_visible = 0; 6238 SET_FRAME_VISIBLE (f, 0);
6239 /* We can't distinguish, from the event, whether the window 6239 /* We can't distinguish, from the event, whether the window
6240 has become iconified or invisible. So assume, if it 6240 has become iconified or invisible. So assume, if it
6241 was previously visible, than now it is iconified. 6241 was previously visible, than now it is iconified.
6242 But x_make_frame_invisible clears both 6242 But x_make_frame_invisible clears both
6243 the visible flag and the iconified flag; 6243 the visible flag and the iconified flag;
6244 and that way, we know the window is not iconified now. */ 6244 and that way, we know the window is not iconified now. */
6245 if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) 6245 if (visible || FRAME_ICONIFIED_P (f))
6246 { 6246 {
6247 f->async_iconified = 1; 6247 SET_FRAME_ICONIFIED (f, 1);
6248
6249 inev.ie.kind = ICONIFY_EVENT; 6248 inev.ie.kind = ICONIFY_EVENT;
6250 XSETFRAME (inev.ie.frame_or_window, f); 6249 XSETFRAME (inev.ie.frame_or_window, f);
6251 } 6250 }
@@ -6264,13 +6263,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6264 f = x_top_window_to_frame (dpyinfo, event.xmap.window); 6263 f = x_top_window_to_frame (dpyinfo, event.xmap.window);
6265 if (f) 6264 if (f)
6266 { 6265 {
6266 bool iconified = FRAME_ICONIFIED_P (f);
6267 /* wait_reading_process_output will notice this and update 6267 /* wait_reading_process_output will notice this and update
6268 the frame's display structures. 6268 the frame's display structures.
6269 If we where iconified, we should not set garbaged, 6269 If we where iconified, we should not set garbaged,
6270 because that stops redrawing on Expose events. This looks 6270 because that stops redrawing on Expose events. This looks
6271 bad if we are called from a recursive event loop 6271 bad if we are called from a recursive event loop
6272 (x_dispatch_event), for example when a dialog is up. */ 6272 (x_dispatch_event), for example when a dialog is up. */
6273 if (! f->async_iconified) 6273 if (!iconified)
6274 SET_FRAME_GARBAGED (f); 6274 SET_FRAME_GARBAGED (f);
6275 6275
6276 /* Check if fullscreen was specified before we where mapped the 6276 /* Check if fullscreen was specified before we where mapped the
@@ -6278,20 +6278,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6278 if (!f->output_data.x->has_been_visible) 6278 if (!f->output_data.x->has_been_visible)
6279 x_check_fullscreen (f); 6279 x_check_fullscreen (f);
6280 6280
6281 f->async_visible = 1; 6281 SET_FRAME_VISIBLE (f, 1);
6282 f->async_iconified = 0; 6282 SET_FRAME_ICONIFIED (f, 0);
6283 f->output_data.x->has_been_visible = 1; 6283 f->output_data.x->has_been_visible = 1;
6284 6284
6285 if (f->iconified) 6285 if (iconified)
6286 { 6286 {
6287 inev.ie.kind = DEICONIFY_EVENT; 6287 inev.ie.kind = DEICONIFY_EVENT;
6288 XSETFRAME (inev.ie.frame_or_window, f); 6288 XSETFRAME (inev.ie.frame_or_window, f);
6289 } 6289 }
6290 else if (! NILP (Vframe_list) 6290 else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list)))
6291 && ! NILP (XCDR (Vframe_list))) 6291 /* Force a redisplay sooner or later to update the
6292 /* Force a redisplay sooner or later 6292 frame titles in case this is the second frame. */
6293 to update the frame titles
6294 in case this is the second frame. */
6295 record_asynch_buffer_change (); 6293 record_asynch_buffer_change ();
6296 6294
6297#ifdef USE_GTK 6295#ifdef USE_GTK
@@ -8417,7 +8415,7 @@ get_current_wm_state (struct frame *f,
8417 if (tmp_data) XFree (tmp_data); 8415 if (tmp_data) XFree (tmp_data);
8418 x_uncatch_errors (); 8416 x_uncatch_errors ();
8419 unblock_input (); 8417 unblock_input ();
8420 return ! f->iconified; 8418 return !FRAME_ICONIFIED_P (f);
8421 } 8419 }
8422 8420
8423 x_uncatch_errors (); 8421 x_uncatch_errors ();
@@ -8529,7 +8527,7 @@ do_ewmh_fullscreen (struct frame *f)
8529static void 8527static void
8530XTfullscreen_hook (FRAME_PTR f) 8528XTfullscreen_hook (FRAME_PTR f)
8531{ 8529{
8532 if (f->async_visible) 8530 if (FRAME_VISIBLE_P (f))
8533 { 8531 {
8534 block_input (); 8532 block_input ();
8535 x_check_fullscreen (f); 8533 x_check_fullscreen (f);
@@ -8793,7 +8791,7 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows)
8793 /* But the ConfigureNotify may in fact never arrive, and then this is 8791 /* But the ConfigureNotify may in fact never arrive, and then this is
8794 not right if the frame is visible. Instead wait (with timeout) 8792 not right if the frame is visible. Instead wait (with timeout)
8795 for the ConfigureNotify. */ 8793 for the ConfigureNotify. */
8796 if (f->async_visible) 8794 if (FRAME_VISIBLE_P (f))
8797 x_wait_for_event (f, ConfigureNotify); 8795 x_wait_for_event (f, ConfigureNotify);
8798 else 8796 else
8799 { 8797 {
@@ -8905,9 +8903,8 @@ void
8905x_raise_frame (struct frame *f) 8903x_raise_frame (struct frame *f)
8906{ 8904{
8907 block_input (); 8905 block_input ();
8908 if (f->async_visible) 8906 if (FRAME_VISIBLE_P (f))
8909 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8907 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8910
8911 XFlush (FRAME_X_DISPLAY (f)); 8908 XFlush (FRAME_X_DISPLAY (f));
8912 unblock_input (); 8909 unblock_input ();
8913} 8910}
@@ -8917,7 +8914,7 @@ x_raise_frame (struct frame *f)
8917static void 8914static void
8918x_lower_frame (struct frame *f) 8915x_lower_frame (struct frame *f)
8919{ 8916{
8920 if (f->async_visible) 8917 if (FRAME_VISIBLE_P (f))
8921 { 8918 {
8922 block_input (); 8919 block_input ();
8923 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8920 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
@@ -8933,7 +8930,7 @@ xembed_request_focus (FRAME_PTR f)
8933{ 8930{
8934 /* See XEmbed Protocol Specification at 8931 /* See XEmbed Protocol Specification at
8935 http://freedesktop.org/wiki/Specifications/xembed-spec */ 8932 http://freedesktop.org/wiki/Specifications/xembed-spec */
8936 if (f->async_visible) 8933 if (FRAME_VISIBLE_P (f))
8937 xembed_send_message (f, CurrentTime, 8934 xembed_send_message (f, CurrentTime,
8938 XEMBED_REQUEST_FOCUS, 0, 0, 0); 8935 XEMBED_REQUEST_FOCUS, 0, 0, 0);
8939} 8936}
@@ -8947,7 +8944,8 @@ x_ewmh_activate_frame (FRAME_PTR f)
8947 http://freedesktop.org/wiki/Specifications/wm-spec */ 8944 http://freedesktop.org/wiki/Specifications/wm-spec */
8948 8945
8949 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 8946 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8950 if (f->async_visible && wm_supports (f, dpyinfo->Xatom_net_active_window)) 8947
8948 if (FRAME_VISIBLE_P (f) && wm_supports (f, dpyinfo->Xatom_net_active_window))
8951 { 8949 {
8952 Lisp_Object frame; 8950 Lisp_Object frame;
8953 XSETFRAME (frame, f); 8951 XSETFRAME (frame, f);
@@ -9159,9 +9157,6 @@ x_make_frame_visible (struct frame *f)
9159 poll_for_input_1 (); 9157 poll_for_input_1 ();
9160 poll_suppress_count = old_poll_suppress_count; 9158 poll_suppress_count = old_poll_suppress_count;
9161 } 9159 }
9162
9163 /* See if a MapNotify event has been processed. */
9164 FRAME_SAMPLE_VISIBILITY (f);
9165 } 9160 }
9166 9161
9167 /* 2000-09-28: In 9162 /* 2000-09-28: In
@@ -9229,10 +9224,8 @@ x_make_frame_invisible (struct frame *f)
9229 So we can't win using the usual strategy of letting 9224 So we can't win using the usual strategy of letting
9230 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, 9225 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
9231 and synchronize with the server to make sure we agree. */ 9226 and synchronize with the server to make sure we agree. */
9232 f->visible = 0; 9227 SET_FRAME_VISIBLE (f, 0);
9233 FRAME_ICONIFIED_P (f) = 0; 9228 SET_FRAME_ICONIFIED (f, 0);
9234 f->async_visible = 0;
9235 f->async_iconified = 0;
9236 9229
9237 x_sync (f); 9230 x_sync (f);
9238 9231
@@ -9253,13 +9246,11 @@ x_iconify_frame (struct frame *f)
9253 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) 9246 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
9254 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; 9247 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
9255 9248
9256 if (f->async_iconified) 9249 if (FRAME_ICONIFIED_P (f))
9257 return; 9250 return;
9258 9251
9259 block_input (); 9252 block_input ();
9260 9253
9261 FRAME_SAMPLE_VISIBILITY (f);
9262
9263 type = x_icon_type (f); 9254 type = x_icon_type (f);
9264 if (!NILP (type)) 9255 if (!NILP (type))
9265 x_bitmap_icon (f, type); 9256 x_bitmap_icon (f, type);
@@ -9271,10 +9262,8 @@ x_iconify_frame (struct frame *f)
9271 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); 9262 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f));
9272 9263
9273 gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 9264 gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
9274 f->iconified = 1; 9265 SET_FRAME_VISIBLE (f, 0);
9275 f->visible = 1; 9266 SET_FRAME_ICONIFIED (f, 1);
9276 f->async_iconified = 1;
9277 f->async_visible = 0;
9278 unblock_input (); 9267 unblock_input ();
9279 return; 9268 return;
9280 } 9269 }
@@ -9291,10 +9280,8 @@ x_iconify_frame (struct frame *f)
9291 /* The server won't give us any event to indicate 9280 /* The server won't give us any event to indicate
9292 that an invisible frame was changed to an icon, 9281 that an invisible frame was changed to an icon,
9293 so we have to record it here. */ 9282 so we have to record it here. */
9294 f->iconified = 1; 9283 SET_FRAME_VISIBLE (f, 0);
9295 f->visible = 1; 9284 SET_FRAME_ICONIFIED (f, 1);
9296 f->async_iconified = 1;
9297 f->async_visible = 0;
9298 unblock_input (); 9285 unblock_input ();
9299 return; 9286 return;
9300 } 9287 }
@@ -9307,9 +9294,8 @@ x_iconify_frame (struct frame *f)
9307 if (!result) 9294 if (!result)
9308 error ("Can't notify window manager of iconification"); 9295 error ("Can't notify window manager of iconification");
9309 9296
9310 f->async_iconified = 1; 9297 SET_FRAME_ICONIFIED (f, 1);
9311 f->async_visible = 0; 9298 SET_FRAME_VISIBLE (f, 0);
9312
9313 9299
9314 block_input (); 9300 block_input ();
9315 XFlush (FRAME_X_DISPLAY (f)); 9301 XFlush (FRAME_X_DISPLAY (f));
@@ -9358,8 +9344,8 @@ x_iconify_frame (struct frame *f)
9358 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 9344 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
9359 } 9345 }
9360 9346
9361 f->async_iconified = 1; 9347 SET_FRAME_ICONIFIED (f, 1);
9362 f->async_visible = 0; 9348 SET_FRAME_VISIBLE (f, 0);
9363 9349
9364 XFlush (FRAME_X_DISPLAY (f)); 9350 XFlush (FRAME_X_DISPLAY (f));
9365 unblock_input (); 9351 unblock_input ();