@@ -655,9 +655,7 @@ void Viewport::_notification(int p_what) {
655655 case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
656656 _gui_cancel_tooltip ();
657657 _drop_physics_mouseover ();
658- if (gui.mouse_focus && !gui.forced_mouse_focus ) {
659- _drop_mouse_focus ();
660- }
658+ _drop_mouse_focus ();
661659 // When the window focus changes, we want to end mouse_focus, but
662660 // not the mouse_over. Note: The OS will trigger a separate mouse
663661 // 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) {
18351833 // as the release will never be received otherwise.
18361834 if (gui.mouse_focus_mask .is_empty ()) {
18371835 gui.mouse_focus = nullptr ;
1838- gui.forced_mouse_focus = false ;
18391836 }
18401837
18411838 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) {
18641861 gui.drag_data = control->get_drag_data (control->get_global_transform_with_canvas ().affine_inverse ().xform (mpos - gui.drag_accum ));
18651862 if (gui.drag_data .get_type () != Variant::NIL) {
18661863 gui.mouse_focus = nullptr ;
1867- gui.forced_mouse_focus = false ;
18681864 gui.mouse_focus_mask .clear ();
18691865 break ;
18701866 } else {
@@ -2407,7 +2403,6 @@ void Viewport::_gui_hide_control(Control *p_control) {
24072403void Viewport::_gui_remove_control (Control *p_control) {
24082404 if (gui.mouse_focus == p_control) {
24092405 gui.mouse_focus = nullptr ;
2410- gui.forced_mouse_focus = false ;
24112406 gui.mouse_focus_mask .clear ();
24122407 }
24132408 if (gui.key_focus == p_control) {
@@ -2573,9 +2568,12 @@ void Viewport::_drop_mouse_focus() {
25732568 Control *c = gui.mouse_focus ;
25742569 BitField<MouseButtonMask> mask = gui.mouse_focus_mask ;
25752570 gui.mouse_focus = nullptr ;
2576- gui.forced_mouse_focus = false ;
25772571 gui.mouse_focus_mask .clear ();
25782572
2573+ if (!c) {
2574+ return ;
2575+ }
2576+
25792577 for (int i = 0 ; i < 3 ; i++) {
25802578 if ((int )mask & (1 << i)) {
25812579 Ref<InputEventMouseButton> mb;
@@ -3902,23 +3900,6 @@ Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {
39023900 return gui.sub_windows [index].parent_safe_rect ;
39033901}
39043902
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-
39223903void Viewport::set_sdf_oversize (SDFOversize p_sdf_oversize) {
39233904 ERR_MAIN_THREAD_GUARD;
39243905 ERR_FAIL_INDEX (p_sdf_oversize, SDF_OVERSIZE_MAX);
0 commit comments