diff --git a/client.cpp b/client.cpp index 4b88f22a24..b576353ac7 100644 --- a/client.cpp +++ b/client.cpp @@ -1457,6 +1457,7 @@ void Client::setDesktop(int desktop) return; int was_desk = desk; + const bool wasOnCurrentDesktop = isOnCurrentDesktop(); desk = desktop; info->setDesktop(desktop); if ((was_desk == NET::OnAllDesktops) != (desktop == NET::OnAllDesktops)) { @@ -1486,6 +1487,8 @@ void Client::setDesktop(int desktop) if (tabGroup()) tabGroup()->updateStates(this, TabGroup::Desktop); emit desktopChanged(); + if (wasOnCurrentDesktop != isOnCurrentDesktop()) + emit desktopPresenceChanged(this, was_desk); } /** diff --git a/client.h b/client.h index a2b3365e3d..064e82fb9e 100644 --- a/client.h +++ b/client.h @@ -719,6 +719,7 @@ signals: void activeChanged(); void captionChanged(); void desktopChanged(); + void desktopPresenceChanged(KWin::Client*, int); // to be forwarded by Workspace void fullScreenChanged(); void transientChanged(); void modalChanged(); diff --git a/effects.cpp b/effects.cpp index 087eef8f79..1df757df4d 100644 --- a/effects.cpp +++ b/effects.cpp @@ -228,6 +228,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) Workspace *ws = Workspace::self(); VirtualDesktopManager *vds = VirtualDesktopManager::self(); connect(ws, SIGNAL(currentDesktopChanged(int,KWin::Client*)), SLOT(slotDesktopChanged(int,KWin::Client*))); + connect(ws, SIGNAL(desktopPresenceChanged(KWin::Client*,int)), SLOT(slotDesktopPresenceChanged(KWin::Client*,int))); connect(ws, SIGNAL(clientAdded(KWin::Client*)), this, SLOT(slotClientAdded(KWin::Client*))); connect(ws, SIGNAL(unmanagedAdded(KWin::Unmanaged*)), this, SLOT(slotUnmanagedAdded(KWin::Unmanaged*))); connect(ws, SIGNAL(clientActivated(KWin::Client*)), this, SLOT(slotClientActivated(KWin::Client*))); @@ -642,6 +643,11 @@ void EffectsHandlerImpl::slotDesktopChanged(int old, Client *c) } } +void EffectsHandlerImpl::slotDesktopPresenceChanged(Client *c, int old) +{ + emit desktopPresenceChanged(c->effectWindow(), old, c->desktop()); +} + void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRect& r) { if (!t->effectWindow()) { diff --git a/effects.h b/effects.h index 43f2c14642..b02dc839a0 100644 --- a/effects.h +++ b/effects.h @@ -214,6 +214,7 @@ public Q_SLOTS: protected Q_SLOTS: void slotDesktopChanged(int old, KWin::Client *withClient); + void slotDesktopPresenceChanged(KWin::Client *c, int old); void slotClientAdded(KWin::Client *c); void slotClientShown(KWin::Toplevel*); void slotUnmanagedAdded(KWin::Unmanaged *u); diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 62b0a4f0c3..9a03eeb335 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -947,6 +947,15 @@ Q_SIGNALS: * @deprecated */ void desktopChanged(int oldDesktop, int newDesktop); + /** + * Signal emitted when a window moved to another desktop + * NOTICE that this does NOT imply that the desktop has changed + * The @param window which is moved to the new desktop + * @param oldDesktop The previous desktop of the window + * @param newDesktop The new desktop of the window + * @since 4.11.4 + */ + void desktopPresenceChanged(KWin::EffectWindow *window, int oldDesktop, int newDesktop); /** * Signal emitted when the number of currently existing desktops is changed. * @param old The previous number of desktops in used. diff --git a/workspace.cpp b/workspace.cpp index 8235aaa48a..e7f103f99c 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -471,6 +471,7 @@ Client* Workspace::createClient(xcb_window_t w, bool is_mapped) #ifdef KWIN_BUILD_SCREENEDGES connect(c, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), ScreenEdges::self(), SIGNAL(checkBlocking())); #endif + connect(c, SIGNAL(desktopPresenceChanged(KWin::Client*,int)), SIGNAL(desktopPresenceChanged(KWin::Client*,int)), Qt::QueuedConnection); if (!c->manage(w, is_mapped)) { Client::deleteClient(c); return NULL; @@ -1166,8 +1167,6 @@ void Workspace::sendClientToDesktop(Client* c, int desk, bool dont_activate) return; desk = c->desktop(); // Client did range checking - emit desktopPresenceChanged(c, old_desktop); - if (c->isOnDesktop(VirtualDesktopManager::self()->current())) { if (c->wantsTabFocus() && options->focusPolicyIsReasonable() && !was_on_desktop && // for stickyness changes