Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-03-02 00:09:28 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-03-02 00:25:12 +0300
commit9bd586a01e6813a615eab05871803730603e2152 (patch)
treea437902dcc606b7ea3b13d6d7e7ba1168a6428bd /source/blender/windowmanager/intern/wm_window.c
parent8e88af99348590e9879dcbfe97bbbc180fc5ec67 (diff)
Fix T95608: Mac issues with drag drop on multi-monitor
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 monitor these coordinates came from. So the mouse on one monitor may incorrectly send events to a window on another monitor. The solution used is to use a native API on Mac to detect the window under the cursor. For Windows and Linux nothing has changed. Reviewed By: brecht Differential Revision: https://developer.blender.org/D14197
Diffstat (limited to 'source/blender/windowmanager/intern/wm_window.c')
-rw-r--r--source/blender/windowmanager/intern/wm_window.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index a1854a8ed86..0a229b2ea56 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1855,56 +1855,23 @@ bool wm_window_get_swap_interval(wmWindow *win, int *intervalOut)
/** \name Find Window Utility
* \{ */
-static void wm_window_desktop_pos_get(const wmWindow *win,
- const int screen_pos[2],
- int r_desk_pos[2])
+wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mval[2])
{
- /* To desktop space. */
- r_desk_pos[0] = screen_pos[0] + (int)(U.pixelsize * win->posx);
- r_desk_pos[1] = screen_pos[1] + (int)(U.pixelsize * win->posy);
-}
-
-static void wm_window_screen_pos_get(const wmWindow *win,
- const int desktop_pos[2],
- int r_scr_pos[2])
-{
- /* To window space. */
- r_scr_pos[0] = desktop_pos[0] - (int)(U.pixelsize * win->posx);
- r_scr_pos[1] = desktop_pos[1] - (int)(U.pixelsize * win->posy);
-}
-
-wmWindow *WM_window_find_under_cursor(const wmWindowManager *wm,
- const wmWindow *win_ignore,
- const wmWindow *win,
- const int mval[2],
- int r_mval[2])
-{
- int desk_pos[2];
- wm_window_desktop_pos_get(win, mval, desk_pos);
-
- /* TODO: This should follow the order of the activated windows.
- * The current solution is imperfect but usable in most cases. */
- LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
- if (win_iter == win_ignore) {
- continue;
- }
-
- if (win_iter->windowstate == GHOST_kWindowStateMinimized) {
- continue;
- }
-
- int scr_pos[2];
- wm_window_screen_pos_get(win_iter, desk_pos, scr_pos);
+ int tmp[2];
+ copy_v2_v2_int(tmp, mval);
+ wm_cursor_position_to_ghost(win, &tmp[0], &tmp[1]);
- if (scr_pos[0] >= 0 && scr_pos[1] >= 0 && scr_pos[0] <= WM_window_pixels_x(win_iter) &&
- scr_pos[1] <= WM_window_pixels_y(win_iter)) {
+ GHOST_WindowHandle ghostwin = GHOST_GetWindowUnderCursor(g_system, tmp[0], tmp[1]);
- copy_v2_v2_int(r_mval, scr_pos);
- return win_iter;
- }
+ if (!ghostwin) {
+ return NULL;
}
- return NULL;
+ wmWindow *r_win = GHOST_GetWindowUserData(ghostwin);
+ wm_cursor_position_from_ghost(r_win, &tmp[0], &tmp[1]);
+ copy_v2_v2_int(r_mval, tmp);
+
+ return r_win;
}
void WM_window_pixel_sample_read(const wmWindowManager *wm,