KWin
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | List of all members
KWin::VirtualDesktopManager Class Reference

Manages the number of available virtual desktops, the layout of those and which virtual desktop is the current one. More...

#include <virtualdesktops.h>

Inheritance diagram for KWin::VirtualDesktopManager:

Public Types

enum class  Direction {
  Up , Down , Right , Left ,
  Next , Previous
}
 

Public Slots

void setCount (uint count)
 
bool setCurrent (uint current)
 
bool setCurrent (VirtualDesktop *current)
 
void setRows (uint rows)
 
void updateLayout ()
 
void setNavigationWrappingAround (bool enabled)
 
void load ()
 
void save ()
 

Signals

void countChanged (uint previousCount, uint newCount)
 
void rowsChanged (uint rows)
 
void desktopAdded (KWin::VirtualDesktop *desktop)
 
void desktopRemoved (KWin::VirtualDesktop *desktop)
 
void currentChanged (KWin::VirtualDesktop *previousDesktop, KWin::VirtualDesktop *newDesktop)
 
void currentChanging (KWin::VirtualDesktop *currentDesktop, QPointF offset)
 
void currentChangingCancelled ()
 
void layoutChanged (int columns, int rows)
 
void navigationWrappingAroundChanged ()
 

Public Member Functions

 ~VirtualDesktopManager () override
 
void setRootInfo (NETRootInfo *info)
 
void setVirtualDesktopManagement (PlasmaVirtualDesktopManagementInterface *management)
 
void setConfig (KSharedConfig::Ptr config)
 
uint count () const
 
uint rows () const
 
uint current () const
 
VirtualDesktopcurrentDesktop () const
 
template<typename Direction >
void moveTo (bool wrap=false)
 
bool isNavigationWrappingAround () const
 
const VirtualDesktopGridgrid () const
 
VirtualDesktopinDirection (VirtualDesktop *desktop, Direction direction, bool wrap=true)
 
uint inDirection (uint desktop, Direction direction, bool wrap=true)
 
void moveTo (Direction direction, bool wrap=true)
 
VirtualDesktopabove (VirtualDesktop *desktop, bool wrap=true) const
 
VirtualDesktoptoRight (VirtualDesktop *desktop, bool wrap=true) const
 
VirtualDesktopbelow (VirtualDesktop *desktop, bool wrap=true) const
 
VirtualDesktoptoLeft (VirtualDesktop *desktop, bool wrap=true) const
 
VirtualDesktopnext (VirtualDesktop *desktop=nullptr, bool wrap=true) const
 
VirtualDesktopprevious (VirtualDesktop *desktop=nullptr, bool wrap=true) const
 
void initShortcuts ()
 
QList< VirtualDesktop * > desktops () const
 
VirtualDesktopdesktopForX11Id (uint id) const
 
VirtualDesktopdesktopForId (const QString &id) const
 
VirtualDesktopcreateVirtualDesktop (uint position, const QString &name=QString())
 
void removeVirtualDesktop (const QString &id)
 
void removeVirtualDesktop (VirtualDesktop *desktop)
 
void updateRootInfo ()
 

Static Public Member Functions

static uint maximum ()
 

Properties

uint count
 
uint current
 
bool navigationWrappingAround
 

Detailed Description

Manages the number of available virtual desktops, the layout of those and which virtual desktop is the current one.

This manager is responsible for Virtual Desktop handling inside KWin. It has a property for the count of available virtual desktops and a property for the currently active virtual desktop. All changes to the number of virtual desktops and the current virtual desktop need to go through this manager.

On all changes a signal is emitted and interested parties should connect to the signal. The manager itself does not interact with other parts of the system. E.g. it does not hide/show windows of desktop changes. This is outside the scope of this manager.

Internally the manager organizes the virtual desktops in a grid allowing to navigate over the virtual desktops. For this a set of convenient methods are available which allow to get the id of an adjacent desktop or to switch to an adjacent desktop. Interested parties should make use of these methods and not replicate the logic to switch to the next desktop.

Definition at line 130 of file virtualdesktops.h.

Member Enumeration Documentation

◆ Direction

Enumerator
Up 
Down 
Right 
Left 
Next 
Previous 

Definition at line 204 of file virtualdesktops.h.

Constructor & Destructor Documentation

◆ ~VirtualDesktopManager()

KWin::VirtualDesktopManager::~VirtualDesktopManager ( )
override

Definition at line 205 of file virtualdesktops.cpp.

Member Function Documentation

◆ above()

VirtualDesktop * KWin::VirtualDesktopManager::above ( VirtualDesktop * desktop,
bool wrap = true ) const
Returns
The desktop above desktop desktop. Wraps around to the bottom of the layout if wrap is set. If desktop is null use the current one.

Definition at line 253 of file virtualdesktops.cpp.

◆ below()

VirtualDesktop * KWin::VirtualDesktopManager::below ( VirtualDesktop * desktop,
bool wrap = true ) const
Returns
The desktop below desktop desktop. Wraps around to the top of the layout if wrap is set. If desktop is null use the current one.

Definition at line 301 of file virtualdesktops.cpp.

◆ count()

uint KWin::VirtualDesktopManager::count ( ) const
inline
Returns
Total number of desktops currently in existence.
See also
setCount
countChanged

Definition at line 515 of file virtualdesktops.h.

◆ countChanged

void KWin::VirtualDesktopManager::countChanged ( uint previousCount,
uint newCount )
signal

Signal emitted whenever the number of virtual desktops changes.

Parameters
previousCountThe number of desktops prior to the change
newCountThe new current number of desktops

◆ createVirtualDesktop()

VirtualDesktop * KWin::VirtualDesktopManager::createVirtualDesktop ( uint position,
const QString & name = QString() )

Create a new virtual desktop at the requested position. The difference with setCount is that setCount always adds new desktops at the end of the chain. The Id is automatically generated.

Parameters
positionThe position of the desktop. It should be in range [0, count].
nameThe name for the new desktop, if empty the default name will be used.
Returns
the new VirtualDesktop, nullptr if we reached the maximum number of desktops

Definition at line 412 of file virtualdesktops.cpp.

◆ current()

uint KWin::VirtualDesktopManager::current ( ) const
Returns
The ID of the current desktop.
See also
setCurrent
currentChanged

Definition at line 500 of file virtualdesktops.cpp.

◆ currentChanged

void KWin::VirtualDesktopManager::currentChanged ( KWin::VirtualDesktop * previousDesktop,
KWin::VirtualDesktop * newDesktop )
signal

Signal emitted whenever the current desktop changes.

Parameters
previousDesktopThe virtual desktop changed from
newDesktopThe virtual desktop changed to

◆ currentChanging

void KWin::VirtualDesktopManager::currentChanging ( KWin::VirtualDesktop * currentDesktop,
QPointF offset )
signal

Signal emmitted for realtime desktop switching animations.

Parameters
currentDesktopThe current virtual desktop
offsetThe current total change in desktop coordinate Offset x and y are negative if switching Left and Down. Example: x = 0.6 means 60% of the way to the desktop to the right.

◆ currentChangingCancelled

void KWin::VirtualDesktopManager::currentChangingCancelled ( )
signal

◆ currentDesktop()

VirtualDesktop * KWin::VirtualDesktopManager::currentDesktop ( ) const
Returns
The current desktop
See also
setCurrent
currentChanged

Definition at line 505 of file virtualdesktops.cpp.

◆ desktopAdded

void KWin::VirtualDesktopManager::desktopAdded ( KWin::VirtualDesktop * desktop)
signal

A new desktop has been created

Parameters
desktopthe new just crated desktop

◆ desktopForId()

VirtualDesktop * KWin::VirtualDesktopManager::desktopForId ( const QString & id) const
Returns
The VirtualDesktop for the internal desktop string id, if no such VirtualDesktop null is returned

Definition at line 396 of file virtualdesktops.cpp.

◆ desktopForX11Id()

VirtualDesktop * KWin::VirtualDesktopManager::desktopForX11Id ( uint id) const
Returns
The VirtualDesktop for the x11 id, if no such VirtualDesktop null is returned

Definition at line 388 of file virtualdesktops.cpp.

◆ desktopRemoved

void KWin::VirtualDesktopManager::desktopRemoved ( KWin::VirtualDesktop * desktop)
signal

A desktop has been removed and is about to be deleted

Parameters
desktopthe desktop that has been removed. It's guaranteed to stil la valid pointer when the signal arrives, but it's about to be deleted.

◆ desktops()

QList< VirtualDesktop * > KWin::VirtualDesktopManager::desktops ( ) const
inline
Returns
all currently managed VirtualDesktops

Definition at line 252 of file virtualdesktops.h.

◆ grid()

const VirtualDesktopGrid & KWin::VirtualDesktopManager::grid ( ) const
inline
Returns
The layout aware virtual desktop grid used by this manager.

Definition at line 530 of file virtualdesktops.h.

◆ inDirection() [1/2]

uint KWin::VirtualDesktopManager::inDirection ( uint desktop,
Direction direction,
bool wrap = true )

Definition at line 243 of file virtualdesktops.cpp.

◆ inDirection() [2/2]

VirtualDesktop * KWin::VirtualDesktopManager::inDirection ( VirtualDesktop * desktop,
Direction direction,
bool wrap = true )

Definition at line 224 of file virtualdesktops.cpp.

◆ initShortcuts()

void KWin::VirtualDesktopManager::initShortcuts ( )

Definition at line 722 of file virtualdesktops.cpp.

◆ isNavigationWrappingAround()

bool KWin::VirtualDesktopManager::isNavigationWrappingAround ( ) const
inline
Returns
true if navigation at borders of layout wraps around, false otherwise
See also
setNavigationWrappingAround
navigationWrappingAroundChanged

Definition at line 520 of file virtualdesktops.h.

◆ layoutChanged

void KWin::VirtualDesktopManager::layoutChanged ( int columns,
int rows )
signal

Signal emitted whenever the desktop layout changes.

Parameters
columnsThe new number of columns in the layout
rowsThe new number of rows in the layout

◆ load

void KWin::VirtualDesktopManager::load ( )
slot

Loads number of desktops and names from configuration file

Definition at line 636 of file virtualdesktops.cpp.

◆ maximum()

uint KWin::VirtualDesktopManager::maximum ( )
inlinestatic
Returns
The maximum number of desktops that KWin supports.

Definition at line 510 of file virtualdesktops.h.

◆ moveTo() [1/2]

template<typename Direction >
void KWin::VirtualDesktopManager::moveTo ( bool wrap = false)

Moves to the desktop through the algorithm described by Direction.

Parameters
wrapIf true wraps around to the other side of the layout
See also
setCurrent

◆ moveTo() [2/2]

void KWin::VirtualDesktopManager::moveTo ( Direction direction,
bool wrap = true )

Definition at line 248 of file virtualdesktops.cpp.

◆ navigationWrappingAroundChanged

void KWin::VirtualDesktopManager::navigationWrappingAroundChanged ( )
signal

Signal emitted whenever the navigationWrappingAround property changes.

◆ next()

VirtualDesktop * KWin::VirtualDesktopManager::next ( VirtualDesktop * desktop = nullptr,
bool wrap = true ) const
Returns
The desktop after the desktop desktop. Wraps around to the first desktop if wrap is set. If desktop is null use the current desktop.

Definition at line 350 of file virtualdesktops.cpp.

◆ previous()

VirtualDesktop * KWin::VirtualDesktopManager::previous ( VirtualDesktop * desktop = nullptr,
bool wrap = true ) const
Returns
The desktop in front of the desktop desktop. Wraps around to the last desktop if wrap is set. If desktop is null use the current desktop.

Definition at line 369 of file virtualdesktops.cpp.

◆ removeVirtualDesktop() [1/2]

void KWin::VirtualDesktopManager::removeVirtualDesktop ( const QString & id)

Remove the virtual desktop identified by id, if it exists difference with setCount is that is possible to remove an arbitrary desktop, not only the last one.

Parameters
idthe string id of the desktop to remove

Definition at line 460 of file virtualdesktops.cpp.

◆ removeVirtualDesktop() [2/2]

void KWin::VirtualDesktopManager::removeVirtualDesktop ( VirtualDesktop * desktop)

Definition at line 468 of file virtualdesktops.cpp.

◆ rows()

uint KWin::VirtualDesktopManager::rows ( ) const
Returns
the number of rows the layout has.
See also
setRows
rowsChanged

Definition at line 592 of file virtualdesktops.cpp.

◆ rowsChanged

void KWin::VirtualDesktopManager::rowsChanged ( uint rows)
signal

Signal when the number of rows in the layout changes

Parameters
rowsnumber of rows

◆ save

void KWin::VirtualDesktopManager::save ( )
slot

Saves number of desktops and names to configuration file

Definition at line 672 of file virtualdesktops.cpp.

◆ setConfig()

void KWin::VirtualDesktopManager::setConfig ( KSharedConfig::Ptr config)
inline

Definition at line 525 of file virtualdesktops.h.

◆ setCount

void KWin::VirtualDesktopManager::setCount ( uint count)
slot

Set the number of available desktops to count. This function overrides any previous grid layout. There needs to be at least one virtual desktop and the new value is capped at the maximum number of desktops. A caller of this function cannot expect that the change has been applied. It is the callers responsibility to either check the numberOfDesktops or connect to the countChanged signal.

In case the current desktop is on a desktop higher than the new count, the current desktop is changed to be the new desktop with highest id. In that situation the signal desktopRemoved is emitted.

Parameters
countThe new number of desktops to use
See also
count
maximum
countChanged
desktopCreated
desktopRemoved

Definition at line 532 of file virtualdesktops.cpp.

◆ setCurrent [1/2]

bool KWin::VirtualDesktopManager::setCurrent ( uint current)
slot

Set the current desktop to current.

Returns
True on success, false otherwise.
See also
current
currentChanged
moveTo

Definition at line 510 of file virtualdesktops.cpp.

◆ setCurrent [2/2]

bool KWin::VirtualDesktopManager::setCurrent ( VirtualDesktop * current)
slot

Set the current desktop to current.

Returns
True on success, false otherwise.
See also
current
currentChanged
moveTo

Definition at line 520 of file virtualdesktops.cpp.

◆ setNavigationWrappingAround

void KWin::VirtualDesktopManager::setNavigationWrappingAround ( bool enabled)
slot
Parameters
enabledwrapping around borders for navigation in desktop layout
See also
isNavigationWrappingAround
navigationWrappingAroundChanged

Definition at line 869 of file virtualdesktops.cpp.

◆ setRootInfo()

void KWin::VirtualDesktopManager::setRootInfo ( NETRootInfo * info)

Definition at line 210 of file virtualdesktops.cpp.

◆ setRows

void KWin::VirtualDesktopManager::setRows ( uint rows)
slot

Updates the layout to a new number of rows. The number of columns will be calculated accordingly

Definition at line 597 of file virtualdesktops.cpp.

◆ setVirtualDesktopManagement()

void KWin::VirtualDesktopManager::setVirtualDesktopManagement ( PlasmaVirtualDesktopManagementInterface * management)

Definition at line 47 of file virtualdesktops.cpp.

◆ toLeft()

VirtualDesktop * KWin::VirtualDesktopManager::toLeft ( VirtualDesktop * desktop,
bool wrap = true ) const
Returns
The desktop to the left of desktop desktop. Wraps around to the right of the layout if wrap is set. If desktop is null use the current one.

Definition at line 326 of file virtualdesktops.cpp.

◆ toRight()

VirtualDesktop * KWin::VirtualDesktopManager::toRight ( VirtualDesktop * desktop,
bool wrap = true ) const
Returns
The desktop to the right of desktop desktop. Wraps around to the left of the layout if wrap is set. If desktop is null use the current one.

Definition at line 277 of file virtualdesktops.cpp.

◆ updateLayout

void KWin::VirtualDesktopManager::updateLayout ( )
slot

Called from within setCount() to ensure the desktop layout is still valid.

Definition at line 621 of file virtualdesktops.cpp.

◆ updateRootInfo()

void KWin::VirtualDesktopManager::updateRootInfo ( )

Updates the net root info for new number of desktops

Definition at line 609 of file virtualdesktops.cpp.

Property Documentation

◆ count

uint KWin::VirtualDesktopManager::count
readwrite

The number of virtual desktops currently available. The ids of the virtual desktops are in the range [1, VirtualDesktopManager::maximum()].

Definition at line 137 of file virtualdesktops.h.

◆ current

uint KWin::VirtualDesktopManager::current
readwrite

The id of the virtual desktop which is currently in use.

Definition at line 141 of file virtualdesktops.h.

◆ navigationWrappingAround

bool KWin::VirtualDesktopManager::navigationWrappingAround
readwrite

Whether navigation in the desktop layout wraps around at the borders.

Definition at line 145 of file virtualdesktops.h.


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