unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Reitter <david.reitter@gmail.com>
To: Adrian Robert <adrian.b.robert@gmail.com>
Cc: 3303@emacsbugs.donarmstrong.com
Subject: bug#3303: delete-frame raises old (invisible) frame
Date: Mon, 18 May 2009 11:08:39 -0400	[thread overview]
Message-ID: <D8610062-2BC2-49E6-9271-02049E2043DC@gmail.com> (raw)
In-Reply-To: <73A0DAB1-9D16-4E35-A9F7-E9E4CCEACC50@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3175 bytes --]

On May 18, 2009, at 4:05 AM, Adrian Robert wrote:

>
> On May 18, 2009, at 10:33 AM, Stefan Monnier wrote:
>
>>> There is no behavior built into the NS window manager to  choose  
>>> another
>>> application window to be active after the active one  has been  
>>> removed --
>>> this is left to application code.
>>
>> [ So, nothing gets focus?  Keyboard events are just dropped on the  
>> floor
>>  in such a case?  Sounds odd: it should be easy for Apple to provide
>>  a sensible default behavior without any negative impact.  ]
>
> Yes, KB events only get sent to a focused window, except for menu  
> shortcut invocations.  It might be that in NSDocument-based apps  
> (which Emacs.app isn't, but would be conceptually similar to if 1- 
> buffer=1-frame) the NSDocument architecture would autofocus the most  
> recently available doc window, but I guess NeXT/Apple decided not to  
> make assumptions otherwise about sensible focus-sequencing.

Precisely for this reason is the patch not sufficient.
When there is a hidden frame, and you delete the only other existing  
frame, we end up in a situation where there is no key window to  
receive the event, and all events (including menu items) are simply  
dropped.

I've experimented with NSWindow's makeKeyWindow, which should leave  
the order of the windows so the frame stays hidden.

However, this alone doesn't do the job.  Events still get dropped when  
you do

(progn
   (make-frame-invisible (selected-frame) t)
   (make-frame)
   (delete-frame (selected-frame) t))


Note that I had to add FRAME_SAMPLE_VISIBILITY compared to the last  
patch I sent.



diff --git a/src/frame.c b/src/frame.c
index de857af..144b8ac 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -778,6 +778,9 @@ affects all frames on the same terminal device.  */)
     is dead.

     The value of NORECORD is passed as argument to Fselect_window.  */
+#ifdef HAVE_NS
+extern  void x_make_key_frame (struct frame *f);
+#endif

  Lisp_Object
  do_switch_frame (frame, track, for_deletion, norecord)
@@ -868,8 +871,12 @@ do_switch_frame (frame, track, for_deletion,  
norecord)

  #ifdef NS_IMPL_COCOA
    /* term gets no other notification of this */
+  FRAME_SAMPLE_VISIBILITY (XFRAME (selected_frame));
    if (for_deletion)
-    Fraise_frame(Qnil);
+    if (FRAME_VISIBLE_P (XFRAME (selected_frame)))
+      Fraise_frame(Qnil);
+    else
+      x_make_key_frame(XFRAME (selected_frame));
  #endif

    /* We want to make sure that the next event generates a frame-switch
diff --git a/src/nsterm.m b/src/nsterm.m
index 7e3028a..0994f7d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -910,6 +910,20 @@ ns_raise_frame (struct frame *f)
  }


+void
+x_make_key_frame (struct frame *f)
+/*  
--------------------------------------------------------------------------
+     Make window active
+    
-------------------------------------------------------------------------- */
+{
+  NSView *view = FRAME_NS_VIEW (f);
+  check_ns ();
+  BLOCK_INPUT;
+  [[view window] makeKeyWindow];
+  UNBLOCK_INPUT;
+}
+
+
  static void
  ns_lower_frame (struct frame *f)
  /*  
--------------------------------------------------------------------------


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2193 bytes --]

  reply	other threads:[~2009-05-18 15:08 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-16  1:09 bug#3303: delete-frame raises old (invisible) frame David Reitter
2009-05-17 19:06 ` Stefan Monnier
2009-05-17 19:12   ` David Reitter
2009-05-17 20:43     ` Stefan Monnier
2009-05-17 22:27       ` Lennart Borgman
2009-05-18  3:26         ` Stefan Monnier
2009-05-18  1:16       ` Adrian Robert
2009-05-18  3:33         ` Stefan Monnier
2009-05-18  8:05           ` Adrian Robert
2009-05-18 15:08             ` David Reitter [this message]
2009-05-18 20:12               ` Stefan Monnier
2009-05-18 23:00                 ` David Reitter
2009-05-19  2:46                   ` Stefan Monnier
2009-05-19  2:56                     ` David Reitter
2009-05-19  3:09                       ` Stefan Monnier
2009-05-19  3:15                         ` David Reitter
2009-05-19  8:20                       ` YAMAMOTO Mitsuharu
2009-05-19 14:30                         ` Stefan Monnier
2009-05-20  2:07                       ` David Reitter
2009-05-19  0:58               ` YAMAMOTO Mitsuharu
2009-05-18  8:19           ` YAMAMOTO Mitsuharu
  -- strict thread matches above, loose matches on Subject: below --
2009-05-16 19:28 Chong Yidong
2009-05-17  2:55 ` David Reitter
2009-05-22  3:57 David Reitter
2009-05-25 15:17 ` Stefan Monnier
2009-05-26 18:20   ` David Reitter
2009-05-26 19:37     ` Stefan Monnier
2009-05-26 20:15       ` David Reitter
2009-05-26 21:30         ` Stefan Monnier
2009-05-27  4:51     ` Adrian Robert
2009-05-27 14:36       ` Stefan Monnier
2009-06-01  9:37         ` Adrian Robert
2009-05-27 15:28       ` David Reitter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D8610062-2BC2-49E6-9271-02049E2043DC@gmail.com \
    --to=david.reitter@gmail.com \
    --cc=3303@emacsbugs.donarmstrong.com \
    --cc=adrian.b.robert@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).