Skip to content

macOS: don't require "control computer" accessibility permissions to move cursor - #577

Open
starlit-void wants to merge 3 commits into
YACReader:developfrom
starlit-void:starlit/cursor-warp-no-postevent
Open

macOS: don't require "control computer" accessibility permissions to move cursor#577
starlit-void wants to merge 3 commits into
YACReader:developfrom
starlit-void:starlit/cursor-warp-no-postevent

Conversation

@starlit-void

@starlit-void starlit-void commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

When the user presses S to open the page flow, the cursor is warped to the page flow area. this is performed in Qt using QCursor::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.

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.
@starlit-void

Copy link
Copy Markdown
Contributor Author

I've opened a Qt bug for this issue:
https://qt-project.atlassian.net/browse/QTBUG-148709

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant