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()