GNU bug report logs - #4892
compute_motion, mouse_position

Previous Next

Package: emacs;

Reported by: David Reitter <david.reitter <at> gmail.com>

Date: Mon, 9 Nov 2009 17:20:21 UTC

Severity: normal

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


Message #19 received at 4892 <at> debbugs.gnu.org (full text, mbox):

From: David Reitter <david.reitter <at> gmail.com>
To: Alan Third <alan <at> idiocy.org>
Cc: 4892 <at> debbugs.gnu.org
Subject: Re: [PATCH] Fix mouse-position on macOS (bug#4892)
Date: Wed, 4 Dec 2019 07:48:45 -0500
[Message part 1 (text/plain, inline)]
Looks good to me (but haven’t tried). Thanks for working on this!
DR
On Dec 4, 2019, 07:44 -0500, Alan Third <alan <at> idiocy.org>, wrote:
> * src/nsterm.m (ns_mouse_position): Implement a search for the frame
> under the mouse pointer.
> ---
> src/nsterm.m | 52 ++++++++++++++++++++++++++++++++++++++--------------
> 1 file changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/src/nsterm.m b/src/nsterm.m
> index 52a9830be8..71234ac783 100644
> --- a/src/nsterm.m
> +++ b/src/nsterm.m
> @@ -2475,7 +2475,7 @@ so some key presses (TAB) are swallowed by the system. */
> -------------------------------------------------------------------------- */
> {
> id view;
> - NSPoint position;
> + NSPoint view_position;
> Lisp_Object frame, tail;
> struct frame *f;
> struct ns_display_info *dpyinfo;
> @@ -2498,31 +2498,55 @@ so some key presses (TAB) are swallowed by the system. */
> XFRAME (frame)->mouse_moved = 0;
>
> dpyinfo->last_mouse_scroll_bar = nil;
> - f = dpyinfo->ns_focus_frame ? dpyinfo->ns_focus_frame : SELECTED_FRAME ();
> - if (dpyinfo->last_mouse_frame
> - /* While dropping, use the last mouse frame only if there is no
> - currently focused frame. */
> - && (!EQ (track_mouse, Qdropping) || !f)
> +
> +#ifdef NS_IMPL_COCOA
> + /* Find the uppermost Emacs frame under the mouse pointer.
> +
> + This doesn't work on GNUstep, although in recent versions there
> + is compatibility code that makes it a noop. */
> +
> + NSPoint screen_position = [NSEvent mouseLocation];
> + NSInteger window_number = 0;
> + do
> + {
> + NSWindow *w;
> +
> + window_number = [NSWindow windowNumberAtPoint:screen_position
> + belowWindowWithWindowNumber:window_number];
> + w = [NSApp windowWithWindowNumber:window_number];
> +
> + if (w && [[w delegate] isKindOfClass:[EmacsView class]])
> + f = ((EmacsView *)[w delegate])->emacsframe;
> + }
> + while (window_number > 0 && !f);
> +#endif
> +
> + if (!f)
> + f = dpyinfo->ns_focus_frame ? dpyinfo->ns_focus_frame : SELECTED_FRAME ();
> +
> + /* While dropping, use the last mouse frame only if there is no
> + currently focused frame. */
> + if (!f
> + && EQ (track_mouse, Qdropping)
> + && dpyinfo->last_mouse_frame
> && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
> f = dpyinfo->last_mouse_frame;
> - else
> - f = dpyinfo->ns_focus_frame ? dpyinfo->ns_focus_frame : SELECTED_FRAME ();
>
> if (f && FRAME_NS_P (f))
> {
> view = FRAME_NS_VIEW (f);
>
> - position = [[view window] mouseLocationOutsideOfEventStream];
> - position = [view convertPoint: position fromView: nil];
> - remember_mouse_glyph (f, position.x, position.y,
> + view_position = [[view window] mouseLocationOutsideOfEventStream];
> + view_position = [view convertPoint: view_position fromView: nil];
> + remember_mouse_glyph (f, view_position.x, view_position.y,
> &dpyinfo->last_mouse_glyph);
> - NSTRACE_POINT ("position", position);
> + NSTRACE_POINT ("view_position", view_position);
>
> if (bar_window) *bar_window = Qnil;
> if (part) *part = scroll_bar_above_handle;
>
> - if (x) XSETINT (*x, lrint (position.x));
> - if (y) XSETINT (*y, lrint (position.y));
> + if (x) XSETINT (*x, lrint (view_position.x));
> + if (y) XSETINT (*y, lrint (view_position.y));
> if (time)
> *time = dpyinfo->last_mouse_movement_time;
> *fp = f;
> --
> 2.21.0
>
>
> --
> Alan Third
[Message part 2 (text/html, inline)]

This bug report was last modified 5 years and 221 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.