Fix #93685: Allow Outliner Drag to Other Windows

Allow dragging items from Outliner to other windows. Disables EdgePan
operator when entering new window. Canceling the drop redraws target
area and resets all modal cursors. But this does not fix incorrect
mouse cursor during operations on the remote target window.

Pull Request: https://projects.blender.org/blender/blender/pulls/105196
This commit is contained in:
Harley Acheson 2023-08-17 00:48:32 +02:00 committed by Harley Acheson
parent 3a99e8898c
commit d102536b1a
2 changed files with 32 additions and 19 deletions

View File

@ -393,7 +393,12 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event
{
View2DEdgePanData *vpd = static_cast<View2DEdgePanData *>(op->customdata);
if (event->val == KM_RELEASE || event->type == EVT_ESCKEY) {
wmWindow *source_win = CTX_wm_window(C);
int r_mval[2];
wmWindow *target_win = WM_window_find_under_cursor(source_win, event->xy, &r_mval[0]);
/* Exit if we release the mouse button, hit escape, or enter a different window. */
if (event->val == KM_RELEASE || event->type == EVT_ESCKEY || source_win != target_win) {
vpd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);

View File

@ -246,21 +246,21 @@ void WM_event_start_drag(
void wm_drags_exit(wmWindowManager *wm, wmWindow *win)
{
bool any_active = false;
LISTBASE_FOREACH (const wmDrag *, drag, &wm->drags) {
if (drag->drop_state.active_dropbox) {
any_active = true;
break;
}
/* Turn off modal cursor for all windows. */
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WM_cursor_modal_restore(win);
}
/* If there is no active drop-box #wm_drags_check_ops() set a stop-cursor, which needs to be
* restored. */
if (!any_active) {
WM_cursor_modal_restore(win);
/* Active area should always redraw, even if cancelled. */
int r_mval[2];
wmWindow *target_win = WM_window_find_under_cursor(win, win->eventstate->xy, &r_mval[0]);
if (target_win) {
const bScreen *screen = WM_window_get_active_screen(target_win);
ED_region_tag_redraw_no_rebuild(screen->active_region);
/* Ensure the correct area cursor is restored. */
win->tag_cursor_refresh = true;
WM_event_add_mousemove(win);
target_win->tag_cursor_refresh = true;
WM_event_add_mousemove(target_win);
}
}
@ -414,14 +414,22 @@ static wmDropBox *dropbox_active(bContext *C,
static wmDropBox *wm_dropbox_active(bContext *C, wmDrag *drag, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
wmDropBox *drop = dropbox_active(C, &win->handlers, drag, event);
if (!drop) {
ScrArea *area = CTX_wm_area(C);
drop = dropbox_active(C, &area->handlers, drag, event);
bScreen *screen = WM_window_get_active_screen(win);
ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy);
wmDropBox *drop = nullptr;
if (area) {
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_ANY, event->xy);
if (region) {
drop = dropbox_active(C, &region->handlers, drag, event);
}
if (!drop) {
drop = dropbox_active(C, &area->handlers, drag, event);
}
}
if (!drop) {
ARegion *region = CTX_wm_region(C);
drop = dropbox_active(C, &region->handlers, drag, event);
drop = dropbox_active(C, &win->handlers, drag, event);
}
return drop;
}