From 16b1cae73e05b0195f74d67ba60d090019127609 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 31 Jul 2020 11:11:26 +0200 Subject: [PATCH] when task switch appears release minimize on launchers --- .../homescreen/applicationlistmodel.cpp | 31 ++++++++++++++++--- .../homescreen/applicationlistmodel.h | 1 + .../package/contents/ui/launcher/Delegate.qml | 26 ++++++++++------ .../taskpanel/package/contents/ui/Task.qml | 7 ++--- .../package/contents/ui/TaskSwitcher.qml | 13 ++++++++ 5 files changed, 60 insertions(+), 18 deletions(-) diff --git a/containments/homescreen/applicationlistmodel.cpp b/containments/homescreen/applicationlistmodel.cpp index 6823d29e..fe7030a3 100644 --- a/containments/homescreen/applicationlistmodel.cpp +++ b/containments/homescreen/applicationlistmodel.cpp @@ -453,10 +453,6 @@ void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate) return; } - if (!delegate || !delegate->parentItem() || !delegate->window()) { - return; - } - QWindow *delegateWindow = delegate->window(); if (!delegateWindow) { @@ -480,5 +476,32 @@ void ApplicationListModel::setMinimizedDelegate(int row, QQuickItem *delegate) window->setMinimizedGeometry(surface, rect); } +void ApplicationListModel::unsetMinimizedDelegate(int row, QQuickItem *delegate) +{ + if (row < 0 || row >= m_applicationList.count()) { + return; + } + + QWindow *delegateWindow = delegate->window(); + + if (!delegateWindow) { + return; + } + + using namespace KWayland::Client; + KWayland::Client::PlasmaWindow *window = m_applicationList[row].window; + if (!window) { + return; + } + + Surface *surface = Surface::fromWindow(delegateWindow); + + if (!surface) { + return; + } +qWarning()<<"UNSETTING"<title(); + window->unsetMinimizedGeometry(surface); +} + #include "moc_applicationlistmodel.cpp" diff --git a/containments/homescreen/applicationlistmodel.h b/containments/homescreen/applicationlistmodel.h index 9df10206..2e957dad 100644 --- a/containments/homescreen/applicationlistmodel.h +++ b/containments/homescreen/applicationlistmodel.h @@ -107,6 +107,7 @@ public: Q_INVOKABLE void loadApplications(); Q_INVOKABLE void setMinimizedDelegate(int row, QQuickItem *delegate); + Q_INVOKABLE void unsetMinimizedDelegate(int row, QQuickItem *delegate); public Q_SLOTS: void sycocaDbChanged(const QStringList &change); diff --git a/containments/homescreen/package/contents/ui/launcher/Delegate.qml b/containments/homescreen/package/contents/ui/launcher/Delegate.qml index bd8c331a..e9ca464d 100644 --- a/containments/homescreen/package/contents/ui/launcher/Delegate.qml +++ b/containments/homescreen/package/contents/ui/launcher/Delegate.qml @@ -51,11 +51,21 @@ ContainmentLayoutManager.ItemContainer { signal launch(int x, int y, var source, string title) + function syncDelegateGeometry() { + if (!applicationRunning) { + return; + } + + if (!MobileShell.HomeScreenControls.taskSwitcherVisible) { + plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); + } else { + plasmoid.nativeInterface.applicationListModel.unsetMinimizedDelegate(index, delegate); + } + } + readonly property bool applicationRunning: model.applicationRunning onApplicationRunningChanged: { - if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { - plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); - } + syncDelegateGeometry(); } Connections { target: mainFlickable @@ -63,17 +73,13 @@ ContainmentLayoutManager.ItemContainer { cancelEdit() } function onContentYChanged() { - if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { - plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); - } + syncDelegateGeometry() } } Connections { target: MobileShell.HomeScreenControls - function taskSwitcherVisibleChanged() { - if (applicationRunning && !MobileShell.HomeScreenControls.taskSwitcherVisible) { - plasmoid.nativeInterface.applicationListModel.setMinimizedDelegate(index, delegate); - } + function onTaskSwitcherVisibleChanged() { + syncDelegateGeometry(); } } onDragActiveChanged: { diff --git a/containments/taskpanel/package/contents/ui/Task.qml b/containments/taskpanel/package/contents/ui/Task.qml index ff8f3347..4c826aa6 100644 --- a/containments/taskpanel/package/contents/ui/Task.qml +++ b/containments/taskpanel/package/contents/ui/Task.qml @@ -132,10 +132,9 @@ Item { } onPressed: delegate.z = 10; onClicked: { - if (model.IsActive) { - window.hide(); - } else { - window.setSingleActiveWindow(model.index, delegate); + window.setSingleActiveWindow(model.index, delegate); + if (!model.IsMinimized) { + window.visible = false; } } onReleased: { diff --git a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml index 421b916a..bf30f299 100644 --- a/containments/taskpanel/package/contents/ui/TaskSwitcher.qml +++ b/containments/taskpanel/package/contents/ui/TaskSwitcher.qml @@ -98,8 +98,17 @@ NanoShell.FullScreenOverlay { onVisibleChanged: { if (!visible) { tasksView.contentY = 0; + moveTransition.enabled = false; + scrollAnim.running = false; + activateAnim.running = false; + window.contentItem.opacity = 1; + if (activateAnim.delegate) { + activateAnim.delegate.z = 0; + activateAnim.delegate.scale = 1; + } } MobileShell.HomeScreenControls.taskSwitcherVisible = visible; + print("BBBB"+MobileShell.HomeScreenControls.taskSwitcherVisible) } SequentialAnimation { @@ -121,6 +130,8 @@ NanoShell.FullScreenOverlay { if (tasksView.contentY <= 0 || tasksView.contentY >= tasksView.contentHeight - window.height) { window.visible = false; setSingleActiveWindow(currentTaskIndex); + } else { + moveTransition.enabled = true; } } } @@ -262,6 +273,8 @@ NanoShell.FullScreenOverlay { } move: Transition { + id: moveTransition + enabled: false NumberAnimation { properties: "x,y" duration: units.longDuration