From 8f7f97148c51abd62406bd0b9ecdd5b102047531 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 2 Feb 2024 19:28:59 +0200 Subject: [PATCH] plugins/desktopchangeosd: Fix previous desktop indicator BUG: 480630 --- .../package/contents/ui/main.qml | 3 +- .../package/contents/ui/osd.qml | 58 ++++++++----------- src/scripting/workspace_wrapper.h | 2 +- 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/plugins/desktopchangeosd/package/contents/ui/main.qml b/src/plugins/desktopchangeosd/package/contents/ui/main.qml index 0a31c7ab59..41195fdfa5 100644 --- a/src/plugins/desktopchangeosd/package/contents/ui/main.qml +++ b/src/plugins/desktopchangeosd/package/contents/ui/main.qml @@ -14,10 +14,11 @@ Loader { Connections { target: Workspace - function onCurrentDesktopChanged() { + function onCurrentDesktopChanged(previous) { if (!mainItemLoader.item) { mainItemLoader.source = "osd.qml"; } + mainItemLoader.item.show(previous); } } } diff --git a/src/plugins/desktopchangeosd/package/contents/ui/osd.qml b/src/plugins/desktopchangeosd/package/contents/ui/osd.qml index 6da8cbe0dc..e8428ccb41 100644 --- a/src/plugins/desktopchangeosd/package/contents/ui/osd.qml +++ b/src/plugins/desktopchangeosd/package/contents/ui/osd.qml @@ -30,34 +30,6 @@ PlasmaCore.Dialog { } } - function show() { - if (Workspace.isEffectActive("overview")) { - return; - } - const index = Workspace.desktops.indexOf(Workspace.currentDesktop); - if (dialogItem.currentIndex === index) { - return; - } - dialogItem.previousIndex = dialogItem.currentIndex; - timer.stop(); - dialogItem.currentIndex = index; - // screen geometry might have changed - var screen = Workspace.clientArea(KWin.FullScreenArea, Workspace.activeScreen, Workspace.currentDesktop); - dialogItem.screenWidth = screen.width; - dialogItem.screenHeight = screen.height; - if (dialogItem.showGrid) { - // non dependable properties might have changed - view.columns = Workspace.desktopGridWidth; - view.rows = Workspace.desktopGridHeight; - } - dialog.visible = true; - // position might have changed - dialog.x = screen.x + screen.width/2 - dialogItem.width/2; - dialog.y = screen.y + screen.height/2 - dialogItem.height/2; - // start the hide timer - timer.start(); - } - id: dialogItem property int screenWidth: 0 property int screenHeight: 0 @@ -275,12 +247,6 @@ PlasmaCore.Dialog { onTriggered: dialog.visible = false } - Connections { - target: Workspace - function onCurrentDesktopChanged() { - dialogItem.show() - } - } Connections { target: Options function onConfigChanged() { @@ -291,7 +257,29 @@ PlasmaCore.Dialog { view.columns = Workspace.desktopGridWidth; view.rows = Workspace.desktopGridHeight; dialogItem.loadConfig(); - dialogItem.show(); } } + + function show(previous) { + if (Workspace.isEffectActive("overview")) { + return; + } + dialogItem.previousIndex = Workspace.desktops.indexOf(previous); + dialogItem.currentIndex = Workspace.desktops.indexOf(Workspace.currentDesktop); + // screen geometry might have changed + var screen = Workspace.clientArea(KWin.FullScreenArea, Workspace.activeScreen, Workspace.currentDesktop); + dialogItem.screenWidth = screen.width; + dialogItem.screenHeight = screen.height; + if (dialogItem.showGrid) { + // non dependable properties might have changed + view.columns = Workspace.desktopGridWidth; + view.rows = Workspace.desktopGridHeight; + } + dialog.visible = true; + // position might have changed + dialog.x = screen.x + screen.width/2 - dialogItem.width/2; + dialog.y = screen.y + screen.height/2 - dialogItem.height/2; + // start the hide timer + timer.restart(); + } } diff --git a/src/scripting/workspace_wrapper.h b/src/scripting/workspace_wrapper.h index 17199ef177..d4edf62b8e 100644 --- a/src/scripting/workspace_wrapper.h +++ b/src/scripting/workspace_wrapper.h @@ -121,7 +121,7 @@ Q_SIGNALS: /** * This signal is emitted when the current virtual desktop changes. */ - void currentDesktopChanged(); + void currentDesktopChanged(KWin::VirtualDesktop *previous); /** * This signal is emitted when the cursor position changes. * @see cursorPos()