emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 30444c6: Fix some frame handling issues on NS


From: Alan Third
Subject: [Emacs-diffs] master 30444c6: Fix some frame handling issues on NS
Date: Sat, 15 Jul 2017 17:14:22 -0400 (EDT)

branch: master
commit 30444c695ae4d1184c4b6bc994c00b7b1af5ab4a
Author: Alan Third <address@hidden>
Commit: Alan Third <address@hidden>

    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.
---
 lisp/frame.el |  2 ++
 src/nsfns.m   | 20 ++++++++++++++++++++
 src/nsterm.m  | 18 ++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/lisp/frame.el b/lisp/frame.el
index 7d57179..1af12c7 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 68eba8b..36748ce 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 bf83550..a3c7031 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);
+        }
     }
 }
 



reply via email to

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