From 017bb6d3c8b80d3b9ad05874ab47c39de22efda8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 17 Feb 2023 17:52:57 +0200 Subject: [PATCH] scripting: Drop Window.desktop property --- src/effects/desktopgrid/qml/DesktopView.qml | 12 ++++++------ src/effects/overview/qml/DesktopBar.qml | 8 ++++---- src/scripting/virtualdesktopmodel.cpp | 4 ++-- src/scripting/virtualdesktopmodel.h | 2 +- src/window.h | 7 ------- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/effects/desktopgrid/qml/DesktopView.qml b/src/effects/desktopgrid/qml/DesktopView.qml index 2f10f63b56..0fb44eaa09 100644 --- a/src/effects/desktopgrid/qml/DesktopView.qml +++ b/src/effects/desktopgrid/qml/DesktopView.qml @@ -43,11 +43,11 @@ FocusScope { effect.swapDesktops(drag.source.desktop.x11DesktopNumber, desktop.x11DesktopNumber); } else { // 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; 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))) { return; } - item.client.desktop = desktopView.desktop.x11DesktopNumber; + item.client.desktops = [desktopView.desktop]; } } Repeater { @@ -137,10 +137,10 @@ FocusScope { if (eventPoint.event.button === Qt.MiddleButton) { window.closeWindow(); } else if (eventPoint.event.button === Qt.RightButton) { - if (window.desktop > -1) { - window.desktop = -1; + if (window.desktops.length > 0) { + window.desktops = []; } else { - window.desktop = desktopView.desktop.x11DesktopNumber; + window.desktops = [desktopView.desktop]; } } } diff --git a/src/effects/overview/qml/DesktopBar.qml b/src/effects/overview/qml/DesktopBar.qml index 5a86d32921..76783fdaf5 100644 --- a/src/effects/overview/qml/DesktopBar.qml +++ b/src/effects/overview/qml/DesktopBar.qml @@ -203,11 +203,11 @@ Item { onDropped: drop => { drop.accepted = true; // 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; return; } - drag.source.desktop = delegate.desktop.x11DesktopNumber; + drag.source.desktops = [delegate.desktop]; } } } @@ -304,8 +304,8 @@ Item { drag.accepted = desktopModel.rowCount() < 20 } onDropped: { - desktopModel.create(desktopModel.rowCount()); - drag.source.desktop = desktopModel.rowCount() + 1; + const desktop = desktopModel.create(desktopModel.rowCount()); + drag.source.desktops = [desktop]; } } } diff --git a/src/scripting/virtualdesktopmodel.cpp b/src/scripting/virtualdesktopmodel.cpp index 7de2379e48..c42033ef80 100644 --- a/src/scripting/virtualdesktopmodel.cpp +++ b/src/scripting/virtualdesktopmodel.cpp @@ -23,9 +23,9 @@ VirtualDesktopModel::VirtualDesktopModel(QObject *parent) 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) diff --git a/src/scripting/virtualdesktopmodel.h b/src/scripting/virtualdesktopmodel.h index a2a7ee0589..1397913a10 100644 --- a/src/scripting/virtualdesktopmodel.h +++ b/src/scripting/virtualdesktopmodel.h @@ -31,7 +31,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; public Q_SLOTS: - void create(uint position, const QString &name = QString()); + KWin::VirtualDesktop *create(uint position, const QString &name = QString()); void remove(uint position); private: diff --git a/src/window.h b/src/window.h index f9a96849ac..f047b345e6 100644 --- a/src/window.h +++ b/src/window.h @@ -310,13 +310,6 @@ class KWIN_EXPORT Window : public QObject */ 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. */