scripting: Drop Window.desktop property

master
Vlad Zahorodnii 2 years ago
parent ecb58c987f
commit 017bb6d3c8

@ -43,11 +43,11 @@ FocusScope {
effect.swapDesktops(drag.source.desktop.x11DesktopNumber, desktop.x11DesktopNumber); effect.swapDesktops(drag.source.desktop.x11DesktopNumber, desktop.x11DesktopNumber);
} else { } else {
// dragging a KWin::Window // dragging a KWin::Window
if (drag.source.desktop === desktopView.desktop.x11DesktopNumber) { if (drag.source.desktops.length === 0 || drag.source.desktops.indexOf(desktopView.desktop) !== -1) {
drop.action = Qt.IgnoreAction; drop.action = Qt.IgnoreAction;
return; return;
} }
drag.source.desktop = desktopView.desktop.x11DesktopNumber; drag.source.desktops = [desktopView.desktop];
} }
} }
} }
@ -61,7 +61,7 @@ FocusScope {
if (!desktopView.contains(desktopView.mapFromItem(null, pos.x, pos.y))) { if (!desktopView.contains(desktopView.mapFromItem(null, pos.x, pos.y))) {
return; return;
} }
item.client.desktop = desktopView.desktop.x11DesktopNumber; item.client.desktops = [desktopView.desktop];
} }
} }
Repeater { Repeater {
@ -137,10 +137,10 @@ FocusScope {
if (eventPoint.event.button === Qt.MiddleButton) { if (eventPoint.event.button === Qt.MiddleButton) {
window.closeWindow(); window.closeWindow();
} else if (eventPoint.event.button === Qt.RightButton) { } else if (eventPoint.event.button === Qt.RightButton) {
if (window.desktop > -1) { if (window.desktops.length > 0) {
window.desktop = -1; window.desktops = [];
} else { } else {
window.desktop = desktopView.desktop.x11DesktopNumber; window.desktops = [desktopView.desktop];
} }
} }
} }

@ -203,11 +203,11 @@ Item {
onDropped: drop => { onDropped: drop => {
drop.accepted = true; drop.accepted = true;
// dragging a KWin::Window // dragging a KWin::Window
if (drag.source.desktop === delegate.desktop.x11DesktopNumber) { if (drag.source.desktops.length === 0 || drag.source.desktops.indexOf(delegate.desktop) !== -1) {
drop.action = Qt.IgnoreAction; drop.action = Qt.IgnoreAction;
return; return;
} }
drag.source.desktop = delegate.desktop.x11DesktopNumber; drag.source.desktops = [delegate.desktop];
} }
} }
} }
@ -304,8 +304,8 @@ Item {
drag.accepted = desktopModel.rowCount() < 20 drag.accepted = desktopModel.rowCount() < 20
} }
onDropped: { onDropped: {
desktopModel.create(desktopModel.rowCount()); const desktop = desktopModel.create(desktopModel.rowCount());
drag.source.desktop = desktopModel.rowCount() + 1; drag.source.desktops = [desktop];
} }
} }
} }

@ -23,9 +23,9 @@ VirtualDesktopModel::VirtualDesktopModel(QObject *parent)
m_virtualDesktops = manager->desktops(); m_virtualDesktops = manager->desktops();
} }
void VirtualDesktopModel::create(uint position, const QString &name) VirtualDesktop *VirtualDesktopModel::create(uint position, const QString &name)
{ {
VirtualDesktopManager::self()->createVirtualDesktop(position, name); return VirtualDesktopManager::self()->createVirtualDesktop(position, name);
} }
void VirtualDesktopModel::remove(uint position) void VirtualDesktopModel::remove(uint position)

@ -31,7 +31,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
public Q_SLOTS: public Q_SLOTS:
void create(uint position, const QString &name = QString()); KWin::VirtualDesktop *create(uint position, const QString &name = QString());
void remove(uint position); void remove(uint position);
private: private:

@ -310,13 +310,6 @@ class KWIN_EXPORT Window : public QObject
*/ */
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
/**
* The desktop this Window is on. If the Window is on all desktops the property has value -1.
*
* @deprecated Use the desktops property instead.
*/
Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
/** /**
* The virtual desktops this client is on. If it's on all desktops, the list is empty. * The virtual desktops this client is on. If it's on all desktops, the list is empty.
*/ */

Loading…
Cancel
Save