Skip to content

Fix fullscreen Space detection reading the wrong Space type - #10

Merged
cavaldos merged 1 commit into
cavaldos:mainfrom
WuColin-1:fix-space-type-abi
Sep 17, 2026
Merged

cavaldos merged 1 commit into
cavaldos:mainfrom
WuColin-1:fix-space-type-abi

Conversation

@WuColin-1

@WuColin-1 WuColin-1 commented Sep 17, 2026

Copy link
Copy Markdown

Summary

Fixes fullscreen Space detection. Bridging.isSpaceFullscreen currently reports ordinary system Spaces as fullscreen and real fullscreen Spaces as not fullscreen.

Cause

CGSSpaceGetType is a C function that returns a raw uint32_t (0 user, 2 system, 4 fullscreen). Its Swift shim declared the return type as the CGSSpaceType enum. Swift doesn't convert the value through init(rawValue:) there; it reads the integer as the enum's case tag. As a result:

Native Space type Old result for isSpaceFullscreen Correct
0 (user) false false
2 (system) true false
4 (fullscreen) false true

That feeds AppState.isActiveSpaceFullscreen, so anything keyed on fullscreen, such as the menu bar appearance overlays, behaves backwards.

Change

  • Declare CGSSpaceGetType as returning UInt32.
  • Compare against CGSSpaceType.fullscreen.rawValue.

The fix comes from jordanbaird#980.

Testing

  • Reproduced the table above by linking both declarations against a stand-in C function that returns the requested raw value. The old declaration gives the wrong results shown; the new one reports only type 4 as fullscreen.
  • Built main with this change using Xcode 27.0 on macOS 27.0 (26A428).
  • Not yet exercised in a live fullscreen app.

🤖 Generated with Claude Code

Summary by Sourcery

Bug Fixes:

  • Correct fullscreen Space detection so ordinary system Spaces are not misclassified and actual fullscreen Spaces are recognized.

CGSSpaceGetType returns a raw uint32_t, but its Swift declaration returned
the CGSSpaceType enum. Swift reads the returned integer as the enum's case
tag, not its raw value, so isSpaceFullscreen reported a system Space (raw
type 2) as fullscreen and a real fullscreen Space (raw type 4) as not.

Declare the function as returning UInt32 and compare with the raw value.
The fix was found in jordanbaird#980.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes fullscreen Space detection by matching the native CGSSpaceGetType UInt32 result against the fullscreen type’s raw value, preventing Swift enum-tag interpretation from reversing system and fullscreen classifications.

Sequence diagram for corrected fullscreen Space detection

sequenceDiagram
    participant AppState
    participant Bridging
    participant CGS
    AppState->>Bridging: isSpaceFullscreen(spaceID)
    Bridging->>CGS: CGSSpaceGetType(connectionID, spaceID)
    CGS-->>Bridging: UInt32 spaceType
    Bridging-->>AppState: spaceType == CGSSpaceType.fullscreen.rawValue
Loading

File-Level Changes

Change Details Files
Correct Space-type interpretation by preserving the native integer return value and comparing it with the fullscreen enum’s raw value.
  • Change the CGS shim return type from CGSSpaceType to UInt32.
  • Compare the returned value against CGSSpaceType.fullscreen.rawValue.
  • This fixes downstream fullscreen state and menu bar overlay behavior for system and fullscreen Spaces.
Ice/Bridging/Bridging.swift
Ice/Bridging/Shims/Private.swift

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cavaldos
cavaldos merged commit cd79822 into cavaldos:main Sep 17, 2026
1 check passed
cavaldos added a commit that referenced this pull request Sep 17, 2026
cavaldos added a commit that referenced this pull request Sep 17, 2026
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.

2 participants