@@ -655,9 +655,7 @@ void Viewport::_notification(int p_what) {
655
655
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
656
656
_gui_cancel_tooltip ();
657
657
_drop_physics_mouseover ();
658
- if (gui.mouse_focus && !gui.forced_mouse_focus ) {
659
- _drop_mouse_focus ();
660
- }
658
+ _drop_mouse_focus ();
661
659
// When the window focus changes, we want to end mouse_focus, but
662
660
// not the mouse_over. Note: The OS will trigger a separate mouse
663
661
// exit event if the change in focus results in the mouse exiting
@@ -1835,7 +1833,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
1835
1833
// as the release will never be received otherwise.
1836
1834
if (gui.mouse_focus_mask .is_empty ()) {
1837
1835
gui.mouse_focus = nullptr ;
1838
- gui.forced_mouse_focus = false ;
1839
1836
}
1840
1837
1841
1838
bool stopped = mouse_focus && mouse_focus->can_process () && _gui_call_input (mouse_focus, mb);
@@ -1864,7 +1861,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
1864
1861
gui.drag_data = control->get_drag_data (control->get_global_transform_with_canvas ().affine_inverse ().xform (mpos - gui.drag_accum ));
1865
1862
if (gui.drag_data .get_type () != Variant::NIL) {
1866
1863
gui.mouse_focus = nullptr ;
1867
- gui.forced_mouse_focus = false ;
1868
1864
gui.mouse_focus_mask .clear ();
1869
1865
break ;
1870
1866
} else {
@@ -2407,7 +2403,6 @@ void Viewport::_gui_hide_control(Control *p_control) {
2407
2403
void Viewport::_gui_remove_control (Control *p_control) {
2408
2404
if (gui.mouse_focus == p_control) {
2409
2405
gui.mouse_focus = nullptr ;
2410
- gui.forced_mouse_focus = false ;
2411
2406
gui.mouse_focus_mask .clear ();
2412
2407
}
2413
2408
if (gui.key_focus == p_control) {
@@ -2573,9 +2568,12 @@ void Viewport::_drop_mouse_focus() {
2573
2568
Control *c = gui.mouse_focus ;
2574
2569
BitField<MouseButtonMask> mask = gui.mouse_focus_mask ;
2575
2570
gui.mouse_focus = nullptr ;
2576
- gui.forced_mouse_focus = false ;
2577
2571
gui.mouse_focus_mask .clear ();
2578
2572
2573
+ if (!c) {
2574
+ return ;
2575
+ }
2576
+
2579
2577
for (int i = 0 ; i < 3 ; i++) {
2580
2578
if ((int )mask & (1 << i)) {
2581
2579
Ref<InputEventMouseButton> mb;
@@ -3902,23 +3900,6 @@ Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {
3902
3900
return gui.sub_windows [index ].parent_safe_rect ;
3903
3901
}
3904
3902
3905
- void Viewport::pass_mouse_focus_to (Viewport *p_viewport, Control *p_control) {
3906
- ERR_MAIN_THREAD_GUARD;
3907
- ERR_FAIL_NULL (p_viewport);
3908
- ERR_FAIL_NULL (p_control);
3909
-
3910
- if (gui.mouse_focus ) {
3911
- p_viewport->gui .mouse_focus = p_control;
3912
- p_viewport->gui .mouse_focus_mask = gui.mouse_focus_mask ;
3913
- p_viewport->gui .key_focus = p_control;
3914
- p_viewport->gui .forced_mouse_focus = true ;
3915
-
3916
- gui.mouse_focus = nullptr ;
3917
- gui.forced_mouse_focus = false ;
3918
- gui.mouse_focus_mask .clear ();
3919
- }
3920
- }
3921
-
3922
3903
void Viewport::set_sdf_oversize (SDFOversize p_sdf_oversize) {
3923
3904
ERR_MAIN_THREAD_GUARD;
3924
3905
ERR_FAIL_INDEX (p_sdf_oversize, SDF_OVERSIZE_MAX);
0 commit comments