Repository navigation
Conversation
…t#2165) Fix cursor position and tool activation misalignment that occurs when the canvas window is unmaximized, resized, or scrolled. - Previously in fa6482f (PR PintaProject#1929), drag and motion controllers were moved to CanvasWindow to capture drags beginning outside the canvas. - In GTK4, TranslateCoordinates through Gtk.ScrolledWindow / Gtk.Viewport does not account for GtkViewport scroll adjustments and Halign/Valign Center margins, causing coordinates to drift away from the actual cursor. - Attach GestureDrag and EventControllerMotion directly to the canvas widget so events deliver native canvas-space coordinates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Fixes #2165 (regression introduced in fa6482f / PR #1929).
Root Cause
In PR #1929 (
fa6482f0), the gesture drag and motion controllers were moved fromCanvastoCanvasWindow(the parentGtk.Grid) to receive drags starting outside the canvas, with coordinates translated viathis.TranslateCoordinates (Canvas, rootPoint, out PointD viewPoint).In GTK4, translating coordinates through intermediate container widgets (
Gtk.ScrolledWindow/Gtk.Viewport) does not account forGtkViewportscroll adjustments or the centering margins (Halign/Valign=Center). When the window is unmaximized, resized, or scrolled, the translated coordinate drifts from the pointer position, causing tools to draw and interact with a significant offset from the cursor.Solution
dragControllerandmotionControllerdirectly tocanvas(PintaCanvas).TranslateCoordinatescalls and passrootPointdirectly asviewPoint.Testing & Verification
dotnet build: Built 14 projects with 0 errors and 0 warnings.dotnet test: 901/901 unit tests passing acrossPinta.Core.Tests(780 passed, 1 skipped) andPinta.Effects.Tests(121 passed, 1 skipped).Checklist