aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2017-04-20 15:25:56 +0100
committerAlan Third2017-04-21 20:44:35 +0100
commitd812d20fbc3e1eff0f10443baed801adda9031cd (patch)
tree184f53fd04d4b5cae0bfe5297bd904043e9db3b9 /src
parenta3b8618d79657af0d7fea9cb6fd914ccf0f67849 (diff)
downloademacs-d812d20fbc3e1eff0f10443baed801adda9031cd.tar.gz
emacs-d812d20fbc3e1eff0f10443baed801adda9031cd.zip
Add no-accept-focus and frame-list-z-order to NS port
* lisp/frame.el (frame-list-z-order): Add NS. * src/nsfns.m: Add x_set_no_accept_focus to handler struct. (Fx_create_frame): Handle no-accept-focus parameter. (ns_window_is_ancestor): (Fns_frame_list_z_order): New functions. * src/nsterm.m (x_set_no_accept_focus): New function. (initFrameFromEmacs): Use EmacsWindow instead of EmacsFSWindow for non-fullscreen windows. (EmacsWindow:canBecomeKeyWindow): New function.
Diffstat (limited to 'src')
-rw-r--r--src/nsfns.m61
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m22
3 files changed, 81 insertions, 4 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index f1a5df8f27e..3a37df95759 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -973,14 +973,14 @@ frame_parm_handler ns_frame_parm_handlers[] =
973 0, /* x_set_tool_bar_position */ 973 0, /* x_set_tool_bar_position */
974 0, /* x_set_inhibit_double_buffering */ 974 0, /* x_set_inhibit_double_buffering */
975#ifdef NS_IMPL_COCOA 975#ifdef NS_IMPL_COCOA
976 x_set_undecorated, /* x_set_undecorated */ 976 x_set_undecorated,
977#else 977#else
978 0, /*x_set_undecorated */ 978 0, /*x_set_undecorated */
979#endif 979#endif
980 x_set_parent_frame, /* x_set_parent_frame */ 980 x_set_parent_frame,
981 0, /* x_set_skip_taskbar */ 981 0, /* x_set_skip_taskbar */
982 0, /* x_set_no_focus_on_map */ 982 0, /* x_set_no_focus_on_map */
983 0, /* x_set_no_accept_focus */ 983 x_set_no_accept_focus,
984 x_set_z_group, /* x_set_z_group */ 984 x_set_z_group, /* x_set_z_group */
985 0, /* x_set_override_redirect */ 985 0, /* x_set_override_redirect */
986}; 986};
@@ -1287,6 +1287,8 @@ This function is an internal primitive--use `make-frame' instead. */)
1287 store_frame_param (f, Qparent_frame, parent_frame); 1287 store_frame_param (f, Qparent_frame, parent_frame);
1288 1288
1289 x_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL); 1289 x_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL);
1290 x_default_parameter (f, parms, Qno_accept_focus, Qnil,
1291 NULL, NULL, RES_TYPE_BOOLEAN);
1290 1292
1291 /* The resources controlling the menu-bar and tool-bar are 1293 /* The resources controlling the menu-bar and tool-bar are
1292 processed specially at startup, and reflected in the mode 1294 processed specially at startup, and reflected in the mode
@@ -1428,6 +1430,58 @@ x_focus_frame (struct frame *f, bool noactivate)
1428 } 1430 }
1429} 1431}
1430 1432
1433static BOOL
1434ns_window_is_ancestor (NSWindow *win, NSWindow *candidate)
1435/* Test whether CANDIDATE is an ancestor window of WIN. */
1436{
1437 if (candidate == NULL)
1438 return NO;
1439 else if (win == candidate)
1440 return YES;
1441 else
1442 return ns_window_is_ancestor(win, [candidate parentWindow]);
1443}
1444
1445DEFUN ("ns-frame-list-z-order", Fns_frame_list_z_order,
1446 Sns_frame_list_z_order, 0, 1, 0,
1447 doc: /* Return list of Emacs' frames, in Z (stacking) order.
1448The optional argument TERMINAL specifies which display to ask about.
1449TERMINAL should be either a frame or a display name (a string). If
1450omitted or nil, that stands for the selected frame's display. Return
1451nil if TERMINAL contains no Emacs frame.
1452
1453As a special case, if TERMINAL is non-nil and specifies a live frame,
1454return the child frames of that frame in Z (stacking) order.
1455
1456Frames are listed from topmost (first) to bottommost (last). */)
1457 (Lisp_Object terminal)
1458{
1459 NSArray *list = [NSApp orderedWindows];
1460 Lisp_Object frames = Qnil;
1461
1462 if (FRAMEP (terminal) && FRAME_LIVE_P (XFRAME (terminal)))
1463 {
1464 /* Filter LIST to just those that are ancestors of TERMINAL. */
1465 NSWindow *win = [FRAME_NS_VIEW (XFRAME (terminal)) window];
1466
1467 NSPredicate *ancestor_pred =
1468 [NSPredicate predicateWithBlock:^BOOL(id candidate, NSDictionary *bind) {
1469 return ns_window_is_ancestor (win, [(NSWindow *)candidate parentWindow]);
1470 }];
1471
1472 list = [[NSApp orderedWindows] filteredArrayUsingPredicate: ancestor_pred];
1473 }
1474
1475 for (NSWindow *win in [list reverseObjectEnumerator])
1476 {
1477 Lisp_Object frame;
1478 XSETFRAME (frame, ((EmacsView *)[win delegate])->emacsframe);
1479 frames = Fcons(frame, frames);
1480 }
1481
1482 return frames;
1483}
1484
1431DEFUN ("ns-frame-restack", Fns_frame_restack, Sns_frame_restack, 2, 3, 0, 1485DEFUN ("ns-frame-restack", Fns_frame_restack, Sns_frame_restack, 2, 3, 0,
1432 doc: /* Restack FRAME1 below FRAME2. 1486 doc: /* Restack FRAME1 below FRAME2.
1433This means that if both frames are visible and the display areas of 1487This means that if both frames are visible and the display areas of
@@ -3188,6 +3242,7 @@ be used as the image of the icon representing the frame. */);
3188 defsubr (&Sns_display_monitor_attributes_list); 3242 defsubr (&Sns_display_monitor_attributes_list);
3189 defsubr (&Sns_frame_geometry); 3243 defsubr (&Sns_frame_geometry);
3190 defsubr (&Sns_frame_edges); 3244 defsubr (&Sns_frame_edges);
3245 defsubr (&Sns_frame_list_z_order);
3191 defsubr (&Sns_frame_restack); 3246 defsubr (&Sns_frame_restack);
3192 defsubr (&Sx_display_mm_width); 3247 defsubr (&Sx_display_mm_width);
3193 defsubr (&Sx_display_mm_height); 3248 defsubr (&Sx_display_mm_height);
diff --git a/src/nsterm.h b/src/nsterm.h
index 2f8c4269b0b..9285178d190 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1212,6 +1212,8 @@ extern void x_set_undecorated (struct frame *f, Lisp_Object new_value,
1212 Lisp_Object old_value); 1212 Lisp_Object old_value);
1213extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value, 1213extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value,
1214 Lisp_Object old_value); 1214 Lisp_Object old_value);
1215extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
1216 Lisp_Object old_value);
1215extern void x_set_z_group (struct frame *f, Lisp_Object new_value, 1217extern void x_set_z_group (struct frame *f, Lisp_Object new_value,
1216 Lisp_Object old_value); 1218 Lisp_Object old_value);
1217extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds, 1219extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
diff --git a/src/nsterm.m b/src/nsterm.m
index c53957f9338..4e88297bc04 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1913,6 +1913,21 @@ x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
1913} 1913}
1914 1914
1915void 1915void
1916x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
1917/* Set frame F's `no-accept-focus' parameter which, if non-nil, hints
1918 * that F's window-system window does not want to receive input focus
1919 * via mouse clicks or by moving the mouse into it.
1920 *
1921 * If non-nil, this may have the unwanted side-effect that a user cannot
1922 * scroll a non-selected frame with the mouse.
1923 *
1924 * Some window managers may not honor this parameter. */
1925{
1926 if (!EQ (new_value, old_value))
1927 FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
1928}
1929
1930void
1916x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value) 1931x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
1917/* Set frame F's `z-group' parameter. If `above', F's window-system 1932/* Set frame F's `z-group' parameter. If `above', F's window-system
1918 window is displayed above all windows that do not have the `above' 1933 window is displayed above all windows that do not have the `above'
@@ -6900,7 +6915,7 @@ not_in_argv (NSString *arg)
6900 maximizing_resize = NO; 6915 maximizing_resize = NO;
6901#endif 6916#endif
6902 6917
6903 win = [[EmacsFSWindow alloc] 6918 win = [[EmacsWindow alloc]
6904 initWithContentRect: r 6919 initWithContentRect: r
6905 styleMask: (FRAME_UNDECORATED (f) 6920 styleMask: (FRAME_UNDECORATED (f)
6906 ? NSWindowStyleMaskBorderless 6921 ? NSWindowStyleMaskBorderless
@@ -8130,6 +8145,11 @@ not_in_argv (NSString *arg)
8130 8145
8131 [super setFrameTopLeftPoint:point]; 8146 [super setFrameTopLeftPoint:point];
8132} 8147}
8148
8149- (BOOL)canBecomeKeyWindow
8150{
8151 return !FRAME_NO_ACCEPT_FOCUS (((EmacsView *)[self delegate])->emacsframe);
8152}
8133@end /* EmacsWindow */ 8153@end /* EmacsWindow */
8134 8154
8135 8155