Page MenuHome

Fix T95608: Dragdrop on a windows on a different display gets wrong coordinates
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Feb 26 2022, 12:13 AM.

Details

Summary

The problem only happens on Mac and has its origin in WM_window_find_under_cursor.

Explanation of the problem:
Mousemove events are sent to windows.

In Windows OS, almost all mousemove events are sent to the window whose mouse cursor is over.

On MacOS, the window with mousemove events is always the active window. It doesn't matter if the mouse cursor is inside or outside the window.

So, in order for non-active windows to also have events, WM_window_find_under_cursor is called to find those windows and send the same events.

The problem is that to find the window, WM_window_find_under_cursor only has the mouse coordinates available, it doesn't differentiate which Display these coordinates came from.

So the mouse on one Display may incorrectly send events to a window on another display.

Explanation of the solution:
On Mac we have a native API to detect the window under the cursor (See https://developer.apple.com/documentation/appkit/nswindow/1419210-windownumberatpoint?language=objc)

The solution was to move all the WM_window_find_under_cursor logic to Ghost, and on Mac use the windowNumberAtPoint:belowWindowWithWindowNumber function in place of the existing one.

For Windows and Linux nothing has changed.

Ref T95608

Diff Detail

Repository
rB Blender

Event Timeline

Germano Cavalcante (mano-wii) requested review of this revision.Feb 26 2022, 12:13 AM
Germano Cavalcante (mano-wii) created this revision.
  • Remove parameter win_ignore (It's only used for a micro-optimization and doesn't make any difference to the event system)
  • Do not change param r_mval
  • Fix: Use getClientBounds instead of getWindowBounds (It does not consider window borders and title and matches the original code)

Looks good to me.

This revision is now accepted and ready to land.Mar 1 2022, 6:02 PM