Subject: Re: bug#28620: Interact directly on Emacs bug#28620: mouse drag event records wrong release window

From: Alan Third <[email-masked]>
Date: Wed, 4 Oct 2017 23:09:01 +0100

On Wed, Oct 04, 2017 at 04:07:56PM -0400, Robert Weiner wrote:
> On Wed, Oct 4, 2017 at 2:59 PM, Alan Third <[email-masked]> wrote:
> 
> >
> > It looks like there’s maybe a neater way to get the current frame
> > under the mouse...
> >
> >     Lisp_Object frame = Qnil;
> >     NSWindow *w = [NSApp windowWithWindowNumber:
> >                          [NSWindow windowNumberAtPoint:[NSEvent
> > mouseLocation]
> >                            belowWindowWithWindowNumber:0]];
> >     if (w != nil)
> >       XSETFRAME (frame, ((EmacsView *)[w delegate])->emacsframe);
> >
> >
> The ​mouseDown​ function (called by the various mouseUp functions) uses
> `emacsframe' to set the appropriate frame.
> How does the above modify emacsframe?  Doesn't XSETFRAME just set the value
> of the local `frame'?

Yes. You can’t modify emacsframe because it’s an instance variable.
You’ll need to modify whatever is using it to set the frame in the
emacs event.

So, assuming the code you’re modifying is calling EV_TRAILER, for now,
replace the call to EV_TRAILER with it’s contents:

    XSETFRAME (emacs_event->frame_or_window, emacsframe);
    EV_TRAILER2 (e);

and work from there.

-- 
Alan Third