|
@@ -655,9 +655,7 @@ void Viewport::_notification(int p_what) {
|
|
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
|
|
case NOTIFICATION_WM_WINDOW_FOCUS_OUT: {
|
|
_gui_cancel_tooltip();
|
|
_gui_cancel_tooltip();
|
|
_drop_physics_mouseover();
|
|
_drop_physics_mouseover();
|
|
- if (gui.mouse_focus && !gui.forced_mouse_focus) {
|
|
|
|
- _drop_mouse_focus();
|
|
|
|
- }
|
|
|
|
|
|
+ _drop_mouse_focus();
|
|
// When the window focus changes, we want to end mouse_focus, but
|
|
// When the window focus changes, we want to end mouse_focus, but
|
|
// not the mouse_over. Note: The OS will trigger a separate mouse
|
|
// not the mouse_over. Note: The OS will trigger a separate mouse
|
|
// exit event if the change in focus results in the mouse exiting
|
|
// 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) {
|
|
// as the release will never be received otherwise.
|
|
// as the release will never be received otherwise.
|
|
if (gui.mouse_focus_mask.is_empty()) {
|
|
if (gui.mouse_focus_mask.is_empty()) {
|
|
gui.mouse_focus = nullptr;
|
|
gui.mouse_focus = nullptr;
|
|
- gui.forced_mouse_focus = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
bool stopped = mouse_focus && mouse_focus->can_process() && _gui_call_input(mouse_focus, mb);
|
|
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) {
|
|
gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos - gui.drag_accum));
|
|
gui.drag_data = control->get_drag_data(control->get_global_transform_with_canvas().affine_inverse().xform(mpos - gui.drag_accum));
|
|
if (gui.drag_data.get_type() != Variant::NIL) {
|
|
if (gui.drag_data.get_type() != Variant::NIL) {
|
|
gui.mouse_focus = nullptr;
|
|
gui.mouse_focus = nullptr;
|
|
- gui.forced_mouse_focus = false;
|
|
|
|
gui.mouse_focus_mask.clear();
|
|
gui.mouse_focus_mask.clear();
|
|
break;
|
|
break;
|
|
} else {
|
|
} else {
|
|
@@ -2407,7 +2403,6 @@ void Viewport::_gui_hide_control(Control *p_control) {
|
|
void Viewport::_gui_remove_control(Control *p_control) {
|
|
void Viewport::_gui_remove_control(Control *p_control) {
|
|
if (gui.mouse_focus == p_control) {
|
|
if (gui.mouse_focus == p_control) {
|
|
gui.mouse_focus = nullptr;
|
|
gui.mouse_focus = nullptr;
|
|
- gui.forced_mouse_focus = false;
|
|
|
|
gui.mouse_focus_mask.clear();
|
|
gui.mouse_focus_mask.clear();
|
|
}
|
|
}
|
|
if (gui.key_focus == p_control) {
|
|
if (gui.key_focus == p_control) {
|
|
@@ -2573,9 +2568,12 @@ void Viewport::_drop_mouse_focus() {
|
|
Control *c = gui.mouse_focus;
|
|
Control *c = gui.mouse_focus;
|
|
BitField<MouseButtonMask> mask = gui.mouse_focus_mask;
|
|
BitField<MouseButtonMask> mask = gui.mouse_focus_mask;
|
|
gui.mouse_focus = nullptr;
|
|
gui.mouse_focus = nullptr;
|
|
- gui.forced_mouse_focus = false;
|
|
|
|
gui.mouse_focus_mask.clear();
|
|
gui.mouse_focus_mask.clear();
|
|
|
|
|
|
|
|
+ if (!c) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|
|
if ((int)mask & (1 << i)) {
|
|
if ((int)mask & (1 << i)) {
|
|
Ref<InputEventMouseButton> mb;
|
|
Ref<InputEventMouseButton> mb;
|
|
@@ -3902,23 +3900,6 @@ Rect2i Viewport::subwindow_get_popup_safe_rect(Window *p_window) const {
|
|
return gui.sub_windows[index].parent_safe_rect;
|
|
return gui.sub_windows[index].parent_safe_rect;
|
|
}
|
|
}
|
|
|
|
|
|
-void Viewport::pass_mouse_focus_to(Viewport *p_viewport, Control *p_control) {
|
|
|
|
- ERR_MAIN_THREAD_GUARD;
|
|
|
|
- ERR_FAIL_NULL(p_viewport);
|
|
|
|
- ERR_FAIL_NULL(p_control);
|
|
|
|
-
|
|
|
|
- if (gui.mouse_focus) {
|
|
|
|
- p_viewport->gui.mouse_focus = p_control;
|
|
|
|
- p_viewport->gui.mouse_focus_mask = gui.mouse_focus_mask;
|
|
|
|
- p_viewport->gui.key_focus = p_control;
|
|
|
|
- p_viewport->gui.forced_mouse_focus = true;
|
|
|
|
-
|
|
|
|
- gui.mouse_focus = nullptr;
|
|
|
|
- gui.forced_mouse_focus = false;
|
|
|
|
- gui.mouse_focus_mask.clear();
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void Viewport::set_sdf_oversize(SDFOversize p_sdf_oversize) {
|
|
void Viewport::set_sdf_oversize(SDFOversize p_sdf_oversize) {
|
|
ERR_MAIN_THREAD_GUARD;
|
|
ERR_MAIN_THREAD_GUARD;
|
|
ERR_FAIL_INDEX(p_sdf_oversize, SDF_OVERSIZE_MAX);
|
|
ERR_FAIL_INDEX(p_sdf_oversize, SDF_OVERSIZE_MAX);
|