From c378bf4f7cdd496c1526eb5f3d97bcedd7b5890a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 17 Nov 2013 21:45:21 +0100 Subject: [PATCH] emit desktopPresenceChanged from Client:setDesktop and forward it to scripted effects CCBUG: 326903 REVIEW: 114080 --- client.cpp | 3 +++ client.h | 1 + effects.cpp | 6 ++++++ effects.h | 1 + libkwineffects/kwineffects.h | 9 +++++++++ workspace.cpp | 3 +-- 6 files changed, 21 insertions(+), 2 deletions(-) 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