From b1d6b346626c2e6199306d45c77231e383fe54a0 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Fri, 14 Oct 2022 10:29:28 +0200 Subject: Always update Viewport's last_mosue_position When the mouse cursor is over a embedded Window, the Viewport's last_mouse_position did not get updated. This patch makes sure that the update happens on every InputEventMouse. Document canvas layer of embedded Windows. --- doc/classes/CanvasLayer.xml | 1 + scene/main/viewport.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index 50c0860d1f..7c1b19b961 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -5,6 +5,7 @@ Canvas drawing layer. [CanvasItem] nodes that are direct or indirect children of a [CanvasLayer] will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a [CanvasLayer] with index -1 will be drawn below, and one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below). + Embedded [Window]s are placed in layer 1024. CanvasItems in layer 1025 or above appear in front of embedded windows, CanvasItems in layer 1023 or below appear behind embedded windows. $DOCS_URL/tutorials/2d/2d_transforms.html diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index f7a515dc1d..f66337a2f9 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1490,7 +1490,6 @@ void Viewport::_gui_input_event(Ref p_event) { gui.key_event_accepted = false; Point2 mpos = mb->get_position(); - gui.last_mouse_pos = mpos; if (mb->is_pressed()) { Size2 pos = mpos; if (gui.mouse_focus_mask != MouseButton::NONE) { @@ -1644,8 +1643,6 @@ void Viewport::_gui_input_event(Ref p_event) { gui.key_event_accepted = false; Point2 mpos = mm->get_position(); - gui.last_mouse_pos = mpos; - // Drag & drop. if (!gui.drag_attempted && gui.mouse_focus && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { gui.drag_accum += mm->get_relative(); @@ -2759,6 +2756,11 @@ void Viewport::push_input(const Ref &p_event, bool p_local_coords) { ev = p_event; } + Ref me = ev; + if (me.is_valid()) { + gui.last_mouse_pos = me->get_position(); + } + if (is_embedding_subwindows() && _sub_windows_forward_input(ev)) { set_input_as_handled(); return; -- cgit v1.2.3