emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 0f24ad7 1/2: Add no-focus-on-map to NS build (bug#2


From: Alan Third
Subject: [Emacs-diffs] master 0f24ad7 1/2: Add no-focus-on-map to NS build (bug#25408)
Date: Mon, 12 Jun 2017 13:52:45 -0400 (EDT)

branch: master
commit 0f24ad7b81b5f5920f165ada06490cea5194b109
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    Add no-focus-on-map to NS build (bug#25408)
    
    * src/nsfns.m (ns_frame_parm_handlers): Add x_set_no_focus_on_map.
    (x-create-frame): Check for no-focus-on-map.
    * src/nsterm.h (x_set_no_focus_on_map): New function.
    * src/nsterm.m (x_set_no_focus_on_map): New function.
    (ns_raise_frame): Add parameter for specifying whether to focus the
    frame.
    (ns_frame_raise_lower):
    (x_make_frame_visible): Handle new parameter for ns_raise_frame.
---
 src/nsfns.m  |  4 +++-
 src/nsterm.h |  2 ++
 src/nsterm.m | 33 ++++++++++++++++++++++++++++-----
 3 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/nsfns.m b/src/nsfns.m
index 0c86507..dbce279 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -980,7 +980,7 @@ frame_parm_handler ns_frame_parm_handlers[] =
 #endif
   x_set_parent_frame,
   0, /* x_set_skip_taskbar */
-  0, /* x_set_no_focus_on_map */
+  x_set_no_focus_on_map,
   x_set_no_accept_focus,
   x_set_z_group, /* x_set_z_group */
   0, /* x_set_override_redirect */
@@ -1288,6 +1288,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   store_frame_param (f, Qparent_frame, parent_frame);
 
   x_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL);
+  x_default_parameter (f, parms, Qno_focus_on_map, Qnil,
+                      NULL, NULL, RES_TYPE_BOOLEAN);
   x_default_parameter (f, parms, Qno_accept_focus, Qnil,
                        NULL, NULL, RES_TYPE_BOOLEAN);
 
diff --git a/src/nsterm.h b/src/nsterm.h
index f75e375..bed0b92 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1218,6 +1218,8 @@ extern void x_set_undecorated (struct frame *f, 
Lisp_Object new_value,
                                Lisp_Object old_value);
 extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value,
                                 Lisp_Object old_value);
+extern void x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
+                                   Lisp_Object old_value);
 extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
                                    Lisp_Object old_value);
 extern void x_set_z_group (struct frame *f, Lisp_Object new_value,
diff --git a/src/nsterm.m b/src/nsterm.m
index 633ca3b..e05dbf4 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1463,9 +1463,9 @@ hide_bell (void)
 
 
 static void
-ns_raise_frame (struct frame *f)
+ns_raise_frame (struct frame *f, BOOL make_key)
 /* --------------------------------------------------------------------------
-     Bring window to foreground and make it active
+     Bring window to foreground and if make_key is YES, give it focus.
    -------------------------------------------------------------------------- 
*/
 {
   NSView *view;
@@ -1474,7 +1474,12 @@ ns_raise_frame (struct frame *f)
   view = FRAME_NS_VIEW (f);
   block_input ();
   if (FRAME_VISIBLE_P (f))
-    [[view window] makeKeyAndOrderFront: NSApp];
+    {
+      if (make_key)
+        [[view window] makeKeyAndOrderFront: NSApp];
+      else
+        [[view window] orderFront: NSApp];
+    }
   unblock_input ();
 }
 
@@ -1504,7 +1509,7 @@ ns_frame_raise_lower (struct frame *f, bool raise)
   NSTRACE ("ns_frame_raise_lower");
 
   if (raise)
-    ns_raise_frame (f);
+    ns_raise_frame (f, YES);
   else
     ns_lower_frame (f);
 }
@@ -1567,7 +1572,7 @@ x_make_frame_visible (struct frame *f)
       EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
 
       SET_FRAME_VISIBLE (f, 1);
-      ns_raise_frame (f);
+      ns_raise_frame (f, ! FRAME_NO_FOCUS_ON_MAP (f));
 
       /* Making a new frame from a fullscreen frame will make the new frame
          fullscreen also.  So skip handleFS as this will print an error.  */
@@ -1927,6 +1932,24 @@ x_set_parent_frame (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 }
 
 void
+x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+/* Set frame F's `no-focus-on-map' parameter which, if non-nil, means
+ * that F's window-system window does not want to receive input focus
+ * when it is mapped.  (A frame's window is mapped when the frame is
+ * displayed for the first time and when the frame changes its state
+ * from `iconified' or `invisible' to `visible'.)
+ *
+ * Some window managers may not honor this parameter. */
+{
+  NSTRACE ("x_set_no_focus_on_map");
+
+  if (!EQ (new_value, old_value))
+    {
+      FRAME_NO_FOCUS_ON_MAP (f) = !NILP (new_value);
+    }
+}
+
+void
 x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 /*  Set frame F's `no-accept-focus' parameter which, if non-nil, hints
  * that F's window-system window does not want to receive input focus



reply via email to

[Prev in Thread] Current Thread [Next in Thread]