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

How KWin's desktop positions moved in one change of its desktop list: for each 1-based position in the OLD list, the position the same desktop holds in the NEW list, or 0 when it was removed. More...

#include <PhosphorEngine/DesktopRemap.h>

Public Member Functions

 DesktopRemap ()=default
bool isIdentity () const
 True when no old position moves or goes.
int oldCount () const
int newCount () const
int map (int oldPosition) const
 The new position of the desktop at oldPosition, or 0 when it was removed.
int successor (int oldPosition) const
 Like map(), except that a removed desktop answers the desktop KWin moves the outputs showing it and the windows on it alone to: the next surviving desktop after it, which takes its number, or the last one before it when it was the last.
int singleRemoval () const
 The old position when this change is exactly one desktop removed with every other keeping its order, else 0.
bool operator== (const DesktopRemap &other) const =default

Static Public Member Functions

static DesktopRemap fromIds (const QStringList &oldIds, const QStringList &newIds)
 The map from oldIds to newIds, both in position order.
static DesktopRemap removal (int position, int oldCount)
 The map for exactly one desktop removed at position out of oldCount.

Detailed Description

How KWin's desktop positions moved in one change of its desktop list: for each 1-based position in the OLD list, the position the same desktop holds in the NEW list, or 0 when it was removed.

Every store keyed by desktop NUMBER (the engines' per-desktop states, the window registry, the context rules, the disabled-desktop gates) takes the same map, so a removal, an insert or a reorder moves them all alike (orchestrator_phaseb_1, F763, F787). Built by diffing the desktop manager's id lists, which are stable across a renumber where positions are not.

A number outside the old list (0, the "every desktop" value several stores use, or one already stale) is never this map's to move: map() and successor() hand it back unchanged. A default-constructed map is therefore the identity.

Constructor & Destructor Documentation

◆ DesktopRemap()

PhosphorEngine::DesktopRemap::DesktopRemap ( )
default

Member Function Documentation

◆ fromIds()

DesktopRemap PhosphorEngine::DesktopRemap::fromIds ( const QStringList & oldIds,
const QStringList & newIds )
static

The map from oldIds to newIds, both in position order.

A desktop is matched by id, so a rename alone is the identity. Either list empty gives the identity (nothing to compare against). Lists that share no id at all are read as KWin re-creating its desktops, not as every desktop removed: the positions are kept, and those past the new count go.

◆ isIdentity()

bool PhosphorEngine::DesktopRemap::isIdentity ( ) const

True when no old position moves or goes.

Desktops appended after the last one leave it true: no stored number changes.

◆ map()

int PhosphorEngine::DesktopRemap::map ( int oldPosition) const

The new position of the desktop at oldPosition, or 0 when it was removed.

A position outside the old list comes back unchanged.

◆ newCount()

int PhosphorEngine::DesktopRemap::newCount ( ) const

◆ oldCount()

int PhosphorEngine::DesktopRemap::oldCount ( ) const

◆ operator==()

bool PhosphorEngine::DesktopRemap::operator== ( const DesktopRemap & other) const
default

◆ removal()

DesktopRemap PhosphorEngine::DesktopRemap::removal ( int position,
int oldCount )
static

The map for exactly one desktop removed at position out of oldCount.

The identity when position is not in 1..oldCount.

◆ singleRemoval()

int PhosphorEngine::DesktopRemap::singleRemoval ( ) const

The old position when this change is exactly one desktop removed with every other keeping its order, else 0.

◆ successor()

int PhosphorEngine::DesktopRemap::successor ( int oldPosition) const

Like map(), except that a removed desktop answers the desktop KWin moves the outputs showing it and the windows on it alone to: the next surviving desktop after it, which takes its number, or the last one before it when it was the last.

0 only when nothing survived (newCount() is 0). A window on several desktops is not moved by KWin, it just leaves the removed one, so a desktop list is mapped entry by entry through map() and only falls back here when no entry survives.


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