From: Alan Third Date: Sat, 15 Jul 2017 20:57:18 +0000 (+0100) Subject: Fix some frame handling issues on NS X-Git-Tag: emacs-26.0.90~518^2~91 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=30444c695ae4d1184c4b6bc994c00b7b1af5ab4a;p=emacs.git Fix some frame handling issues on NS * lisp/frame.el (mouse-absolute-pixel-position): Use new NS function. * src/nsfns.m (Sns_mouse_absolute_pixel_position): New function. * src/nsterm.m (x_make_frame_visible): Re-establish parent-child relationship if it's broken. --- diff --git a/lisp/frame.el b/lisp/frame.el index 7d571791e23..1af12c70363 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -1494,6 +1494,8 @@ position (0, 0) of the selected frame's terminal." (x-mouse-absolute-pixel-position)) ((eq frame-type 'w32) (w32-mouse-absolute-pixel-position)) + ((eq frame-type 'ns) + (ns-mouse-absolute-pixel-position)) (t (cons 0 0))))) diff --git a/src/nsfns.m b/src/nsfns.m index 68eba8b6a2e..36748cebb8b 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -3080,6 +3080,25 @@ The coordinates X and Y are interpreted in pixels relative to a position return Qnil; } +DEFUN ("ns-mouse-absolute-pixel-position", + Fns_mouse_absolute_pixel_position, + Sns_mouse_absolute_pixel_position, 0, 0, 0, + doc: /* Return absolute position of mouse cursor in pixels. +The position is returned as a cons cell (X . Y) of the +coordinates of the mouse cursor position in pixels relative to a +position (0, 0) of the selected frame's terminal. */) + (void) +{ + struct frame *f = SELECTED_FRAME (); + EmacsView *view = FRAME_NS_VIEW (f); + NSScreen *screen = [[view window] screen]; + NSPoint pt = [NSEvent mouseLocation]; + + return Fcons(make_number(pt.x - screen.frame.origin.x), + make_number(screen.frame.size.height - + (pt.y - screen.frame.origin.y))); +} + /* ========================================================================== Class implementations @@ -3269,6 +3288,7 @@ be used as the image of the icon representing the frame. */); defsubr (&Sns_frame_list_z_order); defsubr (&Sns_frame_restack); defsubr (&Sns_set_mouse_absolute_pixel_position); + defsubr (&Sns_mouse_absolute_pixel_position); defsubr (&Sx_display_mm_width); defsubr (&Sx_display_mm_height); defsubr (&Sx_display_screens); diff --git a/src/nsterm.m b/src/nsterm.m index bf83550b3d7..a3c7031331a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1570,6 +1570,7 @@ x_make_frame_visible (struct frame *f) if (!FRAME_VISIBLE_P (f)) { EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); + NSWindow *window = [view window]; SET_FRAME_VISIBLE (f, 1); ns_raise_frame (f, ! FRAME_NO_FOCUS_ON_MAP (f)); @@ -1586,6 +1587,23 @@ x_make_frame_visible (struct frame *f) [view handleFS]; unblock_input (); } + + /* Making a frame invisible seems to break the parent->child + relationship, so reinstate it. */ + if ([window parentWindow] == nil && FRAME_PARENT_FRAME (f) != NULL) + { + NSWindow *parent = [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window]; + + block_input (); + [parent addChildWindow: window + ordered: NSWindowAbove]; + unblock_input (); + + /* If the parent frame moved while the child frame was + invisible, the child frame's position won't have been + updated. Make sure it's in the right place now. */ + x_set_offset(f, f->left_pos, f->top_pos, 0); + } } }