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
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')
-rw-r--r--source/blender/editors/interface/interface_eyedropper.c3
-rw-r--r--source/blender/windowmanager/WM_api.h6
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/intern/wm_window.c57
4 files changed, 16 insertions, 54 deletions
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index fd03cc5e12c..c475e143df0 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -165,8 +165,7 @@ void datadropper_win_area_find(
*r_win = CTX_wm_window(C);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mval);
if (*r_area == NULL) {
- wmWindowManager *wm = CTX_wm_manager(C);
- *r_win = WM_window_find_under_cursor(wm, NULL, *r_win, mval, r_mval);
+ *r_win = WM_window_find_under_cursor(*r_win, mval, r_mval);
if (*r_win) {
screen = WM_window_get_active_screen(*r_win);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, r_mval);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index ff3e1b7474c..5f8a831706b 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -143,11 +143,7 @@ void WM_reinit_gizmomap_all(struct Main *bmain);
*/
void WM_script_tag_reload(void);
-wmWindow *WM_window_find_under_cursor(const wmWindowManager *wm,
- const wmWindow *win_ignore,
- const wmWindow *win,
- const int mval[2],
- int r_mval[2]);
+wmWindow *WM_window_find_under_cursor(wmWindow *win, const int mval[2], int r_mval[2]);
void WM_window_pixel_sample_read(const wmWindowManager *wm,
const wmWindow *win,
const int pos[2],
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 0cc2db661ec..d9ef7dc63ff 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4663,8 +4663,8 @@ static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *wi
}
}
- wmWindow *win_other = WM_window_find_under_cursor(wm, win, win, mval, mval);
- if (win_other) {
+ wmWindow *win_other = WM_window_find_under_cursor(win, mval, mval);
+ if (win_other && win_other != win) {
copy_v2_v2_int(event->xy, mval);
return win_other;
}
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,