KWin
|
Manages the number of available virtual desktops, the layout of those and which virtual desktop is the current one. More...
#include <virtualdesktops.h>
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 |
VirtualDesktop * | currentDesktop () const |
template<typename Direction > | |
void | moveTo (bool wrap=false) |
bool | isNavigationWrappingAround () const |
const VirtualDesktopGrid & | grid () const |
VirtualDesktop * | inDirection (VirtualDesktop *desktop, Direction direction, bool wrap=true) |
uint | inDirection (uint desktop, Direction direction, bool wrap=true) |
void | moveTo (Direction direction, bool wrap=true) |
VirtualDesktop * | above (VirtualDesktop *desktop, bool wrap=true) const |
VirtualDesktop * | toRight (VirtualDesktop *desktop, bool wrap=true) const |
VirtualDesktop * | below (VirtualDesktop *desktop, bool wrap=true) const |
VirtualDesktop * | toLeft (VirtualDesktop *desktop, bool wrap=true) const |
VirtualDesktop * | next (VirtualDesktop *desktop=nullptr, bool wrap=true) const |
VirtualDesktop * | previous (VirtualDesktop *desktop=nullptr, bool wrap=true) const |
void | initShortcuts () |
QList< VirtualDesktop * > | desktops () const |
VirtualDesktop * | desktopForX11Id (uint id) const |
VirtualDesktop * | desktopForId (const QString &id) const |
VirtualDesktop * | createVirtualDesktop (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 |
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.
|
strong |
Enumerator | |
---|---|
Up | |
Down | |
Right | |
Left | |
Next | |
Previous |
Definition at line 204 of file virtualdesktops.h.
|
override |
Definition at line 205 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::above | ( | VirtualDesktop * | desktop, |
bool | wrap = true ) const |
null
use the current one. Definition at line 253 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::below | ( | VirtualDesktop * | desktop, |
bool | wrap = true ) const |
null
use the current one. Definition at line 301 of file virtualdesktops.cpp.
|
inline |
Definition at line 515 of file virtualdesktops.h.
|
signal |
Signal emitted whenever the number of virtual desktops changes.
previousCount | The number of desktops prior to the change |
newCount | The new current number of desktops |
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.
position | The position of the desktop. It should be in range [0, count]. |
name | The name for the new desktop, if empty the default name will be used. |
Definition at line 412 of file virtualdesktops.cpp.
uint KWin::VirtualDesktopManager::current | ( | ) | const |
Definition at line 500 of file virtualdesktops.cpp.
|
signal |
Signal emitted whenever the current desktop changes.
previousDesktop | The virtual desktop changed from |
newDesktop | The virtual desktop changed to |
|
signal |
Signal emmitted for realtime desktop switching animations.
currentDesktop | The current virtual desktop |
offset | The 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. |
|
signal |
VirtualDesktop * KWin::VirtualDesktopManager::currentDesktop | ( | ) | const |
Definition at line 505 of file virtualdesktops.cpp.
|
signal |
A new desktop has been created
desktop | the new just crated desktop |
VirtualDesktop * KWin::VirtualDesktopManager::desktopForId | ( | const QString & | id | ) | const |
id
, if no such VirtualDesktop null
is returned Definition at line 396 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::desktopForX11Id | ( | uint | id | ) | const |
id
, if no such VirtualDesktop null
is returned Definition at line 388 of file virtualdesktops.cpp.
|
signal |
A desktop has been removed and is about to be deleted
desktop | the desktop that has been removed. It's guaranteed to stil la valid pointer when the signal arrives, but it's about to be deleted. |
|
inline |
Definition at line 252 of file virtualdesktops.h.
|
inline |
Definition at line 530 of file virtualdesktops.h.
uint KWin::VirtualDesktopManager::inDirection | ( | uint | desktop, |
Direction | direction, | ||
bool | wrap = true ) |
Definition at line 243 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::inDirection | ( | VirtualDesktop * | desktop, |
Direction | direction, | ||
bool | wrap = true ) |
Definition at line 224 of file virtualdesktops.cpp.
void KWin::VirtualDesktopManager::initShortcuts | ( | ) |
Definition at line 722 of file virtualdesktops.cpp.
|
inline |
true
if navigation at borders of layout wraps around, false
otherwise Definition at line 520 of file virtualdesktops.h.
|
signal |
Signal emitted whenever the desktop layout changes.
columns | The new number of columns in the layout |
rows | The new number of rows in the layout |
|
slot |
Loads number of desktops and names from configuration file
Definition at line 636 of file virtualdesktops.cpp.
|
inlinestatic |
Definition at line 510 of file virtualdesktops.h.
void KWin::VirtualDesktopManager::moveTo | ( | bool | wrap = false | ) |
Moves to the desktop through the algorithm described by Direction.
wrap | If true wraps around to the other side of the layout |
void KWin::VirtualDesktopManager::moveTo | ( | Direction | direction, |
bool | wrap = true ) |
Definition at line 248 of file virtualdesktops.cpp.
|
signal |
Signal emitted whenever the navigationWrappingAround property changes.
VirtualDesktop * KWin::VirtualDesktopManager::next | ( | VirtualDesktop * | desktop = nullptr, |
bool | wrap = true ) const |
null
use the current desktop. Definition at line 350 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::previous | ( | VirtualDesktop * | desktop = nullptr, |
bool | wrap = true ) const |
null
use the current desktop. Definition at line 369 of file virtualdesktops.cpp.
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.
id | the string id of the desktop to remove |
Definition at line 460 of file virtualdesktops.cpp.
void KWin::VirtualDesktopManager::removeVirtualDesktop | ( | VirtualDesktop * | desktop | ) |
Definition at line 468 of file virtualdesktops.cpp.
uint KWin::VirtualDesktopManager::rows | ( | ) | const |
Definition at line 592 of file virtualdesktops.cpp.
|
signal |
Signal when the number of rows in the layout changes
rows | number of rows |
|
slot |
Saves number of desktops and names to configuration file
Definition at line 672 of file virtualdesktops.cpp.
|
inline |
Definition at line 525 of file virtualdesktops.h.
|
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.
count | The new number of desktops to use |
Definition at line 532 of file virtualdesktops.cpp.
|
slot |
Set the current desktop to current.
Definition at line 510 of file virtualdesktops.cpp.
|
slot |
Set the current desktop to current.
Definition at line 520 of file virtualdesktops.cpp.
|
slot |
enabled | wrapping around borders for navigation in desktop layout |
Definition at line 869 of file virtualdesktops.cpp.
void KWin::VirtualDesktopManager::setRootInfo | ( | NETRootInfo * | info | ) |
Definition at line 210 of file virtualdesktops.cpp.
|
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.
void KWin::VirtualDesktopManager::setVirtualDesktopManagement | ( | PlasmaVirtualDesktopManagementInterface * | management | ) |
Definition at line 47 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::toLeft | ( | VirtualDesktop * | desktop, |
bool | wrap = true ) const |
null
use the current one. Definition at line 326 of file virtualdesktops.cpp.
VirtualDesktop * KWin::VirtualDesktopManager::toRight | ( | VirtualDesktop * | desktop, |
bool | wrap = true ) const |
null
use the current one. Definition at line 277 of file virtualdesktops.cpp.
|
slot |
Called from within setCount() to ensure the desktop layout is still valid.
Definition at line 621 of file virtualdesktops.cpp.
void KWin::VirtualDesktopManager::updateRootInfo | ( | ) |
Updates the net root info for new number of desktops
Definition at line 609 of file virtualdesktops.cpp.
|
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.
|
readwrite |
The id of the virtual desktop which is currently in use.
Definition at line 141 of file virtualdesktops.h.
|
readwrite |
Whether navigation in the desktop layout wraps around at the borders.
Definition at line 145 of file virtualdesktops.h.