summaryrefslogtreecommitdiff
path: root/src/nsfns.m
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2022-03-06 10:43:25 +0800
committerPo Lu <luangruo@yahoo.com>2022-03-06 10:43:25 +0800
commite09bbfc37d81d58af3412ae1b56dc2e620218653 (patch)
tree347ec2352781cc8d5ae2c0a9a00042c8035e8075 /src/nsfns.m
parentdb2cb522e154ce97b7a780572d2cb99d82d291ca (diff)
downloademacs-e09bbfc37d81d58af3412ae1b56dc2e620218653.tar.gz
emacs-e09bbfc37d81d58af3412ae1b56dc2e620218653.tar.bz2
emacs-e09bbfc37d81d58af3412ae1b56dc2e620218653.zip
Implement "window cascading" on NS
* src/nsfns.m (Fx_create_frame): Cascade new frame position if size hint flags are not USPosition or PPosition.
Diffstat (limited to 'src/nsfns.m')
-rw-r--r--src/nsfns.m22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/nsfns.m b/src/nsfns.m
index 1900616b9de..6256bd220dd 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1112,6 +1112,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
Lisp_Object parent, parent_frame;
struct kboard *kb;
static int desc_ctr = 1;
+ NSWindow *main_window = [NSApp mainWindow];
/* gui_display_get_arg modifies parms. */
parms = Fcopy_alist (parms);
@@ -1483,8 +1484,27 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
- if (window_prompting & USPosition)
+ /* This cascading behavior (which is the job of the window manager
+ on X-based systems) is something NS applications are expected to
+ implement themselves. At least one person tells me he used
+ Carbon Emacs solely for this behavior. */
+ if (window_prompting & (USPosition | PPosition) || FRAME_PARENT_FRAME (f))
ns_set_offset (f, f->left_pos, f->top_pos, 1);
+ else
+ {
+ NSWindow *frame_window = [FRAME_NS_VIEW (f) window];
+ NSPoint top_left;
+
+ if (main_window)
+ {
+ top_left = NSMakePoint (NSMinX ([main_window frame]),
+ NSMaxY ([main_window frame]));
+ top_left = [frame_window cascadeTopLeftFromPoint: top_left];
+ [frame_window cascadeTopLeftFromPoint: top_left];
+ }
+ else
+ [main_window center];
+ }
/* Make sure windows on this frame appear in calls to next-window
and similar functions. */