aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog31
-rw-r--r--src/frame.c30
-rw-r--r--src/frame.h94
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/insdel.c7
-rw-r--r--src/nsfont.m16
-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
13 files changed, 211 insertions, 254 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7a2ff184c0a..ffa4bdf927f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,34 @@
12013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * nsfont.m (ns_escape_name, ns_unescape_name, ns_registry_to_script):
4 Avoid redundant calls to strlen.
5
62013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
7
8 Drop async_visible and async_iconified fields of struct frame.
9 This is possible because async input is gone; for details, see
10 http://lists.gnu.org/archive/html/emacs-devel/2012-12/msg00734.html.
11 * frame.h (struct frame): Remove async_visible and async_iconified
12 members, convert garbaged to unsigned bitfield. Adjust comments.
13 (FRAME_SAMPLE_VISIBILITY): Remove. Adjust all users.
14 (SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED): New macros.
15 * frame.c, gtkutil.c, term.c, w32fns.c, window.c, xdisp.c:
16 Consistently use SET_FRAME_VISIBLE, SET_FRAME_ICONIFIED,
17 FRAME_VISIBLE_P and FRAME_ICONIFIED_P macros where appropriate.
18 * w32term.c: Ditto.
19 (w32_read_socket): Save iconified state to generate DEICONIFY_EVENT
20 properly. Likewise for obscured.
21 * xterm.c: Ditto.
22 (handle_one_xevent): Save visible state go generate ICONIFY_EVENT
23 properly.
24 * nsterm.m: Ditto.
25 (windowDidDeminiaturize): Generate DEICONIFY_EVENT.
26
272013-01-24 Dmitry Antipov <dmantipov@yandex.ru>
28
29 * insdel.c (prepare_to_modify_buffer): Revert last change as suggested
30 in http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00555.html.
31
12013-01-23 Stefan Monnier <monnier@iro.umontreal.ca> 322013-01-23 Stefan Monnier <monnier@iro.umontreal.ca>
2 33
3 * xdisp.c (message2, message2_nolog): Remove functions. 34 * xdisp.c (message2, message2_nolog): Remove functions.
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/insdel.c b/src/insdel.c
index 98dd97bdd08..303247816ca 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1804,12 +1804,9 @@ prepare_to_modify_buffer (ptrdiff_t start, ptrdiff_t end,
1804 Fbarf_if_buffer_read_only (); 1804 Fbarf_if_buffer_read_only ();
1805 1805
1806 /* If we're modifying the buffer other than shown in a selected window, 1806 /* If we're modifying the buffer other than shown in a selected window,
1807 let redisplay consider other windows if this buffer is visible or 1807 let redisplay consider other windows if this buffer is visible. */
1808 hidden (although hidden buffers have zero window counts, their state
1809 may affect the display too, e.g. via mode lines of other buffers). */
1810 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer 1808 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer
1811 && (buffer_window_count (current_buffer) 1809 && buffer_window_count (current_buffer))
1812 || BUFFER_HIDDEN_P (current_buffer)))
1813 ++windows_or_buffers_changed; 1810 ++windows_or_buffers_changed;
1814 1811
1815 if (buffer_intervals (current_buffer)) 1812 if (buffer_intervals (current_buffer))
diff --git a/src/nsfont.m b/src/nsfont.m
index 5039f0c9013..ebee363651f 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -75,10 +75,9 @@ static void ns_glyph_metrics (struct nsfont_info *font_info,
75static void 75static void
76ns_escape_name (char *name) 76ns_escape_name (char *name)
77{ 77{
78 int i =0, len =strlen (name); 78 for (; *name; name++)
79 for ( ; i<len; i++) 79 if (*name == ' ')
80 if (name[i] == ' ') 80 *name = '_';
81 name[i] = '_';
82} 81}
83 82
84 83
@@ -86,10 +85,9 @@ ns_escape_name (char *name)
86static void 85static void
87ns_unescape_name (char *name) 86ns_unescape_name (char *name)
88{ 87{
89 int i =0, len =strlen (name); 88 for (; *name; name++)
90 for ( ; i<len; i++) 89 if (*name == '_')
91 if (name[i] == '_') 90 *name = ' ';
92 name[i] = ' ';
93} 91}
94 92
95 93
@@ -364,7 +362,7 @@ static NSString
364 while CONSP (rts) 362 while CONSP (rts)
365 { 363 {
366 r = XCAR (XCAR (rts)); 364 r = XCAR (XCAR (rts));
367 if (!strncmp(SSDATA(r), reg, strlen(SSDATA(r)))) 365 if (!strncmp (SSDATA (r), reg, SBYTES (r)))
368 { 366 {
369 script = XCDR (XCAR (rts)); 367 script = XCDR (XCAR (rts));
370 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))]; 368 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))];
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 906cfe6ba9d..f75c17a3d4f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2232,7 +2232,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2232 } 2232 }
2233 else if (EQ (all_frames, Qvisible)) 2233 else if (EQ (all_frames, Qvisible))
2234 { 2234 {
2235 FRAME_SAMPLE_VISIBILITY (f);
2236 candidate_p = FRAME_VISIBLE_P (f) 2235 candidate_p = FRAME_VISIBLE_P (f)
2237 && (FRAME_TERMINAL (XFRAME (w->frame)) 2236 && (FRAME_TERMINAL (XFRAME (w->frame))
2238 == FRAME_TERMINAL (XFRAME (selected_frame))); 2237 == FRAME_TERMINAL (XFRAME (selected_frame)));
@@ -2240,7 +2239,6 @@ candidate_window_p (Lisp_Object window, Lisp_Object owindow, Lisp_Object minibuf
2240 } 2239 }
2241 else if (INTEGERP (all_frames) && XINT (all_frames) == 0) 2240 else if (INTEGERP (all_frames) && XINT (all_frames) == 0)
2242 { 2241 {
2243 FRAME_SAMPLE_VISIBILITY (f);
2244 candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f) 2242 candidate_p = (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)
2245#ifdef HAVE_X_WINDOWS 2243#ifdef HAVE_X_WINDOWS
2246 /* Yuck!! If we've just created the frame and the 2244 /* Yuck!! If we've just created the frame and the
diff --git a/src/xdisp.c b/src/xdisp.c
index c550a7db02c..c7ee0d37f47 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9698,8 +9698,7 @@ message3_nolog (Lisp_Object m)
9698 /* Error messages get reported properly by cmd_error, so this must be just an 9698 /* Error messages get reported properly by cmd_error, so this must be just an
9699 informative message; if the frame hasn't really been initialized yet, just 9699 informative message; if the frame hasn't really been initialized yet, just
9700 toss it. */ 9700 toss it. */
9701 else if (INTERACTIVE 9701 else if (INTERACTIVE && sf->glyphs_initialized_p)
9702 && sf->glyphs_initialized_p)
9703 { 9702 {
9704 /* Get the frame containing the mini-buffer 9703 /* Get the frame containing the mini-buffer
9705 that the selected frame is using. */ 9704 that the selected frame is using. */
@@ -9707,9 +9706,7 @@ message3_nolog (Lisp_Object m)
9707 Lisp_Object frame = XWINDOW (mini_window)->frame; 9706 Lisp_Object frame = XWINDOW (mini_window)->frame;
9708 struct frame *f = XFRAME (frame); 9707 struct frame *f = XFRAME (frame);
9709 9708
9710 FRAME_SAMPLE_VISIBILITY (f); 9709 if (FRAME_VISIBLE_P (sf) && !FRAME_VISIBLE_P (f))
9711 if (FRAME_VISIBLE_P (sf)
9712 && !FRAME_VISIBLE_P (f))
9713 Fmake_frame_visible (frame); 9710 Fmake_frame_visible (frame);
9714 9711
9715 if (STRINGP (m) && SCHARS (m) > 0) 9712 if (STRINGP (m) && SCHARS (m) > 0)
@@ -12978,7 +12975,6 @@ redisplay_internal (void)
12978 { 12975 {
12979 struct frame *f = XFRAME (frame); 12976 struct frame *f = XFRAME (frame);
12980 12977
12981 FRAME_SAMPLE_VISIBILITY (f);
12982 if (FRAME_VISIBLE_P (f)) 12978 if (FRAME_VISIBLE_P (f))
12983 ++number_of_visible_frames; 12979 ++number_of_visible_frames;
12984 clear_desired_matrices (f); 12980 clear_desired_matrices (f);
@@ -13533,9 +13529,6 @@ redisplay_internal (void)
13533 13529
13534 if (XFRAME (frame)->visible) 13530 if (XFRAME (frame)->visible)
13535 this_is_visible = 1; 13531 this_is_visible = 1;
13536 FRAME_SAMPLE_VISIBILITY (XFRAME (frame));
13537 if (XFRAME (frame)->visible)
13538 this_is_visible = 1;
13539 13532
13540 if (this_is_visible) 13533 if (this_is_visible)
13541 new_count++; 13534 new_count++;
diff --git a/src/xterm.c b/src/xterm.c
index 212530e5acf..e92123583b0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6111,16 +6111,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6111 last_user_time = event.xproperty.time; 6111 last_user_time = event.xproperty.time;
6112 f = x_top_window_to_frame (dpyinfo, event.xproperty.window); 6112 f = x_top_window_to_frame (dpyinfo, event.xproperty.window);
6113 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state) 6113 if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state)
6114 if (x_handle_net_wm_state (f, &event.xproperty) && f->iconified 6114 if (x_handle_net_wm_state (f, &event.xproperty)
6115 && f->output_data.x->net_wm_state_hidden_seen) 6115 && FRAME_ICONIFIED_P (f)
6116 && f->output_data.x->net_wm_state_hidden_seen)
6116 { 6117 {
6117 /* Gnome shell does not iconify us when C-z is pressed. It hides 6118 /* Gnome shell does not iconify us when C-z is pressed.
6118 the frame. So if our state says we aren't hidden anymore, 6119 It hides the frame. So if our state says we aren't
6119 treat it as deiconified. */ 6120 hidden anymore, treat it as deiconified. */
6120 if (! f->async_iconified) 6121 SET_FRAME_VISIBLE (f, 1);
6121 SET_FRAME_GARBAGED (f); 6122 SET_FRAME_ICONIFIED (f, 0);
6122 f->async_visible = 1;
6123 f->async_iconified = 0;
6124 f->output_data.x->has_been_visible = 1; 6123 f->output_data.x->has_been_visible = 1;
6125 f->output_data.x->net_wm_state_hidden_seen = 0; 6124 f->output_data.x->net_wm_state_hidden_seen = 0;
6126 inev.ie.kind = DEICONIFY_EVENT; 6125 inev.ie.kind = DEICONIFY_EVENT;
@@ -6161,10 +6160,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6161 event.xexpose.width, event.xexpose.height, 6160 event.xexpose.width, event.xexpose.height,
6162 FALSE); 6161 FALSE);
6163#endif 6162#endif
6164 if (f->async_visible == 0) 6163 if (!FRAME_VISIBLE_P (f))
6165 { 6164 {
6166 f->async_visible = 1; 6165 SET_FRAME_VISIBLE (f, 1);
6167 f->async_iconified = 0; 6166 SET_FRAME_ICONIFIED (f, 0);
6168 f->output_data.x->has_been_visible = 1; 6167 f->output_data.x->has_been_visible = 1;
6169 SET_FRAME_GARBAGED (f); 6168 SET_FRAME_GARBAGED (f);
6170 } 6169 }
@@ -6241,20 +6240,20 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6241 if (f) /* F may no longer exist if 6240 if (f) /* F may no longer exist if
6242 the frame was deleted. */ 6241 the frame was deleted. */
6243 { 6242 {
6243 bool visible = FRAME_VISIBLE_P (f);
6244 /* While a frame is unmapped, display generation is 6244 /* While a frame is unmapped, display generation is
6245 disabled; you don't want to spend time updating a 6245 disabled; you don't want to spend time updating a
6246 display that won't ever be seen. */ 6246 display that won't ever be seen. */
6247 f->async_visible = 0; 6247 SET_FRAME_VISIBLE (f, 0);
6248 /* We can't distinguish, from the event, whether the window 6248 /* We can't distinguish, from the event, whether the window
6249 has become iconified or invisible. So assume, if it 6249 has become iconified or invisible. So assume, if it
6250 was previously visible, than now it is iconified. 6250 was previously visible, than now it is iconified.
6251 But x_make_frame_invisible clears both 6251 But x_make_frame_invisible clears both
6252 the visible flag and the iconified flag; 6252 the visible flag and the iconified flag;
6253 and that way, we know the window is not iconified now. */ 6253 and that way, we know the window is not iconified now. */
6254 if (FRAME_VISIBLE_P (f) || FRAME_ICONIFIED_P (f)) 6254 if (visible || FRAME_ICONIFIED_P (f))
6255 { 6255 {
6256 f->async_iconified = 1; 6256 SET_FRAME_ICONIFIED (f, 1);
6257
6258 inev.ie.kind = ICONIFY_EVENT; 6257 inev.ie.kind = ICONIFY_EVENT;
6259 XSETFRAME (inev.ie.frame_or_window, f); 6258 XSETFRAME (inev.ie.frame_or_window, f);
6260 } 6259 }
@@ -6273,13 +6272,14 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6273 f = x_top_window_to_frame (dpyinfo, event.xmap.window); 6272 f = x_top_window_to_frame (dpyinfo, event.xmap.window);
6274 if (f) 6273 if (f)
6275 { 6274 {
6275 bool iconified = FRAME_ICONIFIED_P (f);
6276 /* wait_reading_process_output will notice this and update 6276 /* wait_reading_process_output will notice this and update
6277 the frame's display structures. 6277 the frame's display structures.
6278 If we where iconified, we should not set garbaged, 6278 If we where iconified, we should not set garbaged,
6279 because that stops redrawing on Expose events. This looks 6279 because that stops redrawing on Expose events. This looks
6280 bad if we are called from a recursive event loop 6280 bad if we are called from a recursive event loop
6281 (x_dispatch_event), for example when a dialog is up. */ 6281 (x_dispatch_event), for example when a dialog is up. */
6282 if (! f->async_iconified) 6282 if (!iconified)
6283 SET_FRAME_GARBAGED (f); 6283 SET_FRAME_GARBAGED (f);
6284 6284
6285 /* Check if fullscreen was specified before we where mapped the 6285 /* Check if fullscreen was specified before we where mapped the
@@ -6287,20 +6287,18 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventptr,
6287 if (!f->output_data.x->has_been_visible) 6287 if (!f->output_data.x->has_been_visible)
6288 x_check_fullscreen (f); 6288 x_check_fullscreen (f);
6289 6289
6290 f->async_visible = 1; 6290 SET_FRAME_VISIBLE (f, 1);
6291 f->async_iconified = 0; 6291 SET_FRAME_ICONIFIED (f, 0);
6292 f->output_data.x->has_been_visible = 1; 6292 f->output_data.x->has_been_visible = 1;
6293 6293
6294 if (f->iconified) 6294 if (iconified)
6295 { 6295 {
6296 inev.ie.kind = DEICONIFY_EVENT; 6296 inev.ie.kind = DEICONIFY_EVENT;
6297 XSETFRAME (inev.ie.frame_or_window, f); 6297 XSETFRAME (inev.ie.frame_or_window, f);
6298 } 6298 }
6299 else if (! NILP (Vframe_list) 6299 else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list)))
6300 && ! NILP (XCDR (Vframe_list))) 6300 /* Force a redisplay sooner or later to update the
6301 /* Force a redisplay sooner or later 6301 frame titles in case this is the second frame. */
6302 to update the frame titles
6303 in case this is the second frame. */
6304 record_asynch_buffer_change (); 6302 record_asynch_buffer_change ();
6305 6303
6306#ifdef USE_GTK 6304#ifdef USE_GTK
@@ -8431,7 +8429,7 @@ get_current_wm_state (struct frame *f,
8431 if (tmp_data) XFree (tmp_data); 8429 if (tmp_data) XFree (tmp_data);
8432 x_uncatch_errors (); 8430 x_uncatch_errors ();
8433 unblock_input (); 8431 unblock_input ();
8434 return ! f->iconified; 8432 return !FRAME_ICONIFIED_P (f);
8435 } 8433 }
8436 8434
8437 x_uncatch_errors (); 8435 x_uncatch_errors ();
@@ -8543,7 +8541,7 @@ do_ewmh_fullscreen (struct frame *f)
8543static void 8541static void
8544XTfullscreen_hook (FRAME_PTR f) 8542XTfullscreen_hook (FRAME_PTR f)
8545{ 8543{
8546 if (f->async_visible) 8544 if (FRAME_VISIBLE_P (f))
8547 { 8545 {
8548 block_input (); 8546 block_input ();
8549 x_check_fullscreen (f); 8547 x_check_fullscreen (f);
@@ -8807,7 +8805,7 @@ x_set_window_size_1 (struct frame *f, int change_gravity, int cols, int rows)
8807 /* But the ConfigureNotify may in fact never arrive, and then this is 8805 /* But the ConfigureNotify may in fact never arrive, and then this is
8808 not right if the frame is visible. Instead wait (with timeout) 8806 not right if the frame is visible. Instead wait (with timeout)
8809 for the ConfigureNotify. */ 8807 for the ConfigureNotify. */
8810 if (f->async_visible) 8808 if (FRAME_VISIBLE_P (f))
8811 x_wait_for_event (f, ConfigureNotify); 8809 x_wait_for_event (f, ConfigureNotify);
8812 else 8810 else
8813 { 8811 {
@@ -8919,9 +8917,8 @@ void
8919x_raise_frame (struct frame *f) 8917x_raise_frame (struct frame *f)
8920{ 8918{
8921 block_input (); 8919 block_input ();
8922 if (f->async_visible) 8920 if (FRAME_VISIBLE_P (f))
8923 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8921 XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
8924
8925 XFlush (FRAME_X_DISPLAY (f)); 8922 XFlush (FRAME_X_DISPLAY (f));
8926 unblock_input (); 8923 unblock_input ();
8927} 8924}
@@ -8931,7 +8928,7 @@ x_raise_frame (struct frame *f)
8931static void 8928static void
8932x_lower_frame (struct frame *f) 8929x_lower_frame (struct frame *f)
8933{ 8930{
8934 if (f->async_visible) 8931 if (FRAME_VISIBLE_P (f))
8935 { 8932 {
8936 block_input (); 8933 block_input ();
8937 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); 8934 XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
@@ -8947,7 +8944,7 @@ xembed_request_focus (FRAME_PTR f)
8947{ 8944{
8948 /* See XEmbed Protocol Specification at 8945 /* See XEmbed Protocol Specification at
8949 http://freedesktop.org/wiki/Specifications/xembed-spec */ 8946 http://freedesktop.org/wiki/Specifications/xembed-spec */
8950 if (f->async_visible) 8947 if (FRAME_VISIBLE_P (f))
8951 xembed_send_message (f, CurrentTime, 8948 xembed_send_message (f, CurrentTime,
8952 XEMBED_REQUEST_FOCUS, 0, 0, 0); 8949 XEMBED_REQUEST_FOCUS, 0, 0, 0);
8953} 8950}
@@ -8961,7 +8958,8 @@ x_ewmh_activate_frame (FRAME_PTR f)
8961 http://freedesktop.org/wiki/Specifications/wm-spec */ 8958 http://freedesktop.org/wiki/Specifications/wm-spec */
8962 8959
8963 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 8960 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8964 if (f->async_visible && wm_supports (f, dpyinfo->Xatom_net_active_window)) 8961
8962 if (FRAME_VISIBLE_P (f) && wm_supports (f, dpyinfo->Xatom_net_active_window))
8965 { 8963 {
8966 Lisp_Object frame; 8964 Lisp_Object frame;
8967 XSETFRAME (frame, f); 8965 XSETFRAME (frame, f);
@@ -9173,9 +9171,6 @@ x_make_frame_visible (struct frame *f)
9173 poll_for_input_1 (); 9171 poll_for_input_1 ();
9174 poll_suppress_count = old_poll_suppress_count; 9172 poll_suppress_count = old_poll_suppress_count;
9175 } 9173 }
9176
9177 /* See if a MapNotify event has been processed. */
9178 FRAME_SAMPLE_VISIBILITY (f);
9179 } 9174 }
9180 9175
9181 /* 2000-09-28: In 9176 /* 2000-09-28: In
@@ -9243,10 +9238,8 @@ x_make_frame_invisible (struct frame *f)
9243 So we can't win using the usual strategy of letting 9238 So we can't win using the usual strategy of letting
9244 FRAME_SAMPLE_VISIBILITY set this. So do it by hand, 9239 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
9245 and synchronize with the server to make sure we agree. */ 9240 and synchronize with the server to make sure we agree. */
9246 f->visible = 0; 9241 SET_FRAME_VISIBLE (f, 0);
9247 FRAME_ICONIFIED_P (f) = 0; 9242 SET_FRAME_ICONIFIED (f, 0);
9248 f->async_visible = 0;
9249 f->async_iconified = 0;
9250 9243
9251 x_sync (f); 9244 x_sync (f);
9252 9245
@@ -9267,13 +9260,11 @@ x_iconify_frame (struct frame *f)
9267 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) 9260 if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f)
9268 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; 9261 FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0;
9269 9262
9270 if (f->async_iconified) 9263 if (FRAME_ICONIFIED_P (f))
9271 return; 9264 return;
9272 9265
9273 block_input (); 9266 block_input ();
9274 9267
9275 FRAME_SAMPLE_VISIBILITY (f);
9276
9277 type = x_icon_type (f); 9268 type = x_icon_type (f);
9278 if (!NILP (type)) 9269 if (!NILP (type))
9279 x_bitmap_icon (f, type); 9270 x_bitmap_icon (f, type);
@@ -9285,10 +9276,8 @@ x_iconify_frame (struct frame *f)
9285 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f)); 9276 gtk_widget_show_all (FRAME_GTK_OUTER_WIDGET (f));
9286 9277
9287 gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); 9278 gtk_window_iconify (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
9288 f->iconified = 1; 9279 SET_FRAME_VISIBLE (f, 0);
9289 f->visible = 1; 9280 SET_FRAME_ICONIFIED (f, 1);
9290 f->async_iconified = 1;
9291 f->async_visible = 0;
9292 unblock_input (); 9281 unblock_input ();
9293 return; 9282 return;
9294 } 9283 }
@@ -9305,10 +9294,8 @@ x_iconify_frame (struct frame *f)
9305 /* The server won't give us any event to indicate 9294 /* The server won't give us any event to indicate
9306 that an invisible frame was changed to an icon, 9295 that an invisible frame was changed to an icon,
9307 so we have to record it here. */ 9296 so we have to record it here. */
9308 f->iconified = 1; 9297 SET_FRAME_VISIBLE (f, 0);
9309 f->visible = 1; 9298 SET_FRAME_ICONIFIED (f, 1);
9310 f->async_iconified = 1;
9311 f->async_visible = 0;
9312 unblock_input (); 9299 unblock_input ();
9313 return; 9300 return;
9314 } 9301 }
@@ -9321,9 +9308,8 @@ x_iconify_frame (struct frame *f)
9321 if (!result) 9308 if (!result)
9322 error ("Can't notify window manager of iconification"); 9309 error ("Can't notify window manager of iconification");
9323 9310
9324 f->async_iconified = 1; 9311 SET_FRAME_ICONIFIED (f, 1);
9325 f->async_visible = 0; 9312 SET_FRAME_VISIBLE (f, 0);
9326
9327 9313
9328 block_input (); 9314 block_input ();
9329 XFlush (FRAME_X_DISPLAY (f)); 9315 XFlush (FRAME_X_DISPLAY (f));
@@ -9372,8 +9358,8 @@ x_iconify_frame (struct frame *f)
9372 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 9358 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
9373 } 9359 }
9374 9360
9375 f->async_iconified = 1; 9361 SET_FRAME_ICONIFIED (f, 1);
9376 f->async_visible = 0; 9362 SET_FRAME_VISIBLE (f, 0);
9377 9363
9378 XFlush (FRAME_X_DISPLAY (f)); 9364 XFlush (FRAME_X_DISPLAY (f));
9379 unblock_input (); 9365 unblock_input ();