From d1171635ff5d303fa0799df0bd7751371a2a1c96 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 14 Nov 2024 22:31:36 +0100 Subject: [PATCH] Fix #129414: On linux, Join Use Active Window when Overlapping On Linux we can't always determine topmost window under cursor, therefore check for overlapping windows and, if so, only use the active window. This allows dragging between windows as long as they don't overlap Pull Request: https://projects.blender.org/blender/blender/pulls/130242 --- source/blender/editors/screen/screen_ops.cc | 29 ++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 2a43e83c866..3b4c380c9de 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -12,6 +12,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_build_config.h" #include "BLI_math_rotation.h" #include "BLI_math_vector.h" #include "BLI_utildefines.h" @@ -4095,7 +4096,33 @@ static float area_split_factor(bContext *C, sAreaJoinData *jd, const wmEvent *ev static void area_join_update_data(bContext *C, sAreaJoinData *jd, const wmEvent *event) { - ScrArea *area = ED_area_find_under_cursor(C, SPACE_TYPE_ANY, event->xy); + ScrArea *area = nullptr; + + /* TODO: The following is needed until we have linux-specific implementations of + * getWindowUnderCursor. See #130242. Use active window if there are overlapping. */ + +#if (OS_WINDOWS || OS_MAC) + area = ED_area_find_under_cursor(C, SPACE_TYPE_ANY, event->xy); +#else + int win_count = 0; + LISTBASE_FOREACH (wmWindow *, win, &CTX_wm_manager(C)->windows) { + int cursor[2]; + if (wm_cursor_position_get(win, &cursor[0], &cursor[1])) { + rcti rect; + WM_window_rect_calc(win, &rect); + if (BLI_rcti_isect_pt_v(&rect, cursor)) { + win_count++; + } + } + } + + if (win_count > 1) { + area = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->xy); + } + else { + area = ED_area_find_under_cursor(C, SPACE_TYPE_ANY, event->xy); + } +#endif jd->win2 = WM_window_find_by_area(CTX_wm_manager(C), jd->sa2); jd->dir = SCREEN_DIR_NONE;