macOS: don't require "control computer" accessibility permissions to move cursor - #577
Open
starlit-void wants to merge 3 commits into
Open
macOS: don't require "control computer" accessibility permissions to move cursor#577starlit-void wants to merge 3 commits into
starlit-void wants to merge 3 commits into
Conversation
Showing the go to flow bar moves the pointer into it, so that the mouse move handling doesn't immediately hide it again. That went through QCursor::setPos, which on macOS is implemented by synthesizing a mouse event and injecting it into the HID event stream (QCocoaCursor::setPos -> CGEventPost). macOS gates event injection behind the accessibility "control this computer" permission, so the app asked for far more access than it needed, with a system dialog that gives no hint about which feature wants it. Worse, the request is denied by default and never prompts inline, so on any machine without the grant the pointer simply never moved and the feature was quietly dead. Route the move through CGWarpMouseCursorPosition on macOS instead. It repositions the pointer without injecting an event and requires no permission at all. Behaviour is unchanged on every platform: Windows and Linux keep using QCursor::setPos, and macOS now actually performs the move it was always meant to. Warping doesn't deliver a mouse move to the application, which suits this caller exactly, since the intent is to reposition the pointer without triggering the move handling that hides the widget.
Contributor
Author
|
I've opened a Qt bug for this issue: |
The macOS branch in moveCursorTo() exists only because QCursor::setPos is implemented with CGEventPost. That is now filed as QTBUG-148709, so point at it from the comment and note the condition under which this workaround can be removed.
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.
When the user presses
Sto open the page flow, the cursor is warped to the page flow area. this is performed in Qt usingQCursor::setPos, which internally synthesizes a mouse event, which requires "Allow the application to control your computer" accessibility setting on macOS. the proposed fix uses CGWarpMouseCursorPosition which moves the cursor without firing any events, which is basically what we want.this is arguably a workaround for a Qt bug, not a YACReader bug.