aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2017-07-15 21:57:18 +0100
committerAlan Third2017-07-15 22:12:33 +0100
commit30444c695ae4d1184c4b6bc994c00b7b1af5ab4a (patch)
tree76551ac4f7eb064b79df824da06de089c55b74b1 /src
parent66683f46b877a8c2baa5fdedfb332618a1973db5 (diff)
downloademacs-30444c695ae4d1184c4b6bc994c00b7b1af5ab4a.tar.gz
emacs-30444c695ae4d1184c4b6bc994c00b7b1af5ab4a.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/nsfns.m20
-rw-r--r--src/nsterm.m18
2 files changed, 38 insertions, 0 deletions
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
3080 return Qnil; 3080 return Qnil;
3081} 3081}
3082 3082
3083DEFUN ("ns-mouse-absolute-pixel-position",
3084 Fns_mouse_absolute_pixel_position,
3085 Sns_mouse_absolute_pixel_position, 0, 0, 0,
3086 doc: /* Return absolute position of mouse cursor in pixels.
3087The position is returned as a cons cell (X . Y) of the
3088coordinates of the mouse cursor position in pixels relative to a
3089position (0, 0) of the selected frame's terminal. */)
3090 (void)
3091{
3092 struct frame *f = SELECTED_FRAME ();
3093 EmacsView *view = FRAME_NS_VIEW (f);
3094 NSScreen *screen = [[view window] screen];
3095 NSPoint pt = [NSEvent mouseLocation];
3096
3097 return Fcons(make_number(pt.x - screen.frame.origin.x),
3098 make_number(screen.frame.size.height -
3099 (pt.y - screen.frame.origin.y)));
3100}
3101
3083/* ========================================================================== 3102/* ==========================================================================
3084 3103
3085 Class implementations 3104 Class implementations
@@ -3269,6 +3288,7 @@ be used as the image of the icon representing the frame. */);
3269 defsubr (&Sns_frame_list_z_order); 3288 defsubr (&Sns_frame_list_z_order);
3270 defsubr (&Sns_frame_restack); 3289 defsubr (&Sns_frame_restack);
3271 defsubr (&Sns_set_mouse_absolute_pixel_position); 3290 defsubr (&Sns_set_mouse_absolute_pixel_position);
3291 defsubr (&Sns_mouse_absolute_pixel_position);
3272 defsubr (&Sx_display_mm_width); 3292 defsubr (&Sx_display_mm_width);
3273 defsubr (&Sx_display_mm_height); 3293 defsubr (&Sx_display_mm_height);
3274 defsubr (&Sx_display_screens); 3294 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)
1570 if (!FRAME_VISIBLE_P (f)) 1570 if (!FRAME_VISIBLE_P (f))
1571 { 1571 {
1572 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); 1572 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1573 NSWindow *window = [view window];
1573 1574
1574 SET_FRAME_VISIBLE (f, 1); 1575 SET_FRAME_VISIBLE (f, 1);
1575 ns_raise_frame (f, ! FRAME_NO_FOCUS_ON_MAP (f)); 1576 ns_raise_frame (f, ! FRAME_NO_FOCUS_ON_MAP (f));
@@ -1586,6 +1587,23 @@ x_make_frame_visible (struct frame *f)
1586 [view handleFS]; 1587 [view handleFS];
1587 unblock_input (); 1588 unblock_input ();
1588 } 1589 }
1590
1591 /* Making a frame invisible seems to break the parent->child
1592 relationship, so reinstate it. */
1593 if ([window parentWindow] == nil && FRAME_PARENT_FRAME (f) != NULL)
1594 {
1595 NSWindow *parent = [FRAME_NS_VIEW (FRAME_PARENT_FRAME (f)) window];
1596
1597 block_input ();
1598 [parent addChildWindow: window
1599 ordered: NSWindowAbove];
1600 unblock_input ();
1601
1602 /* If the parent frame moved while the child frame was
1603 invisible, the child frame's position won't have been
1604 updated. Make sure it's in the right place now. */
1605 x_set_offset(f, f->left_pos, f->top_pos, 0);
1606 }
1589 } 1607 }
1590} 1608}
1591 1609