scripting: Introduce workspace.currentVirtualDesktop property
It's the same as the currentDesktop except that it's a VirtualDesktop object. The main advantage of the currentVirtualDesktop property is that it doesn't change if a virtual desktop is added or removed in the middle. It also makes dealing with virtual desktop changes easier.
This commit is contained in:
parent
9a2a1c0435
commit
5419e3df4a
2 changed files with 26 additions and 0 deletions
|
@ -35,6 +35,7 @@ WorkspaceWrapper::WorkspaceWrapper(QObject* parent) : QObject(parent)
|
||||||
connect(ws, &Workspace::clientActivated, this, &WorkspaceWrapper::clientActivated);
|
connect(ws, &Workspace::clientActivated, this, &WorkspaceWrapper::clientActivated);
|
||||||
connect(vds, &VirtualDesktopManager::countChanged, this, &WorkspaceWrapper::numberDesktopsChanged);
|
connect(vds, &VirtualDesktopManager::countChanged, this, &WorkspaceWrapper::numberDesktopsChanged);
|
||||||
connect(vds, &VirtualDesktopManager::layoutChanged, this, &WorkspaceWrapper::desktopLayoutChanged);
|
connect(vds, &VirtualDesktopManager::layoutChanged, this, &WorkspaceWrapper::desktopLayoutChanged);
|
||||||
|
connect(vds, &VirtualDesktopManager::currentChanged, this, &WorkspaceWrapper::currentVirtualDesktopChanged);
|
||||||
connect(ws, &Workspace::clientDemandsAttentionChanged, this, &WorkspaceWrapper::clientDemandsAttentionChanged);
|
connect(ws, &Workspace::clientDemandsAttentionChanged, this, &WorkspaceWrapper::clientDemandsAttentionChanged);
|
||||||
#ifdef KWIN_BUILD_ACTIVITIES
|
#ifdef KWIN_BUILD_ACTIVITIES
|
||||||
if (KWin::Activities *activities = KWin::Activities::self()) {
|
if (KWin::Activities *activities = KWin::Activities::self()) {
|
||||||
|
@ -67,6 +68,11 @@ int WorkspaceWrapper::currentDesktop() const
|
||||||
return VirtualDesktopManager::self()->current();
|
return VirtualDesktopManager::self()->current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VirtualDesktop *WorkspaceWrapper::currentVirtualDesktop() const
|
||||||
|
{
|
||||||
|
return VirtualDesktopManager::self()->currentDesktop();
|
||||||
|
}
|
||||||
|
|
||||||
int WorkspaceWrapper::numberOfDesktops() const
|
int WorkspaceWrapper::numberOfDesktops() const
|
||||||
{
|
{
|
||||||
return VirtualDesktopManager::self()->count();
|
return VirtualDesktopManager::self()->count();
|
||||||
|
@ -77,6 +83,11 @@ void WorkspaceWrapper::setCurrentDesktop(int desktop)
|
||||||
VirtualDesktopManager::self()->setCurrent(desktop);
|
VirtualDesktopManager::self()->setCurrent(desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorkspaceWrapper::setCurrentVirtualDesktop(VirtualDesktop *desktop)
|
||||||
|
{
|
||||||
|
VirtualDesktopManager::self()->setCurrent(desktop);
|
||||||
|
}
|
||||||
|
|
||||||
void WorkspaceWrapper::setNumberOfDesktops(int count)
|
void WorkspaceWrapper::setNumberOfDesktops(int count)
|
||||||
{
|
{
|
||||||
VirtualDesktopManager::self()->setCount(count);
|
VirtualDesktopManager::self()->setCount(count);
|
||||||
|
|
|
@ -22,12 +22,17 @@ namespace KWin
|
||||||
{
|
{
|
||||||
// forward declarations
|
// forward declarations
|
||||||
class AbstractClient;
|
class AbstractClient;
|
||||||
|
class VirtualDesktop;
|
||||||
class X11Client;
|
class X11Client;
|
||||||
|
|
||||||
class WorkspaceWrapper : public QObject
|
class WorkspaceWrapper : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
/**
|
||||||
|
* @deprecated use the currentVirtualDesktop property instead
|
||||||
|
*/
|
||||||
Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY currentDesktopChanged)
|
Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY currentDesktopChanged)
|
||||||
|
Q_PROPERTY(KWin::VirtualDesktop *currentVirtualDesktop READ currentVirtualDesktop WRITE setCurrentVirtualDesktop NOTIFY currentVirtualDesktopChanged)
|
||||||
Q_PROPERTY(KWin::AbstractClient *activeClient READ activeClient WRITE setActiveClient NOTIFY clientActivated)
|
Q_PROPERTY(KWin::AbstractClient *activeClient READ activeClient WRITE setActiveClient NOTIFY clientActivated)
|
||||||
// TODO: write and notify?
|
// TODO: write and notify?
|
||||||
Q_PROPERTY(QSize desktopGridSize READ desktopGridSize NOTIFY desktopLayoutChanged)
|
Q_PROPERTY(QSize desktopGridSize READ desktopGridSize NOTIFY desktopLayoutChanged)
|
||||||
|
@ -153,6 +158,13 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void virtualScreenGeometryChanged();
|
void virtualScreenGeometryChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted when the current virtual desktop changes.
|
||||||
|
*
|
||||||
|
* @since 5.23
|
||||||
|
*/
|
||||||
|
void currentVirtualDesktopChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
//enums copy&pasted from kwinglobals.h because qtscript is evil
|
//enums copy&pasted from kwinglobals.h because qtscript is evil
|
||||||
|
@ -217,6 +229,9 @@ void setter( rettype val );
|
||||||
QSize virtualScreenSize() const;
|
QSize virtualScreenSize() const;
|
||||||
QRect virtualScreenGeometry() const;
|
QRect virtualScreenGeometry() const;
|
||||||
|
|
||||||
|
VirtualDesktop *currentVirtualDesktop() const;
|
||||||
|
void setCurrentVirtualDesktop(VirtualDesktop *desktop);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the geometry a Client can use with the specified option.
|
* Returns the geometry a Client can use with the specified option.
|
||||||
* This method should be preferred over other methods providing screen sizes as the
|
* This method should be preferred over other methods providing screen sizes as the
|
||||||
|
|
Loading…
Reference in a new issue