aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXue Fuqiao2013-07-30 08:29:09 +0800
committerXue Fuqiao2013-07-30 08:29:09 +0800
commitd2067333246b676fcf98567d34eec79ed4648d5f (patch)
treead6543d8e7f1db50226907f7278373eef544d252 /src
parent7aa7fff0c8860b72a2c7cdc7d4d0845245754d43 (diff)
parent86b192c1479d167c13edb9cdaa026c231c8a0442 (diff)
downloademacs-d2067333246b676fcf98567d34eec79ed4648d5f.tar.gz
emacs-d2067333246b676fcf98567d34eec79ed4648d5f.zip
Merge from mainline.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog55
-rw-r--r--src/ChangeLog.126
-rw-r--r--src/ChangeLog.92
-rw-r--r--src/eval.c170
-rw-r--r--src/fileio.c3
-rw-r--r--src/fns.c2
-rw-r--r--src/frame.c12
-rw-r--r--src/nsterm.m4
-rw-r--r--src/process.c2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32term.c18
-rw-r--r--src/xterm.c15
12 files changed, 234 insertions, 57 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 64b13a5ac28..b7b2d5fba4b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,58 @@
12013-07-29 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * fns.c (toplevel): Remove comment before Fsafe_length because
4 it checks for QUIT.
5
62013-07-28 Paul Eggert <eggert@cs.ucla.edu>
7
8 * frame.c (delete_frame): Avoid unnecessary 'this_f' test (Bug#14970).
9
102013-07-28 Eli Zaretskii <eliz@gnu.org>
11
12 * w32fns.c (w32_wnd_proc) <WM_IME_STARTCOMPOSITION>: Make sure the
13 frame which got the message is still alive, before dereferencing
14 its pointer. (Bug#14970)
15
16 * frame.c (delete_frame): Test "this" frame's minibuffer window to
17 be a live window, before using it as such. (Bug#14970)
18
192013-07-27 Eli Zaretskii <eliz@gnu.org>
20
21 * w32term.c (w32_read_socket) <WM_KILLFOCUS>: Call
22 w32_detect_focus_change instead of doing part of its job by hand.
23 This fixes the problem whereby FOCUS_OUT events were not sent to
24 the event queue.
25
262013-07-26 Eli Zaretskii <eliz@gnu.org>
27
28 * process.c (Fprocess_list): Doc fix.
29
30 * w32term.c (w32_read_socket) <WM_EMACS_PAINT>: Warn about frame
31 being re-exposed only if it didn't ask to become visible.
32 <WM_SIZE>: Under SIZE_RESTORED, only set the frame visible if it
33 was previously iconified. (Bug#14841)
34 (x_iconify_frame): Mark the frame iconified.
35
362013-07-26 Paul Eggert <eggert@cs.ucla.edu>
37
38 Fix minor problems found by static checking.
39 * eval.c (get_backtrace_frame, backtrace_eval_unrewind): Now static.
40 (backtrace_eval_unrewind): ';' -> '{}' to pacify GCC.
41
422013-07-26 Stefan Monnier <monnier@iro.umontreal.ca>
43
44 * eval.c (set_specpdl_old_value): New function.
45 (unbind_to): Minor simplification.
46 (get_backtrace_frame): New function.
47 (Fbacktrace_frame): Use it. Add `base' argument.
48 (backtrace_eval_unrewind, Fbacktrace_eval): New functions.
49 (syms_of_eval): Export backtrace-eval.
50 * xterm.c (x_focus_changed): Simplify.
51
522013-07-25 Paul Eggert <eggert@cs.ucla.edu>
53
54 * fileio.c (Finsert_file_contents): Avoid double-close (Bug#14936).
55
12013-07-24 Eli Zaretskii <eliz@gnu.org> 562013-07-24 Eli Zaretskii <eliz@gnu.org>
2 57
3 * xdisp.c (redisplay_window): Instead of moving point out of 58 * xdisp.c (redisplay_window): Instead of moving point out of
diff --git a/src/ChangeLog.12 b/src/ChangeLog.12
index 2b22690bb87..053baa3d487 100644
--- a/src/ChangeLog.12
+++ b/src/ChangeLog.12
@@ -69,7 +69,7 @@
69 69
70 * dispnew.c (update_window): Use MATRIX_ROW and MATRIX_MODE_LINE_ROW. 70 * dispnew.c (update_window): Use MATRIX_ROW and MATRIX_MODE_LINE_ROW.
71 71
722013-03-10 handa <handa@gnu.org> 722013-03-10 Kenichi Handa <handa@gnu.org>
73 73
74 * lisp.h (adjust_after_replace): Extern it. 74 * lisp.h (adjust_after_replace): Extern it.
75 75
@@ -11043,7 +11043,7 @@
11043 * nsterm.m (x_free_frame_resources): Move xfree so freed memory isn't 11043 * nsterm.m (x_free_frame_resources): Move xfree so freed memory isn't
11044 referenced (Bug#11583). 11044 referenced (Bug#11583).
11045 11045
110462012-06-16 Aurelien Aptel <aurelien.aptel@gmail.com> 110462012-06-16 Aurélien Aptel <aurelien.aptel@gmail.com>
11047 11047
11048 Implement wave-style variant of underlining. 11048 Implement wave-style variant of underlining.
11049 * dispextern.h (face_underline_type): New enum. 11049 * dispextern.h (face_underline_type): New enum.
@@ -21400,7 +21400,7 @@
21400 21400
21401 * process.c (Fformat_network_address): Doc fix. 21401 * process.c (Fformat_network_address): Doc fix.
21402 21402
214032011-04-08 T.V. Raman <tv.raman.tv@gmail.com> (tiny change) 214032011-04-08 T. V. Raman <tv.raman.tv@gmail.com> (tiny change)
21404 21404
21405 * xml.c (parse_region): Avoid creating spurious whitespace nodes. 21405 * xml.c (parse_region): Avoid creating spurious whitespace nodes.
21406 21406
diff --git a/src/ChangeLog.9 b/src/ChangeLog.9
index b451b78944f..2e1d41b2495 100644
--- a/src/ChangeLog.9
+++ b/src/ChangeLog.9
@@ -10644,7 +10644,7 @@
10644 (syms_of_xfns) [GLYPH_DEBUG]: Don't defsubr removed functions. 10644 (syms_of_xfns) [GLYPH_DEBUG]: Don't defsubr removed functions.
10645 (syms_of_xfns): Initialize Qcenter. 10645 (syms_of_xfns): Initialize Qcenter.
10646 10646
10647 * eval.c (Fsignal): If lisp_eval_depth or spepdl_size are near 10647 * eval.c (Fsignal): If lisp_eval_depth or specpdl_size are near
10648 to the limits, increase the limits. 10648 to the limits, increase the limits.
10649 10649
106502000-05-01 Kenichi Handa <handa@etl.go.jp> 106502000-05-01 Kenichi Handa <handa@etl.go.jp>
diff --git a/src/eval.c b/src/eval.c
index 6cb2b7a92b8..cb716690e3c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -138,6 +138,13 @@ specpdl_old_value (union specbinding *pdl)
138 return pdl->let.old_value; 138 return pdl->let.old_value;
139} 139}
140 140
141static void
142set_specpdl_old_value (union specbinding *pdl, Lisp_Object val)
143{
144 eassert (pdl->kind >= SPECPDL_LET);
145 pdl->let.old_value = val;
146}
147
141static Lisp_Object 148static Lisp_Object
142specpdl_where (union specbinding *pdl) 149specpdl_where (union specbinding *pdl)
143{ 150{
@@ -3301,6 +3308,8 @@ unbind_to (ptrdiff_t count, Lisp_Object value)
3301 case SPECPDL_UNWIND_VOID: 3308 case SPECPDL_UNWIND_VOID:
3302 specpdl_ptr->unwind_void.func (); 3309 specpdl_ptr->unwind_void.func ();
3303 break; 3310 break;
3311 case SPECPDL_BACKTRACE:
3312 break;
3304 case SPECPDL_LET: 3313 case SPECPDL_LET:
3305 /* If variable has a trivial value (no forwarding), we can 3314 /* If variable has a trivial value (no forwarding), we can
3306 just set it. No need to check for constant symbols here, 3315 just set it. No need to check for constant symbols here,
@@ -3315,27 +3324,20 @@ unbind_to (ptrdiff_t count, Lisp_Object value)
3315 Fset_default (specpdl_symbol (specpdl_ptr), 3324 Fset_default (specpdl_symbol (specpdl_ptr),
3316 specpdl_old_value (specpdl_ptr)); 3325 specpdl_old_value (specpdl_ptr));
3317 break; 3326 break;
3318 case SPECPDL_BACKTRACE: 3327 case SPECPDL_LET_DEFAULT:
3328 Fset_default (specpdl_symbol (specpdl_ptr),
3329 specpdl_old_value (specpdl_ptr));
3319 break; 3330 break;
3320 case SPECPDL_LET_LOCAL: 3331 case SPECPDL_LET_LOCAL:
3321 case SPECPDL_LET_DEFAULT: 3332 {
3322 { /* If the symbol is a list, it is really (SYMBOL WHERE
3323 . CURRENT-BUFFER) where WHERE is either nil, a buffer, or a
3324 frame. If WHERE is a buffer or frame, this indicates we
3325 bound a variable that had a buffer-local or frame-local
3326 binding. WHERE nil means that the variable had the default
3327 value when it was bound. CURRENT-BUFFER is the buffer that
3328 was current when the variable was bound. */
3329 Lisp_Object symbol = specpdl_symbol (specpdl_ptr); 3333 Lisp_Object symbol = specpdl_symbol (specpdl_ptr);
3330 Lisp_Object where = specpdl_where (specpdl_ptr); 3334 Lisp_Object where = specpdl_where (specpdl_ptr);
3331 Lisp_Object old_value = specpdl_old_value (specpdl_ptr); 3335 Lisp_Object old_value = specpdl_old_value (specpdl_ptr);
3332 eassert (BUFFERP (where)); 3336 eassert (BUFFERP (where));
3333 3337
3334 if (specpdl_ptr->kind == SPECPDL_LET_DEFAULT)
3335 Fset_default (symbol, old_value);
3336 /* If this was a local binding, reset the value in the appropriate 3338 /* If this was a local binding, reset the value in the appropriate
3337 buffer, but only if that buffer's binding still exists. */ 3339 buffer, but only if that buffer's binding still exists. */
3338 else if (!NILP (Flocal_variable_p (symbol, where))) 3340 if (!NILP (Flocal_variable_p (symbol, where)))
3339 set_internal (symbol, old_value, where, 1); 3341 set_internal (symbol, old_value, where, 1);
3340 } 3342 }
3341 break; 3343 break;
@@ -3422,7 +3424,30 @@ Output stream used is value of `standard-output'. */)
3422 return Qnil; 3424 return Qnil;
3423} 3425}
3424 3426
3425DEFUN ("backtrace-frame", Fbacktrace_frame, Sbacktrace_frame, 1, 1, NULL, 3427static union specbinding *
3428get_backtrace_frame (Lisp_Object nframes, Lisp_Object base)
3429{
3430 union specbinding *pdl = backtrace_top ();
3431 register EMACS_INT i;
3432
3433 CHECK_NATNUM (nframes);
3434
3435 if (!NILP (base))
3436 { /* Skip up to `base'. */
3437 base = Findirect_function (base, Qt);
3438 while (backtrace_p (pdl)
3439 && !EQ (base, Findirect_function (backtrace_function (pdl), Qt)))
3440 pdl = backtrace_next (pdl);
3441 }
3442
3443 /* Find the frame requested. */
3444 for (i = XFASTINT (nframes); i > 0 && backtrace_p (pdl); i--)
3445 pdl = backtrace_next (pdl);
3446
3447 return pdl;
3448}
3449
3450DEFUN ("backtrace-frame", Fbacktrace_frame, Sbacktrace_frame, 1, 2, NULL,
3426 doc: /* Return the function and arguments NFRAMES up from current execution point. 3451 doc: /* Return the function and arguments NFRAMES up from current execution point.
3427If that frame has not evaluated the arguments yet (or is a special form), 3452If that frame has not evaluated the arguments yet (or is a special form),
3428the value is (nil FUNCTION ARG-FORMS...). 3453the value is (nil FUNCTION ARG-FORMS...).
@@ -3431,17 +3456,12 @@ the value is (t FUNCTION ARG-VALUES...).
3431A &rest arg is represented as the tail of the list ARG-VALUES. 3456A &rest arg is represented as the tail of the list ARG-VALUES.
3432FUNCTION is whatever was supplied as car of evaluated list, 3457FUNCTION is whatever was supplied as car of evaluated list,
3433or a lambda expression for macro calls. 3458or a lambda expression for macro calls.
3434If NFRAMES is more than the number of frames, the value is nil. */) 3459If NFRAMES is more than the number of frames, the value is nil.
3435 (Lisp_Object nframes) 3460If BASE is non-nil, it should be a function and NFRAMES counts from its
3461nearest activation frame. */)
3462 (Lisp_Object nframes, Lisp_Object base)
3436{ 3463{
3437 union specbinding *pdl = backtrace_top (); 3464 union specbinding *pdl = get_backtrace_frame (nframes, base);
3438 register EMACS_INT i;
3439
3440 CHECK_NATNUM (nframes);
3441
3442 /* Find the frame requested. */
3443 for (i = 0; backtrace_p (pdl) && i < XFASTINT (nframes); i++)
3444 pdl = backtrace_next (pdl);
3445 3465
3446 if (!backtrace_p (pdl)) 3466 if (!backtrace_p (pdl))
3447 return Qnil; 3467 return Qnil;
@@ -3456,6 +3476,109 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3456 } 3476 }
3457} 3477}
3458 3478
3479/* For backtrace-eval, we want to temporarily unwind the last few elements of
3480 the specpdl stack, and then rewind them. We store the pre-unwind values
3481 directly in the pre-existing specpdl elements (i.e. we swap the current
3482 value and the old value stored in the specpdl), kind of like the inplace
3483 pointer-reversal trick. As it turns out, the rewind does the same as the
3484 unwind, except it starts from the other end of the specpdl stack, so we use
3485 the same function for both unwind and rewind. */
3486static void
3487backtrace_eval_unrewind (int distance)
3488{
3489 union specbinding *tmp = specpdl_ptr;
3490 int step = -1;
3491 if (distance < 0)
3492 { /* It's a rewind rather than unwind. */
3493 tmp += distance - 1;
3494 step = 1;
3495 distance = -distance;
3496 }
3497
3498 for (; distance > 0; distance--)
3499 {
3500 tmp += step;
3501 /* */
3502 switch (tmp->kind)
3503 {
3504 /* FIXME: Ideally we'd like to "temporarily unwind" (some of) those
3505 unwind_protect, but the problem is that we don't know how to
3506 rewind them afterwards. */
3507 case SPECPDL_UNWIND:
3508 case SPECPDL_UNWIND_PTR:
3509 case SPECPDL_UNWIND_INT:
3510 case SPECPDL_UNWIND_VOID:
3511 case SPECPDL_BACKTRACE:
3512 break;
3513 case SPECPDL_LET:
3514 /* If variable has a trivial value (no forwarding), we can
3515 just set it. No need to check for constant symbols here,
3516 since that was already done by specbind. */
3517 if (XSYMBOL (specpdl_symbol (tmp))->redirect
3518 == SYMBOL_PLAINVAL)
3519 {
3520 struct Lisp_Symbol *sym = XSYMBOL (specpdl_symbol (tmp));
3521 Lisp_Object old_value = specpdl_old_value (tmp);
3522 set_specpdl_old_value (tmp, SYMBOL_VAL (sym));
3523 SET_SYMBOL_VAL (sym, old_value);
3524 break;
3525 }
3526 else
3527 {
3528 /* FALLTHROUGH!
3529 NOTE: we only ever come here if make_local_foo was used for
3530 the first time on this var within this let. */
3531 }
3532 case SPECPDL_LET_DEFAULT:
3533 {
3534 Lisp_Object sym = specpdl_symbol (tmp);
3535 Lisp_Object old_value = specpdl_old_value (tmp);
3536 set_specpdl_old_value (tmp, Fdefault_value (sym));
3537 Fset_default (sym, old_value);
3538 }
3539 break;
3540 case SPECPDL_LET_LOCAL:
3541 {
3542 Lisp_Object symbol = specpdl_symbol (tmp);
3543 Lisp_Object where = specpdl_where (tmp);
3544 Lisp_Object old_value = specpdl_old_value (tmp);
3545 eassert (BUFFERP (where));
3546
3547 /* If this was a local binding, reset the value in the appropriate
3548 buffer, but only if that buffer's binding still exists. */
3549 if (!NILP (Flocal_variable_p (symbol, where)))
3550 {
3551 set_specpdl_old_value
3552 (tmp, Fbuffer_local_value (symbol, where));
3553 set_internal (symbol, old_value, where, 1);
3554 }
3555 }
3556 break;
3557 }
3558 }
3559}
3560
3561DEFUN ("backtrace-eval", Fbacktrace_eval, Sbacktrace_eval, 2, 3, NULL,
3562 doc: /* Evaluate EXP in the context of some activation frame.
3563NFRAMES and BASE specify the activation frame to use, as in `backtrace-frame'. */)
3564 (Lisp_Object exp, Lisp_Object nframes, Lisp_Object base)
3565{
3566 union specbinding *pdl = get_backtrace_frame (nframes, base);
3567 ptrdiff_t count = SPECPDL_INDEX ();
3568 ptrdiff_t distance = specpdl_ptr - pdl;
3569 eassert (distance >= 0);
3570
3571 if (!backtrace_p (pdl))
3572 error ("Activation frame not found!");
3573
3574 backtrace_eval_unrewind (distance);
3575 record_unwind_protect_int (backtrace_eval_unrewind, -distance);
3576
3577 /* Use eval_sub rather than Feval since the main motivation behind
3578 backtrace-eval is to be able to get/set the value of lexical variables
3579 from the debugger. */
3580 return unbind_to (count, eval_sub (exp));
3581}
3459 3582
3460void 3583void
3461mark_specpdl (void) 3584mark_specpdl (void)
@@ -3701,6 +3824,7 @@ alist of active lexical bindings. */);
3701 defsubr (&Sbacktrace_debug); 3824 defsubr (&Sbacktrace_debug);
3702 defsubr (&Sbacktrace); 3825 defsubr (&Sbacktrace);
3703 defsubr (&Sbacktrace_frame); 3826 defsubr (&Sbacktrace_frame);
3827 defsubr (&Sbacktrace_eval);
3704 defsubr (&Sspecial_variable_p); 3828 defsubr (&Sspecial_variable_p);
3705 defsubr (&Sfunctionp); 3829 defsubr (&Sfunctionp);
3706} 3830}
diff --git a/src/fileio.c b/src/fileio.c
index a19fcd9f663..c47b3533145 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3860,7 +3860,8 @@ by calling `format-decode', which see. */)
3860 if (same_at_start - BEGV_BYTE == end_offset - beg_offset) 3860 if (same_at_start - BEGV_BYTE == end_offset - beg_offset)
3861 { 3861 {
3862 emacs_close (fd); 3862 emacs_close (fd);
3863 specpdl_ptr--; 3863 clear_unwind_protect (fd_index);
3864
3864 /* Truncate the buffer to the size of the file. */ 3865 /* Truncate the buffer to the size of the file. */
3865 del_range_1 (same_at_start, same_at_end, 0, 0); 3866 del_range_1 (same_at_start, same_at_end, 0, 0);
3866 goto handled; 3867 goto handled;
diff --git a/src/fns.c b/src/fns.c
index 9fd0ad2a9d1..6f81635ab9d 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -146,8 +146,6 @@ To get the number of bytes, use `string-bytes'. */)
146 return val; 146 return val;
147} 147}
148 148
149/* This does not check for quits. That is safe since it must terminate. */
150
151DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0, 149DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0,
152 doc: /* Return the length of a list, but avoid error or infinite loop. 150 doc: /* Return the length of a list, but avoid error or infinite loop.
153This function never gets an error. If LIST is not really a list, 151This function never gets an error. If LIST is not really a list,
diff --git a/src/frame.c b/src/frame.c
index 5fa54052cd2..95f53569561 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1157,10 +1157,14 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
1157 1157
1158 FOR_EACH_FRAME (frames, this) 1158 FOR_EACH_FRAME (frames, this)
1159 { 1159 {
1160 if (! EQ (this, frame) 1160 Lisp_Object fminiw;
1161 && EQ (frame, 1161
1162 WINDOW_FRAME (XWINDOW 1162 if (EQ (this, frame))
1163 (FRAME_MINIBUF_WINDOW (XFRAME (this)))))) 1163 continue;
1164
1165 fminiw = FRAME_MINIBUF_WINDOW (XFRAME (this));
1166
1167 if (WINDOWP (fminiw) && EQ (frame, WINDOW_FRAME (XWINDOW (fminiw))))
1164 { 1168 {
1165 /* If we MUST delete this frame, delete the other first. 1169 /* If we MUST delete this frame, delete the other first.
1166 But do this only if FORCE equals `noelisp'. */ 1170 But do this only if FORCE equals `noelisp'. */
diff --git a/src/nsterm.m b/src/nsterm.m
index 61538798337..14706f6b91d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4473,9 +4473,9 @@ ns_term_shutdown (int sig)
4473 4473
4474#ifdef NS_IMPL_COCOA 4474#ifdef NS_IMPL_COCOA
4475 /* If no dialog and none of our frames have focus and it is a move, skip it. 4475 /* If no dialog and none of our frames have focus and it is a move, skip it.
4476 It is a mouse move in an auxillary menu, i.e. on the top right on OSX, 4476 It is a mouse move in an auxiliary menu, i.e. on the top right on OSX,
4477 such as Wifi, sound, date or similar. 4477 such as Wifi, sound, date or similar.
4478 This prevents "spooky" highlightning in the frame under the menu. */ 4478 This prevents "spooky" highlighting in the frame under the menu. */
4479 if (type == NSMouseMoved && [NSApp modalWindow] == nil) 4479 if (type == NSMouseMoved && [NSApp modalWindow] == nil)
4480 { 4480 {
4481 struct ns_display_info *di; 4481 struct ns_display_info *di;
diff --git a/src/process.c b/src/process.c
index 34783fae5fd..d87a1803fe2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1330,7 +1330,7 @@ Returns nil if format of ADDRESS is invalid. */)
1330} 1330}
1331 1331
1332DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0, 1332DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0,
1333 doc: /* Return a list of all processes. */) 1333 doc: /* Return a list of all processes that are Emacs sub-processes. */)
1334 (void) 1334 (void)
1335{ 1335{
1336 return Fmapcar (Qcdr, Vprocess_alist); 1336 return Fmapcar (Qcdr, Vprocess_alist);
diff --git a/src/w32fns.c b/src/w32fns.c
index 675b716f3b0..2b06936d119 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3213,6 +3213,8 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3213 described by W was deleted, as indicated by its buffer 3213 described by W was deleted, as indicated by its buffer
3214 field being reset to nil. */ 3214 field being reset to nil. */
3215 f = x_window_to_frame (dpyinfo, hwnd); 3215 f = x_window_to_frame (dpyinfo, hwnd);
3216 if (!(f && FRAME_LIVE_P (f)))
3217 break;
3216 w = XWINDOW (FRAME_SELECTED_WINDOW (f)); 3218 w = XWINDOW (FRAME_SELECTED_WINDOW (f));
3217 /* Punt if someone changed the frame's selected window 3219 /* Punt if someone changed the frame's selected window
3218 behind our back. */ 3220 behind our back. */
diff --git a/src/w32term.c b/src/w32term.c
index 2fe3fe07462..a596a487f3d 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4360,8 +4360,9 @@ w32_read_socket (struct terminal *terminal,
4360 SET_FRAME_VISIBLE (f, 1); 4360 SET_FRAME_VISIBLE (f, 1);
4361 SET_FRAME_ICONIFIED (f, 0); 4361 SET_FRAME_ICONIFIED (f, 0);
4362 SET_FRAME_GARBAGED (f); 4362 SET_FRAME_GARBAGED (f);
4363 DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f, 4363 if (!f->output_data.w32->asked_for_visible)
4364 SDATA (f->name))); 4364 DebPrint (("frame %p (%s) reexposed by WM_PAINT\n", f,
4365 SDATA (f->name)));
4365 4366
4366 /* WM_PAINT serves as MapNotify as well, so report 4367 /* WM_PAINT serves as MapNotify as well, so report
4367 visibility changes properly. */ 4368 visibility changes properly. */
@@ -4819,7 +4820,8 @@ w32_read_socket (struct terminal *terminal,
4819 { 4820 {
4820 bool iconified = FRAME_ICONIFIED_P (f); 4821 bool iconified = FRAME_ICONIFIED_P (f);
4821 4822
4822 SET_FRAME_VISIBLE (f, 1); 4823 if (iconified)
4824 SET_FRAME_VISIBLE (f, 1);
4823 SET_FRAME_ICONIFIED (f, 0); 4825 SET_FRAME_ICONIFIED (f, 0);
4824 4826
4825 /* wait_reading_process_output will notice this 4827 /* wait_reading_process_output will notice this
@@ -4921,16 +4923,11 @@ w32_read_socket (struct terminal *terminal,
4921 break; 4923 break;
4922 4924
4923 case WM_KILLFOCUS: 4925 case WM_KILLFOCUS:
4926 w32_detect_focus_change (dpyinfo, &msg, &inev);
4924 f = x_top_window_to_frame (dpyinfo, msg.msg.hwnd); 4927 f = x_top_window_to_frame (dpyinfo, msg.msg.hwnd);
4925 4928
4926 if (f) 4929 if (f)
4927 { 4930 {
4928 if (f == dpyinfo->w32_focus_event_frame)
4929 dpyinfo->w32_focus_event_frame = 0;
4930
4931 if (f == dpyinfo->w32_focus_frame)
4932 x_new_focus_frame (dpyinfo, 0);
4933
4934 if (f == hlinfo->mouse_face_mouse_frame) 4931 if (f == hlinfo->mouse_face_mouse_frame)
4935 { 4932 {
4936 /* If we move outside the frame, then we're 4933 /* If we move outside the frame, then we're
@@ -6129,6 +6126,9 @@ x_iconify_frame (struct frame *f)
6129 /* Simulate the user minimizing the frame. */ 6126 /* Simulate the user minimizing the frame. */
6130 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MINIMIZE, 0); 6127 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MINIMIZE, 0);
6131 6128
6129 SET_FRAME_VISIBLE (f, 0);
6130 SET_FRAME_ICONIFIED (f, 1);
6131
6132 unblock_input (); 6132 unblock_input ();
6133} 6133}
6134 6134
diff --git a/src/xterm.c b/src/xterm.c
index 74e495e5645..b3534871da9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3435,17 +3435,10 @@ x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct fra
3435 /* Don't stop displaying the initial startup message 3435 /* Don't stop displaying the initial startup message
3436 for a switch-frame event we don't need. */ 3436 for a switch-frame event we don't need. */
3437 /* When run as a daemon, Vterminal_frame is always NIL. */ 3437 /* When run as a daemon, Vterminal_frame is always NIL. */
3438 if ((NILP (Vterminal_frame) || EQ (Fdaemonp(), Qt)) 3438 bufp->arg = (((NILP (Vterminal_frame) || EQ (Fdaemonp (), Qt))
3439 && CONSP (Vframe_list) 3439 && CONSP (Vframe_list)
3440 && !NILP (XCDR (Vframe_list))) 3440 && !NILP (XCDR (Vframe_list)))
3441 { 3441 ? Qt : Qnil);
3442 bufp->arg = Qt;
3443 }
3444 else
3445 {
3446 bufp->arg = Qnil;
3447 }
3448
3449 bufp->kind = FOCUS_IN_EVENT; 3442 bufp->kind = FOCUS_IN_EVENT;
3450 XSETFRAME (bufp->frame_or_window, frame); 3443 XSETFRAME (bufp->frame_or_window, frame);
3451 } 3444 }