@@ -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
@@ -1831,7 +1829,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
18311829 // as the release will never be received otherwise.
18321830 if (gui.mouse_focus_mask .is_empty ()) {
18331831 gui.mouse_focus = nullptr ;
1834- gui.forced_mouse_focus = false ;
18351832 }
18361833
18371834 bool stopped = mouse_focus && mouse_focus->can_process () && _gui_call_input (mouse_focus, mb);
@@ -1860,7 +1857,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
18601857 gui.drag_data = control->get_drag_data (control->get_global_transform_with_canvas ().affine_inverse ().xform (mpos - gui.drag_accum ));
18611858 if (gui.drag_data .get_type () != Variant::NIL) {
18621859 gui.mouse_focus = nullptr ;
1863- gui.forced_mouse_focus = false ;
18641860 gui.mouse_focus_mask .clear ();
18651861 break ;
18661862 } else {
@@ -2398,7 +2394,6 @@ void Viewport::_gui_hide_control(Control *p_control) {
23982394void Viewport::_gui_remove_control (Control *p_control) {
23992395 if (gui.mouse_focus == p_control) {
24002396 gui.mouse_focus = nullptr ;
2401- gui.forced_mouse_focus = false ;
24022397 gui.mouse_focus_mask .clear ();
24032398 }
24042399 if (gui.key_focus == p_control) {
@@ -2564,9 +2559,12 @@ void Viewport::_drop_mouse_focus() {
25642559 Control *c = gui.mouse_focus ;
25652560 BitField<MouseButtonMask> mask = gui.mouse_focus_mask ;
25662561 gui.mouse_focus = nullptr ;
2567- gui.forced_mouse_focus = false ;
25682562 gui.mouse_focus_mask .clear ();
25692563
2564+ if (!c) {
2565+ return ;
2566+ }
2567+
25702568 for (int i = 0 ; i < 3 ; i++) {
25712569 if ((int )mask & (1 << i)) {
25722570 Ref<InputEventMouseButton> mb;
@@ -3893,23 +3891,6 @@ Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {
38933891 return gui.sub_windows [index].parent_safe_rect ;
38943892}
38953893
3896- void Viewport::pass_mouse_focus_to (Viewport *p_viewport, Control *p_control) {
3897- ERR_MAIN_THREAD_GUARD;
3898- ERR_FAIL_NULL (p_viewport);
3899- ERR_FAIL_NULL (p_control);
3900-
3901- if (gui.mouse_focus ) {
3902- p_viewport->gui .mouse_focus = p_control;
3903- p_viewport->gui .mouse_focus_mask = gui.mouse_focus_mask ;
3904- p_viewport->gui .key_focus = p_control;
3905- p_viewport->gui .forced_mouse_focus = true ;
3906-
3907- gui.mouse_focus = nullptr ;
3908- gui.forced_mouse_focus = false ;
3909- gui.mouse_focus_mask .clear ();
3910- }
3911- }
3912-
39133894void Viewport::set_sdf_oversize (SDFOversize p_sdf_oversize) {
39143895 ERR_MAIN_THREAD_GUARD;
39153896 ERR_FAIL_INDEX (p_sdf_oversize, SDF_OVERSIZE_MAX);
0 commit comments