Skip to content

Suppress input during screenshot selection#385

Open
biswadip-paul wants to merge 1 commit into
BarutSRB:mainfrom
biswadip-paul:fix/suppress-input-during-screenshot
Open

Suppress input during screenshot selection#385
biswadip-paul wants to merge 1 commit into
BarutSRB:mainfrom
biswadip-paul:fix/suppress-input-during-screenshot

Conversation

@biswadip-paul
Copy link
Copy Markdown

@biswadip-paul biswadip-paul commented May 28, 2026

Summary

  • Detect when macOS screenshot selection tool (Cmd+Shift+4) is the frontmost app and suppress OmniWM's mouse event handling and layout refreshes
  • Follows the existing lock screen suppression pattern: isInputSuppressed in MouseEventHandler and lock screen guards in LayoutRefreshController
  • Checks for com.apple.screencaptureui and com.apple.Screenshot bundle IDs

Fixes #254

Details

When screenshot selection is active, OmniWM's session-level CGEventTap continues intercepting all mouse events. Dragging the selection rectangle near tiled window edges causes windows to shift or resize. By detecting the screencapture process as the frontmost app and suppressing input handling + layout refreshes (the same approach used for lock screen), the windows remain stable during screenshot capture.

Test plan

  • Press Cmd+Shift+4 and drag the selection rectangle near window edges — windows should remain stable
  • Take a screenshot far from edges — still works as before
  • Press Cmd+Shift+4 then Space (window capture mode) — still works
  • Press Cmd+Shift+3 (full screenshot) — still works
  • After screenshot completes, verify OmniWM resumes normal operation (move/resize windows, focus changes)
  • Lock screen behavior unchanged

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Enhanced screen recording compatibility: the window manager now recognizes when the active application is actively screen-capturing and automatically pauses layout refresh operations, visibility updates, window removal, and input event handling during capture sessions to prevent interference with recording functionality.

Review Change Stack

…g and layout refreshes during screenshot selection When macOS screenshot selection (Cmd+Shift+4) is active, OmniWM's CGEventTap continues intercepting all mouse events system-wide. Dragging the screenshot selection rectangle near tiled window edges causes windows to shift or resize, making screenshot capture unusable. Add screencapture process detection (com.apple.screencaptureui, com.apple.Screenshot) following the existing lock screen suppression pattern: - MouseEventHandler.isInputSuppressed now checks for frontmost screencapture app - LayoutRefreshController suppresses relayout/visibility refreshes during capture This prevents any OmniWM mouse-driven or layout-driven window management while the screenshot selection overlay is active. Fixes BarutSRB#254 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef88f06a-3d55-4fce-8ff9-a6a5a5730515

📥 Commits

Reviewing files that changed from the base of the PR and between 777f1c7 and ee88770.

📒 Files selected for processing (3)
  • Sources/OmniWM/Core/Controller/LayoutRefreshController.swift
  • Sources/OmniWM/Core/Controller/MouseEventHandler.swift
  • Sources/OmniWM/Core/Controller/WMController.swift

📝 Walkthrough

Walkthrough

The PR adds screen-capture detection to prevent OmniWM from refreshing layouts or dispatching mouse events during screenshot operations. A new helper method checks if the frontmost app is screen-capturing, and this check is applied consistently across layout refresh paths and input handling to avoid window shifts during screenshot selection.

Changes

Screen-capture operation suppression

Layer / File(s) Summary
Screen-capture detection helper
Sources/OmniWM/Core/Controller/WMController.swift
isFrontmostAppScreenCapture() method added with a private screenCaptureBundleIds allowlist to detect when the frontmost app is performing screen capture.
Layout refresh suppression during screen capture
Sources/OmniWM/Core/Controller/LayoutRefreshController.swift
Early-return guards added to executeRelayout, executeVisibilityRefresh, executeWindowRemoval, and executeFullRefresh to skip refresh operations when screen capture is active.
Mouse input suppression during screen capture
Sources/OmniWM/Core/Controller/MouseEventHandler.swift
isInputSuppressed property expanded to include screen-capture state, preventing mouse and gesture event dispatch during screenshot operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A screenshot needs peace, no windows in motion,
We've taught OmniWM to pause with devotion.
When capture apps wake, layouts now sleep,
Your Cmd+Shift+4 selections stay deep!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: suppressing input during screenshot selection, which is the core objective of this PR.
Linked Issues check ✅ Passed The PR fully addresses issue #254 by detecting screenshot tools and suppressing input/layout refreshes to prevent window shifting during screenshot selection.
Out of Scope Changes check ✅ Passed All changes are directly scoped to detecting screenshot capture and suppressing input/layout refreshes accordingly; no out-of-scope modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@biswadip-paul
Copy link
Copy Markdown
Author

Note: This fix assumes screencaptureui becomes the frontmost app during Cmd+Shift+4 screenshot selection. If it doesn't (similar to how system overlay pills in #358 don't change the frontmost app), then the isFrontmostAppScreenCapture() check won't fire and the root cause would be deeper — likely CGS frameChanged events from the screenshot overlay window triggering relayouts, or focus churn from transient system process activation.

Happy to investigate the CGS event path if this fix alone doesn't resolve the issue during testing.

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.

Trying to take a screenshot using Cmd + Shift + 4 causes windows to shift.

2 participants