Skip to content

fix: keep title bar and system button state consistent across changes - #270

Open
SineStriker wants to merge 4 commits into
mainfrom
docs/registration-contract
Open

SineStriker wants to merge 4 commits into
mainfrom
docs/registration-contract

Conversation

@SineStriker

Copy link
Copy Markdown
Contributor

Motivation

setTitleBar() documents that the system buttons and hit-test visible items are unset when the title bar changes. The implementation performed this only when the previous title bar still existed, so a first assignment kept the earlier state. The title bar is a QPointer, so destroying it also left its system buttons set on the agent. setTitleBar() also asserted a non-null item, which made nullptr unusable as "no title bar".

This PR is a follow-up to the review of #262.

Behavior

  • setTitleBar(nullptr) removes the title bar.
  • Changing the title bar unsets all system buttons and hit-test visible items, including on the first assignment.
  • Destroying the title bar has the same effect as removing it. The agent clears the title bar, emits systemButtonChanged(role, nullptr) for each cleared system button, and emits titleBarChanged(nullptr) (Widgets) or titleBarWidgetChanged(nullptr) (Quick).
  • Replacing the title bar emits systemButtonChanged(role, nullptr) for each cleared system button. Destroying a title bar that has already been replaced emits nothing.
  • The shared logic is in WindowAgentBasePrivate. Each agent emits its typed signals and performs its macOS updates in the notification functions.
  • setHitTestVisible() does not emit a signal. This is unchanged.
  • The qdoc of setTitleBar(), setSystemButton(), and setHitTestVisible() is added for QuickWindowAgent, and the qdoc of the Widgets functions states the unset behavior and the ordering constraints.

Notes for reviewers

  • WindowAgentBasePrivate is an installed private header. It gains pure virtual functions notifyTitleBarReplaced() and notifyTitleBarDestroyed(), so the class is abstract. The only subclasses in this repository are WidgetWindowAgentPrivate and QuickWindowAgentPrivate.

Verification

  • Built the core, Widgets, and Quick libraries with Apple Clang and Qt 6.12.1 (Debug, Cocoa platform).
  • Probes on macOS cover first assignment, replacement, destruction of the current title bar, and destruction of the agent before the title bar. All cases pass for both agents.
  • A mutation that removes the cleared-button signal makes the probe fail, and the restored code passes.

Not verified: Windows and Linux. The implementations for these platforms are not compiled on the test machine.

This branch has not been deployed

No deployments
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