Fix widget selection on high-DPI displays; remove 'hack' shader toggle#2559
Open
dcwhite wants to merge 1 commit into
Open
Fix widget selection on high-DPI displays; remove 'hack' shader toggle#2559dcwhite wants to merge 1 commit into
dcwhite wants to merge 1 commit into
Conversation
The widget-selection render pass drew into an FBO sized in Qt logical (widget) coordinates but inherited whatever viewport was last set. Qt sets the viewport to the physical framebuffer size (logical size times devicePixelRatio) before each paintGL, so on high-DPI displays the selection scene was rendered at devicePixelRatio scale relative to the FBO and mouse coordinates, breaking shift-click widget picking. The 'Viewer widget selection correction' preference compensated by scaling NDC by 0.5 in the selection vertex shader (a uniform literally named "hack"), which only worked for devicePixelRatio == 2 (e.g. Retina Macs). It was wrong for standard displays (hence the toggle) and for fractional scale factors (e.g. 125%/150% on Windows, common with Qt 6), where neither setting worked. Fix the root cause instead: explicitly set the viewport to the selection FBO's size while rendering the selection pass, so clip space maps onto the FBO 1:1 regardless of display scale, and restore the previous viewport afterward. Remove the hack uniform, the widgetSelectionCorrection preference, its settings entry, and the preferences-dialog checkbox. Fixes #2558 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #2558
Root cause
The widget-selection render pass draws into an offscreen FBO sized in Qt logical (widget) coordinates, and mouse coordinates are logical too — but the pass never set its own viewport. It inherited whatever was current, which is the physical framebuffer viewport (logical × devicePixelRatio) that Qt sets before every
paintGL. On high-DPI displays the selection scene therefore rendered at devicePixelRatio scale relative to the FBO, so the pixel read back at the mouse position missed the widget, breaking shift-click picking.The "Viewer widget selection correction" preference compensated in the selection vertex shader via a uniform literally named
hack:That squeezes NDC into the lower-left quadrant — exactly a devicePixelRatio == 2 correction. Hence the platform dependence:
(History: the toggle was added in 0374273 "added toggle selection hack button", Oct 2019, alongside debug printouts of mouse position vs. screen size — a workaround for the symptom rather than the cause.)
Fix
Explicitly set the viewport to the selection FBO's size while rendering the selection pass, and restore the previous viewport afterward (
SRInterface::select). Clip space then maps onto the FBO 1:1 at any display scale — integer, fractional, or 1 — so the correction has no reason to exist.With the root cause fixed, this removes:
hackuniform and shader branch inSRInterface.ccwidgetSelectionCorrectionpreference (Preferences.h/.cc)Settings.cc) — stale keys in existing user settings files are ignoredPreferences.ui,PreferencesWindow.cc/.h)Testing
🤖 Generated with Claude Code