Skip to content

fix(macos): use CGRequestScreenCaptureAccess instead of grabWindow for permission request#4617

Open
Mitnitsky wants to merge 1 commit intoflameshot-org:masterfrom
Mitnitsky:vmitnitsky/fix_macos_privacy_api_call
Open

fix(macos): use CGRequestScreenCaptureAccess instead of grabWindow for permission request#4617
Mitnitsky wants to merge 1 commit intoflameshot-org:masterfrom
Mitnitsky:vmitnitsky/fix_macos_privacy_api_call

Conversation

@Mitnitsky
Copy link
Copy Markdown
Contributor

Problem

On modern macOS (especially 15+), Flameshot re-triggers the Screen Recording permission dialog on every launch. The user grants the permission, but the next time the app starts it prompts again.

Root cause

The current code uses QScreen::grabWindow() as a hack to trigger the TCC permission prompt. This performs an actual screen capture on every launch, which modern macOS interprets as a new capture attempt rather than a no-op — re-triggering the permission dialog even when already granted.

Fix

Replace the grabWindow() hack with the proper CoreGraphics APIs:

  • CGPreflightScreenCaptureAccess() — checks if permission is already granted (no prompt)
  • CGRequestScreenCaptureAccess() — shows the system dialog only if not yet granted

These APIs have been available since macOS 10.15 (Catalina) and are the documented way to handle Screen Recording permissions.

@Mitnitsky
Copy link
Copy Markdown
Contributor Author

#3463 probably related

@Mitnitsky Mitnitsky force-pushed the vmitnitsky/fix_macos_privacy_api_call branch from 1ada71c to 5fbe85e Compare April 6, 2026 10:21
@mmahmoudian mmahmoudian added the MacOS MacOS related label Apr 6, 2026
@borgmanJeremy
Copy link
Copy Markdown
Collaborator

This looks good to me. I want to do some testing here but I plan to merge for the actual v14 release.

@borgmanJeremy
Copy link
Copy Markdown
Collaborator

I do not get the screen permission prompt every launch, but I almost always test a from source build. Does the issue only happen when using a .dmg built in CI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MacOS MacOS related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants