Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorCompositor::DecorationManager Class Reference

The single owner of server-side decoration (title-bar) state. More...

#include <phosphor-compositor/include/PhosphorCompositor/DecorationManager.h>

Inheritance diagram for PhosphorCompositor::DecorationManager:
[legend]

Classes

struct  Owner
 An owner is a (kind, screen) pair. More...
 

Public Types

enum class  OwnerKind { Rule }
 
enum class  Placement { CallerWillPlace , AlreadyPlaced }
 How the physical hide coordinates with geometry application. More...
 

Signals

void windowDecorationRestored (const QString &windowId)
 Emitted after a physical decoration restore (the effect refreshes border overlays for the window).
 

Public Member Functions

 DecorationManager (ICompositorBridge &bridge, QObject *parent=nullptr)
 bridge must outlive the manager (the KWin effect owns both, with the bridge destroyed after the manager).
 
void acquire (const QString &windowId, const Owner &owner, Placement placement=Placement::AlreadyPlaced)
 Low-level primitive: take ownership of windowId's decoration and hide it per placement.
 
void restoreAll ()
 Daemon loss / effect teardown: synchronously restore every window we hid to its prior state, then drop all tracking.
 
void forgetWindow (const QString &windowId)
 Window destroyed: drop all state for it.
 
void setRuleOverride (const QString &windowId, std::optional< bool > ruleValue)
 nullopt: rule has no opinion — clear Rule owner and veto.
 
void clearAllRuleOverrides ()
 Rules went away wholesale (rule set emptied / teardown): clear every Rule owner and veto, restoring where no other owner remains.
 
void resyncWindow (const QString &windowId)
 The compositor can silently reset noBorder (KWin does on desktop switches).
 
bool isBorderless (const QString &windowId) const
 True when we physically suppressed the window's decoration.
 
bool isOwned (const QString &windowId) const
 
bool isOwnedBy (const QString &windowId, const Owner &owner) const
 
bool isVetoed (const QString &windowId) const
 

Static Public Member Functions

static Owner rule ()
 

Detailed Description

The single owner of server-side decoration (title-bar) state.

Every component that wants a window's title bar hidden registers as an OWNER here instead of calling setNoBorder() itself. The decoration is hidden while at least one owner holds the window (and no veto pins it visible) and restored to its prior state when the last owner releases. Title-bar hiding flows entirely through the window-rule layer (setRuleOverride / clearAllRuleOverrides); there is exactly one owner kind.

Invariants this class centralizes:

  • Capability gate: userCanSetNoBorder() — false for CSD apps (GTK/Electron) and other non-toggleable windows, which are tracked as owned but never physically touched.
  • Prior-state capture: a window that was already borderless when first acquired (user's own compositor rule) is restored to borderless, never force-decorated.
  • Geometry preservation: the compositor holds the CLIENT size constant across a decoration change, so toggling the decoration on a placed window changes the frame height by the title-bar height. Hiding a placed window therefore captures moveResizeGeometry() — NOT frameGeometry(), which lags on Wayland until the client acks the configure — toggles, and re-asserts the target.

Member Enumeration Documentation

◆ OwnerKind

Enumerator
Rule 

◆ Placement

How the physical hide coordinates with geometry application.

Enumerator
CallerWillPlace 

The caller applies the zone geometry immediately after acquire.

The manager only toggles the decoration.

AlreadyPlaced 

The window is already at (or moving toward) its target: capture moveResizeGeometry() → setNoBorder(true) → re-assert the target so the content grows to fill the zone (rule changes).

Constructor & Destructor Documentation

◆ DecorationManager()

PhosphorCompositor::DecorationManager::DecorationManager ( ICompositorBridge bridge,
QObject *  parent = nullptr 
)
explicit

bridge must outlive the manager (the KWin effect owns both, with the bridge destroyed after the manager).

Taken by reference so a null bridge is unrepresentable — no runtime guard needed on any call path.

Member Function Documentation

◆ acquire()

void PhosphorCompositor::DecorationManager::acquire ( const QString &  windowId,
const Owner owner,
Placement  placement = Placement::AlreadyPlaced 
)

Low-level primitive: take ownership of windowId's decoration and hide it per placement.

This is the public seam the higher-level setRuleOverride is built on (it calls acquire(.., rule(), AlreadyPlaced)). Placement::CallerWillPlace is provided for a caller that applies the zone geometry itself right after acquiring; the in-tree effect only ever uses AlreadyPlaced via setRuleOverride, so CallerWillPlace is currently exercised only by direct callers and tests. Kept public deliberately as the reusable primitive, not dead code.

◆ clearAllRuleOverrides()

void PhosphorCompositor::DecorationManager::clearAllRuleOverrides ( )

Rules went away wholesale (rule set emptied / teardown): clear every Rule owner and veto, restoring where no other owner remains.

◆ forgetWindow()

void PhosphorCompositor::DecorationManager::forgetWindow ( const QString &  windowId)

Window destroyed: drop all state for it.

Zero compositor calls — the decoration dies with the window.

◆ isBorderless()

bool PhosphorCompositor::DecorationManager::isBorderless ( const QString &  windowId) const

True when we physically suppressed the window's decoration.

◆ isOwned()

bool PhosphorCompositor::DecorationManager::isOwned ( const QString &  windowId) const

◆ isOwnedBy()

bool PhosphorCompositor::DecorationManager::isOwnedBy ( const QString &  windowId,
const Owner owner 
) const

◆ isVetoed()

bool PhosphorCompositor::DecorationManager::isVetoed ( const QString &  windowId) const

◆ restoreAll()

void PhosphorCompositor::DecorationManager::restoreAll ( )

Daemon loss / effect teardown: synchronously restore every window we hid to its prior state, then drop all tracking.

◆ resyncWindow()

void PhosphorCompositor::DecorationManager::resyncWindow ( const QString &  windowId)

The compositor can silently reset noBorder (KWin does on desktop switches).

If windowId should be hidden but the decoration came back, re-hide via the AlreadyPlaced sequence. No-op otherwise.

◆ rule()

static Owner PhosphorCompositor::DecorationManager::rule ( )
inlinestatic

◆ setRuleOverride()

void PhosphorCompositor::DecorationManager::setRuleOverride ( const QString &  windowId,
std::optional< bool >  ruleValue 
)

nullopt: rule has no opinion — clear Rule owner and veto.

true: rule hides — acquire a Rule owner (clears any veto). false: rule force-shows — VETO. The veto wins over every owner and pins the decoration visible; owners re-assert when it lifts.

◆ windowDecorationRestored

void PhosphorCompositor::DecorationManager::windowDecorationRestored ( const QString &  windowId)
signal

Emitted after a physical decoration restore (the effect refreshes border overlays for the window).

Slots may synchronously re-enter the manager — including destroying it or calling restoreAll() — every emit site guards its epilogue accordingly.


The documentation for this class was generated from the following file: