Fix mouse input interference when drawing with stylus (Wine/Bottles + OTD)#4
Open
jaivu wants to merge 3 commits intoGraham--M:mainfrom
Open
Fix mouse input interference when drawing with stylus (Wine/Bottles + OTD)#4jaivu wants to merge 3 commits intoGraham--M:mainfrom
jaivu wants to merge 3 commits intoGraham--M:mainfrom
Conversation
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.
Fix: Mouse Input Interference When Drawing with Stylus
Problem
When using Krita (and other drawing apps) under Wine/Bottles with XWinTab, the stylus produced dual input both a Wintab stroke and a mouse stroke simultaneously. This caused red (mouse) lines to appear alongside blue (stylus) lines when drawing.
The root cause: Wine's X11 driver subscribes to core X11 pointer events independently of XWinTab's XInput subscription. When the stylus moves, the X server generates two events one for XWinTab (XInput) and one for Wine (core pointer) so the app sees both pen and mouse input at the same time.
Additionally, the existing
g_PenIsDownbranching inon_event()had both branches doing identical work, so it wasn't actually filtering anything.Changes in
WinTab.c1. Per-app mouse suppression hook (
WH_MOUSE)Installed on the app's message thread via
SetWindowsHookExWinWTOpenW(), removed inWTClose().App behavior is detected at open time using
GetModuleFileNameW():WM_LBUTTONDOWN/UPwhile pen is down. This stops the duplicate mouse stroke while still allowingWM_MOUSEMOVEso the brush cursor follows the pen.WM_LBUTTONDOWNto trigger drawing mode but read position/pressure from Wintab packets directly, so blocking mouse events breaks pressure sensitivity. The x=0,y=0 button packet fix below is sufficient.2. Fix x=0,y=0 button press packets
XCB button press/release events carry no coordinates (
x=0, y=0). Previously these were forwarded as-is, causing MediBang and FireAlpaca to see the cursor jump to the top-left corner on every pen touch.Fixed by tracking the last known position (
g_lastPkX,g_lastPkY) from motion events and substituting it into button event packets.3. Mouse mode toggle via barrel button (
WH_KEYBOARD_LL)For Krita users who need to interact with the UI using the pen (clicking buttons, panning etc.), a toggle is provided via the stylus lower barrel button.
Since OTD (OpenTabletDriver) injects barrel button events on its own thread, a thread-local
WH_MOUSEhook cannot catch them. Instead, a system-wideWH_KEYBOARD_LLhook detects the mapped key (PageDownby default — configurable in OTD) and togglesg_mouseModeOverride. When active,WM_LBUTTONDOWN/UPsuppression is disabled so the pen behaves like a mouse.Tested with
Result