From b2d966bb584c62e4407e726b9678977744d78f07 Mon Sep 17 00:00:00 2001 From: GalaxyShard Date: Sun, 5 Oct 2025 03:47:35 -0400 Subject: [PATCH] Adjust panning multipliers get_delta() on Wayland is set to return a value intended to be interpreted as a measure of some amount of pixels, however previously it was being multiplied by another pixel value (page size) before scrolling was applied, which makes no sense dimensionally. As for MacOS, get_delta() seems to be set to a value with unspecified units by the documentation. When hasPreciseScrollingDeltas is true, the docs imply the value can be used as-is, and based on the mulitpliers within the MacOS input handling code and the get_delta() code that was originally written only for MacOS, it's presumably a similar measurement to what Wayland uses, although I don't have a Mac to test this on. As for when hasPreciseScrollingDeltas is false, the units are supposed to be application-defined rows or lines; panning events don't make sense to use here, however there is already code that switches between emitting panning events and scroll events on MacOS; presumably, this code works and this PR would have no effect on it. Relevant docs: https://developer.apple.com/documentation/appkit/nsevent/scrollingdeltay https://developer.apple.com/documentation/appkit/nsevent/scrollingdeltax Panning events only appear to be used on Wayland and MacOS, so this should not affect Windows or other platforms. Fixes #106168 --- editor/animation/animation_state_machine_editor.cpp | 4 ++-- editor/scene/2d/tiles/tile_data_editors.cpp | 2 +- editor/scene/texture/texture_region_editor_plugin.cpp | 4 ++-- platform/macos/godot_content_view.mm | 5 ----- scene/gui/item_list.cpp | 4 ++-- scene/gui/rich_text_label.cpp | 2 +- scene/gui/scroll_container.cpp | 4 ++-- scene/gui/text_edit.cpp | 4 ++-- scene/gui/tree.cpp | 6 +++--- scene/gui/view_panner.cpp | 2 +- 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/editor/animation/animation_state_machine_editor.cpp b/editor/animation/animation_state_machine_editor.cpp index a15ef74caece..7cbf72a2c3d2 100644 --- a/editor/animation/animation_state_machine_editor.cpp +++ b/editor/animation/animation_state_machine_editor.cpp @@ -563,8 +563,8 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { - h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); - v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8); + h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 5); + v_scroll->set_value(v_scroll->get_value() + pan_gesture->get_delta().y * 5); } } diff --git a/editor/scene/2d/tiles/tile_data_editors.cpp b/editor/scene/2d/tiles/tile_data_editors.cpp index 479188bee4f7..5825329bdafc 100644 --- a/editor/scene/2d/tiles/tile_data_editors.cpp +++ b/editor/scene/2d/tiles/tile_data_editors.cpp @@ -527,7 +527,7 @@ void GenericTilePolygonEditor::_base_control_gui_input(Ref p_event) Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { - panning += pan_gesture->get_delta() * 8; + panning += pan_gesture->get_delta() * 5 / 30; drag_last_pos = Vector2(); button_center_view->set_disabled(panning.is_zero_approx()); accept_event(); diff --git a/editor/scene/texture/texture_region_editor_plugin.cpp b/editor/scene/texture/texture_region_editor_plugin.cpp index 5533fc31c858..ee68bd0c6a3e 100644 --- a/editor/scene/texture/texture_region_editor_plugin.cpp +++ b/editor/scene/texture/texture_region_editor_plugin.cpp @@ -643,8 +643,8 @@ void TextureRegionEditor::_texture_overlay_input(const Ref &p_input) Ref pan_gesture = p_input; if (pan_gesture.is_valid()) { - hscroll->set_value(hscroll->get_value() + hscroll->get_page() * pan_gesture->get_delta().x / 8); - vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y / 8); + hscroll->set_value(hscroll->get_value() + pan_gesture->get_delta().x * 5); + vscroll->set_value(vscroll->get_value() + pan_gesture->get_delta().y * 5); } } diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index 165289c5905b..23988135e564 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -887,11 +887,6 @@ - (void)scrollWheel:(NSEvent *)event { double delta_x = [event scrollingDeltaX]; double delta_y = [event scrollingDeltaY]; - if ([event hasPreciseScrollingDeltas]) { - delta_x *= 0.03; - delta_y *= 0.03; - } - if ([event momentumPhase] != NSEventPhaseNone) { if (ignore_momentum_scroll) { return; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 14fd7466c4d0..e135123d6769 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1164,8 +1164,8 @@ void ItemList::gui_input(const Ref &p_event) { Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { - scroll_bar_v->set_value(scroll_bar_v->get_value() + scroll_bar_v->get_page() * pan_gesture->get_delta().y / 8); - scroll_bar_h->set_value(scroll_bar_h->get_value() + scroll_bar_h->get_page() * pan_gesture->get_delta().x / 8); + scroll_bar_v->set_value(scroll_bar_v->get_value() + pan_gesture->get_delta().y * 5); + scroll_bar_h->set_value(scroll_bar_h->get_value() + pan_gesture->get_delta().x * 5); } if (scroll_value_modified && (scroll_bar_v->get_value() != prev_scroll_v || scroll_bar_h->get_value() != prev_scroll_h)) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index dd71625ca1fe..2fe02c235efb 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2795,7 +2795,7 @@ void RichTextLabel::gui_input(const Ref &p_event) { Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { if (scroll_active) { - vscroll->scroll(vscroll->get_page() * pan_gesture->get_delta().y * 0.5 / 8); + vscroll->scroll(pan_gesture->get_delta().y * 5 / 2); queue_accessibility_update(); } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index d0f89561b8bb..09484e0d7453 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -250,10 +250,10 @@ void ScrollContainer::gui_input(const Ref &p_gui_input) { Ref pan_gesture = p_gui_input; if (pan_gesture.is_valid()) { if (h_scroll_enabled) { - h_scroll->scroll(h_scroll->get_page() * pan_gesture->get_delta().x / ScrollBar::PAGE_DIVISOR); + h_scroll->scroll(pan_gesture->get_delta().x * 5); } if (v_scroll_enabled) { - v_scroll->scroll(v_scroll->get_page() * pan_gesture->get_delta().y / ScrollBar::PAGE_DIVISOR); + v_scroll->scroll(pan_gesture->get_delta().y * 5); } if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index c25adad6e80c..c718932a21d2 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2494,13 +2494,13 @@ void TextEdit::gui_input(const Ref &p_gui_input) { const Ref pan_gesture = p_gui_input; if (pan_gesture.is_valid()) { - const real_t delta = pan_gesture->get_delta().y; + const real_t delta = pan_gesture->get_delta().y / 10; if (delta < 0) { _scroll_up(-delta, false); } else { _scroll_down(delta, false); } - h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 100); + h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 5); if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) { accept_event(); // Accept event if scroll changed. } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 6bfc08257aad..534bf6d20ee5 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -4201,13 +4201,13 @@ void Tree::gui_input(const Ref &p_event) { Ref pan_gesture = p_event; if (pan_gesture.is_valid()) { double prev_v = v_scroll->get_value(); - v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8); + v_scroll->set_value(v_scroll->get_value() + pan_gesture->get_delta().y * 5); double prev_h = h_scroll->get_value(); if (is_layout_rtl()) { - h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * -pan_gesture->get_delta().x / 8); + h_scroll->set_value(h_scroll->get_value() - pan_gesture->get_delta().x * 5); } else { - h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); + h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 5); } if (v_scroll->get_value() != prev_v || h_scroll->get_value() != prev_h) { diff --git a/scene/gui/view_panner.cpp b/scene/gui/view_panner.cpp index df7dc3f8a3ab..aadc19e0f14f 100644 --- a/scene/gui/view_panner.cpp +++ b/scene/gui/view_panner.cpp @@ -159,7 +159,7 @@ bool ViewPanner::gui_input(const Ref &p_event, Rect2 p_canvas_rect) zoom_callback.call(zoom, pan_gesture->get_position(), p_event); return true; } - pan_callback.call(-pan_gesture->get_delta() * scroll_speed, p_event); + pan_callback.call(-pan_gesture->get_delta() / 10 * scroll_speed, p_event); } Ref screen_drag = p_event;