bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#26816: mouse movement support for OS X


From: Alan Third
Subject: bug#26816: mouse movement support for OS X
Date: Sun, 7 May 2017 21:00:34 +0100
User-agent: Mutt/1.7.2 (2016-11-26)

On Sun, May 07, 2017 at 05:11:52PM +0200, Charles A. Roelli wrote:
> As far as I know, mouse movement by Emacs has never worked in OS X.
> 
> The following change to frame_set_mouse_pixel_position allows you to move
> the mouse from Lisp:
> 
> diff --git a/src/nsterm.m b/src/nsterm.m
> index c22c5a7..e81b7ee 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -2322,14 +2322,14 @@ so some key presses (TAB) are swallowed by the
> system. */
>  {
>    NSTRACE ("frame_set_mouse_pixel_position");
>    ns_raise_frame (f);
> -#if 0
> -  /* FIXME: this does not work, and what about GNUstep? */
> +  /* FIXME: what about GNUstep? */
>  #ifdef NS_IMPL_COCOA
>    [FRAME_NS_VIEW (f) lockFocus];

AFAICT this call to lockFocus isn’t required. It should tie subsequent
actions to the NSView, however CGWarpMouseCursorPosition always uses
the global screen space.

> -  PSsetmouse ((float)pix_x, (float)pix_y);
> +  CGPoint mouse_pos = CGPointMake(f->left_pos + pix_x,
> +                                  f->top_pos + pix_y);
> +  CGWarpMouseCursorPosition (mouse_pos);
>    [FRAME_NS_VIEW (f) unlockFocus];

Same with unlockFocus.

> (test with (set-mouse-position (selected-frame) 0 0))

set-mouse-position takes coordinates in characters, so (0, 0) should,
I think, be below the title and tool bars. You should be able to just
add (or subtract?) FRAME_NS_TITLEBAR_HEIGHT and FRAME_TOOLBAR_HEIGHT
to get it in the right place.

Unless I’ve misunderstood it.

> Still some things to fix:
> 
> With a portrait monitor to the left of the main monitor (the left monitor
> being in the negative x-coord. space), running the above test code on a
> single frame inside the left monitor leaves the mouse pointer about half a
> frame further down than the bottom-left corner of the frame.  The pointer
> should end up in the top-left corner.

Does this mean that the top of the portrait monitor is higher than the
top of the main monitor? It might be that NS_PARENT_WINDOW_TOP_POS
isn’t taking that extra height into account.

#define NS_PARENT_WINDOW_TOP_POS(f)                                     \
  (FRAME_PARENT_FRAME (f) != NULL                                       \
   ? ([[FRAME_NS_VIEW (f) window] parentWindow].frame.origin.y          \
      + [[FRAME_NS_VIEW (f) window] parentWindow].frame.size.height     \
      - FRAME_NS_TITLEBAR_HEIGHT (FRAME_PARENT_FRAME (f)))              \
   : [[[FRAME_NS_VIEW (f) window] screen] frame].size.height)

That last line just takes the screen’s height, and I guess that’s
wrong. It should probably be the top left co‐ord (origin.y +
size.height)?

-- 
Alan Third





reply via email to

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