Using the latest Emacs26 built from master on MacOS Sierra using the macOS window system, I see the following if I have two frames: f1 and f2.
I start with the mouse within a window of f1 and selected frame of f1; (mouse-position) also reports f1.
I click mouse-1 in an Emacs window of f2 and leave it there.
(selected-frame) is now f2
macOS window manager highlights f2 as active window
(frame-focus) returns nil
(mouse-position) reports a frame of f1 <<< WRONG
I click mouse-1 again in the same Emacs window of f2.
(selected-frame) is still f2
macOS window manager highlights f2 as active window
(frame-focus) returns nil
(mouse-position) now reports a frame of f2
This happens consistently in testing. This must be a bug in mouse-position for macOS, right? Why would (mouse-position) still report f1 when f2 is the selected frame? Maybe this is why I am seeing the wrong frame on drag releases too.
If anyone else could confirm this and whether it happens on other window systems that use a mouse click to select windows, that would be helpful.
Bob