Exclude software-dimming overlay windows from screen capture#1877
Open
cgchiroyasu-dev wants to merge 2 commits into
Open
Exclude software-dimming overlay windows from screen capture#1877cgchiroyasu-dev wants to merge 2 commits into
cgchiroyasu-dev wants to merge 2 commits into
Conversation
For displays without DDC or gamma support (e.g. DisplayLink / virtual displays), MonitorControl dims via a full-screen black 'shade' NSWindow. Because the shade window's sharingType defaults to .readOnly, it is captured by screenshots and screen recordings, so any capture taken while a display is dimmed comes out darkened (see discussions MonitorControl#1453, MonitorControl#866, MonitorControl#1446). Set sharingType = .none on the shade windows and the gamma activity enforcer so they no longer appear in screen captures. This is display-only chrome; excluding it from capture does not change what the user sees on screen.
Virtual displays (AirPlay/Sidecar/DisplayLink) are themselves presented to the physical monitor via screen capture. Setting sharingType=.none on their shade would remove the dimming from the actual monitor, not just from screenshots. Guard the opt-out with !isVirtual so DisplayLink etc. keep dimming, while real displays using shade (e.g. Mac mini HDMI) still get screenshot-clean dimming.
Author
|
Revised: limited the |
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.
Problem
When a display is dimmed using software dimming (the black "shade" overlay), screenshots and screen recordings of that display come out darkened — the capture includes the dimming overlay. This is most visible on displays that have no DDC and no gamma support, such as DisplayLink / virtual displays, where the shade overlay is the only dimming mechanism available.
Reported in:
Root cause
DisplayManager.createShadeOnDisplay(...)creates a full‑screen blackNSWindowto act as the dimming shade, but never sets itssharingType. The default is.readOnly, so the shade window is visible to the screen‑capture system (CGWindowList/ ScreenCaptureKit). Any screenshot or recording taken while a display is dimmed therefore captures the shade and looks dark. The same applies to the 1×1gammaActivityEnforcerhelper window.Fix
Set
sharingType = .noneon the shade windows and the gamma activity enforcer. These windows are display‑only chrome; excluding them from capture does not change what the user sees on screen — the display stays visibly dimmed, but captures are taken from the content underneath.Verification (macOS 15, DisplayLink displays)
Enumerated MonitorControl's on‑screen windows via
CGWindowListCopyWindowInfoand readkCGWindowSharingState:1(ReadOnly → captured)0(None → excluded)1(captured)0(excluded)With the fix, the dimmed display still looks dimmed to the eye, but
screencaptureof that display no longer includes the shade — screenshots come out at normal brightness. An isolated test window withsharingType = .noneconfirmed it is excluded from capture (content behind shows through) rather than rendered black.No behavior change for users who don't use software dimming.