From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.bugs Subject: bug#3303: delete-frame raises old (invisible) frame Date: Thu, 21 May 2009 23:57:08 -0400 Message-ID: <513F6DDF-F57F-4C8E-A2ED-C2163183BFF0@cmu.edu> Reply-To: David Reitter , 3303@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v935.3) Content-Type: multipart/signed; boundary=Apple-Mail-31-516940623; micalg=sha1; protocol="application/pkcs7-signature" X-Trace: ger.gmane.org 1242973500 8083 80.91.229.12 (22 May 2009 06:25:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 May 2009 06:25:00 +0000 (UTC) Cc: Chong Yidong , Adrian Robert To: 3303@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 22 08:24:52 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M7OBX-0002eg-JR for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 May 2009 08:24:52 +0200 Original-Received: from localhost ([127.0.0.1]:33721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7OBW-0004Rc-Te for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 May 2009 02:24:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M7M74-000796-U5 for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 00:12:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M7M6z-00076P-8d for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 00:12:06 -0400 Original-Received: from [199.232.76.173] (port=47518 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M7M6z-000763-1I for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 00:12:01 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:46767) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M7M6y-00034u-DO for bug-gnu-emacs@gnu.org; Fri, 22 May 2009 00:12:00 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n4M4Bv2r031773; Thu, 21 May 2009 21:11:58 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n4M455iF029166; Thu, 21 May 2009 21:05:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: David Reitter Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 22 May 2009 04:05:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 3303 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 3303-submit@emacsbugs.donarmstrong.com id=B3303.124296464126894 (code B ref 3303); Fri, 22 May 2009 04:05:05 +0000 Original-Received: (at 3303) by emacsbugs.donarmstrong.com; 22 May 2009 03:57:21 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from smtp.andrew.cmu.edu (SMTP.ANDREW.CMU.EDU [128.2.11.61]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n4M3vGnv026876 for <3303@emacsbugs.donarmstrong.com>; Thu, 21 May 2009 20:57:18 -0700 Original-Received: from [192.168.1.42] (pool-71-162-19-47.pitbpa.east.verizon.net [71.162.19.47]) (user=reitter mech=PLAIN (0 bits)) by smtp.andrew.cmu.edu (8.14.3/8.13.8) with ESMTP id n4M3v91H024519 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 21 May 2009 23:57:10 -0400 X-Mailer: Apple Mail (2.935.3) X-PMX-Version: 5.5.5.374460, Antispam-Engine: 2.7.1.369594, Antispam-Data: 2009.5.22.33435 X-SMTP-Spam-Clean: 10% ( CTYPE_MULTIPART_NO_QUOTE 0.5, FROM_EDU_TLD 0, RDNS_GENERIC_POOLED 0, RDNS_POOLED 0, RDNS_SUSP 0, RDNS_SUSP_GENERIC 0, RDNS_SUSP_SPECIFIC 0, TO_NO_NAME 0, __BOUNCE_CHALLENGE_SUBJ 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_VERSION 0, __MSGID_APPLEMAIL 0, __RDNS_POOLED_9 0, __SANE_MSGID 0, __TO_MALFORMED_2 0) X-SMTP-Spam-Score: 10% X-Scanned-By: MIMEDefang 2.60 on 128.2.11.61 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Fri, 22 May 2009 00:12:05 -0400 X-Mailman-Approved-At: Fri, 22 May 2009 02:24:38 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:28086 Archived-At: --Apple-Mail-31-516940623 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit OK, I think I have a set of fixes now for this bug. The problems included swallowed events, setting async_visible and async_iconified from drawRect under the false assumption that this proves that the frame view is visible, and attendant failure to set visibility correctly when creating the frame (as the other ports, including Appkit, do). Also, we separate visibility from frame order in the NS layer. Description, test cases and patch below. Can someone look this over to see if there is anything obviously wrong? I'll check it in pending feedback. - David PS.: I agree with the proposed change to after-make-frame-functions (not selecting the frame immediately), but this doesn't relate to the bug at hand. Also, I don't know why the modeline isn't updated. Desc: frame.c: Fraise_frame: do not make invisible frames visible (Stefan Monnier). nsterm.m: ns_raise_frame(): only raise frame if visible. x_make_frame_visible(): move frame to front rather than calling ns_raise_frame(). keyDown: do not swallow events that aren't re-sent if frame isn't key window. drawRect: do not set visibility/iconified flags because drawRect may be called by NSView even if the frame is hidden. nsfns.m: Fx_create_frame(): follow other ports in determining visibility; default to t. Ensure async_visible is set. Test cases: ;; test case ;; second time around aaa is t (let ((f (selected-frame))) (make-frame-invisible f t) (setq aa2v (frame-visible-p f)) (redisplay) (setq aa3v (frame-visible-p f)) ) ;; frame should be gone (list aa2v aa3v) ;; should be nil nil ;; test case (progn (make-frame-invisible (selected-frame) t) (select-frame (make-frame)) (delete-frame (selected-frame) t) (select-frame (make-frame)) (sit-for 0) (delete-frame (selected-frame) t)) ;; there should be no frame Patch: diff --git a/src/frame.c b/src/frame.c index afcc96c..fbb00ba 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2024,7 +2024,7 @@ doesn't support multiple overlapping frames, this function selects FRAME. */) if (FRAME_TERMCAP_P (f)) /* On a text-only terminal select FRAME. */ Fselect_frame (frame, Qnil); - else + else if (FRAME_ICONIFIED_P (f)) /* Do like the documentation says. */ Fmake_frame_visible (frame); diff --git a/src/nsfns.m b/src/nsfns.m index 01ffcf1..25d9b30 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1317,13 +1317,20 @@ be shared by the new frame. */) if (! f->output_data.ns->explicit_parent) { - tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_BOOLEAN); - if (EQ (tem, Qunbound)) - tem = Qnil; - - x_set_visibility (f, tem, Qnil); - if (EQ (tem, Qt)) - [[FRAME_NS_VIEW (f) window] makeKeyWindow]; + tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL); + if (EQ (tem, Qunbound)) + tem = Qt; + x_set_visibility (f, tem, Qnil); + if (EQ (tem, Qicon)) + x_iconify_frame (f); + else if (! NILP (tem)) + { + x_make_frame_visible (f); + f->async_visible=1; + [[FRAME_NS_VIEW (f) window] makeKeyWindow]; + } + else + f->async_visible=0; } if (FRAME_HAS_MINIBUF_P (f) diff --git a/src/nsterm.m b/src/nsterm.m index 9ca74e8..d7a8f81 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -895,9 +895,14 @@ ns_raise_frame (struct frame *f) { NSView *view = FRAME_NS_VIEW (f); check_ns (); - BLOCK_INPUT; - [[view window] makeKeyAndOrderFront: NSApp]; - UNBLOCK_INPUT; + + FRAME_SAMPLE_VISIBILITY (f); + if (FRAME_VISIBLE_P (f)) + { + BLOCK_INPUT; + [[view window] makeKeyAndOrderFront: NSApp]; + UNBLOCK_INPUT; + } } @@ -979,11 +984,17 @@ x_make_frame_visible (struct frame *f) -------------------------------------------------------------------------- */ { NSTRACE (x_make_frame_visible); + NSView *view = FRAME_NS_VIEW (f); /* XXX: at some points in past this was not needed, as the only place that called this (frame.c:Fraise_frame ()) also called raise_lower; if this ends up the case again, comment this out again. */ if (!FRAME_VISIBLE_P (f)) - ns_raise_frame (f); + { + BLOCK_INPUT; + [[view window] makeKeyAndOrderFront: NSApp]; + UNBLOCK_INPUT; + } + f->async_visible = 1; } @@ -4461,7 +4472,8 @@ extern void update_window_cursor (struct window *w, int on); if (!emacs_event) return; - if (![[self window] isKeyWindow]) + if (![[self window] isKeyWindow] + && [[theEvent window] isKindOfClass: [EmacsWindow class]]) { /* XXX: There is an occasional condition in which, when Emacs display updates a different frame from the current one, and temporarily @@ -4469,8 +4481,7 @@ extern void update_window_cursor (struct window *w, int on); (dispnew.c:3878), OS will send the event to the correct NSWindow, but for some reason that window has its first responder set to the NSView most recently updated (I guess), which is not the correct one. */ - if ([[theEvent window] isKindOfClass: [EmacsWindow class]]) - [(EmacsView *)[[theEvent window] delegate] keyDown: theEvent]; + [(EmacsView *)[[theEvent window] delegate] keyDown: theEvent]; return; } @@ -5466,8 +5477,6 @@ extern void update_window_cursor (struct window *w, int on); ns_clear_frame_area (emacsframe, x, y, width, height); expose_frame (emacsframe, x, y, width, height); - emacsframe->async_visible = 1; - emacsframe->async_iconified = 0; } --Apple-Mail-31-516940623 Content-Disposition: attachment; filename=smime.p7s Content-Type: application/pkcs7-signature; name=smime.p7s Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGODCCAvEw ggJaoAMCAQICEEUTODS9VcXIOFaPH+ApeTwwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA4MDgyNzAwMzgxNloXDTA5MDgyNzAwMzgx NlowWjEQMA4GA1UEBBMHUmVpdHRlcjEOMAwGA1UEKhMFRGF2aWQxFjAUBgNVBAMTDURhdmlkIFJl aXR0ZXIxHjAcBgkqhkiG9w0BCQEWD3JlaXR0ZXJAY211LmVkdTCCASIwDQYJKoZIhvcNAQEBBQAD ggEPADCCAQoCggEBAJW3Pr3O1TOI9MTahUDKcJkkoZQOmnQVYtchDAALotmkjxNO/wC2b+CiDGGg +8TbJ/EwdMD2IOh1TilL/SXKk2txTgduV5yBrYXk04z1cGxNcCCTRiSZY1A5I3rvnP2jhUf8I49O WXFs8v8XvcJ0o1wFoPITU7b9KBLg22kl+DqNuj10fCLQldlNfe4o5PX/TWFE/NqI+//Ooehr+5hY B1XtAXQXU3/DC6M8l6Sqsm0vw5OO44K7KceG85zQchZ60LOJnGWA2UKcfNTIZGr18LUJMdl6kiU2 TEwy1H/3JAOMmekIbiQ7AWDiVYlkY6QUXBmgAPizQ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