From 40a06a23a990c46fe2c67defc4c61cc7cbbe37cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Fri, 6 Feb 2015 23:10:59 +0100 Subject: [PATCH] ShadeHover highlighted windows in tabbox The setting says "show selected window" ;-) BUG: 186206 FIXED-IN: 5.3 REVIEW: 122472 --- tabbox/autotests/mock_tabboxhandler.h | 4 ++++ tabbox/tabbox.cpp | 24 ++++++++++++++++++------ tabbox/tabbox.h | 3 +++ tabbox/tabboxhandler.cpp | 21 ++++++++++++++++++--- tabbox/tabboxhandler.h | 9 ++++++++- 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/tabbox/autotests/mock_tabboxhandler.h b/tabbox/autotests/mock_tabboxhandler.h index 4e1af12df1..588a04ba71 100644 --- a/tabbox/autotests/mock_tabboxhandler.h +++ b/tabbox/autotests/mock_tabboxhandler.h @@ -56,6 +56,10 @@ public: Q_UNUSED(tabbox) Q_UNUSED(elevate) } + virtual void shadeClient(TabBox::TabBoxClient *c, bool b) const { + Q_UNUSED(c) + Q_UNUSED(b) + } virtual void hideOutline() { } virtual QWeakPointer< TabBox::TabBoxClient > nextClientFocusChain(TabBox::TabBoxClient *client) const; diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp index 8662f0a093..f81a40717f 100644 --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -311,6 +311,15 @@ void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, WId tabbox, bool b) const w->elevate(b); } +void TabBoxHandlerImpl::shadeClient(TabBoxClient *c, bool b) const +{ + Client *cl = static_cast(c)->client(); + cl->cancelShadeHoverTimer(); // stop core shading action + if (!b && cl->shadeMode() == ShadeNormal) + cl->setShade(ShadeHover); + else if (b && cl->shadeMode() == ShadeHover) + cl->setShade(ShadeNormal); +} QWeakPointer TabBoxHandlerImpl::desktopClient() const { @@ -1107,6 +1116,12 @@ void TabBox::slotWalkBackThroughDesktopList() } } +void TabBox::shadeActivate(Client *c) +{ + if ((c->shadeMode() == ShadeNormal || c->shadeMode() == ShadeHover) && options->isShadeHover()) + c->setShade(ShadeActivated); +} + bool TabBox::toggle(ElectricBorder eb) { if (!options->focusPolicyIsReasonable()) @@ -1216,8 +1231,7 @@ void TabBox::CDEWalkThroughWindows(bool forward) Workspace::self()->lowerClient(c); if (options->focusPolicyIsReasonable()) { Workspace::self()->activateClient(nc); - if (nc->isShade() && options->isShadeHover()) - nc->setShade(ShadeActivated); + shadeActivate(nc); } else { if (!nc->isOnDesktop(currentDesktop())) setCurrentDesktop(nc->desktop()); @@ -1233,8 +1247,7 @@ void TabBox::KDEOneStepThroughWindows(bool forward, TabBoxMode mode) nextPrev(forward); if (Client* c = currentClient()) { Workspace::self()->activateClient(c); - if (c->isShade() && options->isShadeHover()) - c->setShade(ShadeActivated); + shadeActivate(c); } } @@ -1426,8 +1439,7 @@ void TabBox::accept() close(); if (c) { Workspace::self()->activateClient(c); - if (c->isShade() && options->isShadeHover()) - c->setShade(ShadeActivated); + shadeActivate(c); if (c->isDesktop()) Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop()); } diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index b4fd30f3e8..4837f6b262 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -67,6 +67,7 @@ public: virtual void elevateClient(TabBoxClient* c, WId tabbox, bool elevate) const; virtual void raiseClient(TabBoxClient *client) const; virtual void restack(TabBoxClient *c, TabBoxClient *under); + virtual void shadeClient(TabBoxClient *c, bool b) const; virtual QWeakPointer< TabBoxClient > clientToAddToList(KWin::TabBox::TabBoxClient* client, int desktop) const; virtual QWeakPointer< TabBoxClient > desktopClient() const; virtual void activateAndClose(); @@ -231,6 +232,8 @@ private: template void key(const char *actionName, Slot slot, const QKeySequence &shortcut = QKeySequence()); + void shadeActivate(Client *c); + private Q_SLOTS: void reconfigure(); void globalShortcutChanged(QAction *action, const QKeySequence &seq); diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index 11f7c30703..afb48fbb35 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -176,6 +176,7 @@ void TabBoxHandlerPrivate::updateHighlightWindows() q->elevateClient(currentClient, w ? w->winId() : 0, true); } else { if (lastRaisedClient) { + q->shadeClient(lastRaisedClient, true); if (lastRaisedClientSucc) q->restack(lastRaisedClient, lastRaisedClientSucc); // TODO lastRaisedClient->setMinimized( lastRaisedClientWasMinimized ); @@ -183,6 +184,7 @@ void TabBoxHandlerPrivate::updateHighlightWindows() lastRaisedClient = currentClient; if (lastRaisedClient) { + q->shadeClient(lastRaisedClient, false); // TODO if ( (lastRaisedClientWasMinimized = lastRaisedClient->isMinimized()) ) // lastRaisedClient->setMinimized( false ); TabBoxClientList order = q->stackingOrder(); @@ -216,6 +218,13 @@ void TabBoxHandlerPrivate::updateHighlightWindows() void TabBoxHandlerPrivate::endHighlightWindows(bool abort) { TabBoxClient *currentClient = q->client(index); + if (config.isHighlightWindows() && q->isKWinCompositing()) { + foreach (const QWeakPointer &clientPointer, q->stackingOrder()) { + if (QSharedPointer client = clientPointer.toStrongRef()) + if (client != currentClient) // to not mess up with wanted ShadeActive/ShadeHover state + q->shadeClient(client.data(), true); + } + } QWindow *w = window(); if (currentClient) q->elevateClient(currentClient, w ? w->winId() : 0, false); @@ -373,15 +382,21 @@ void TabBoxHandler::show() if (d->config.isHighlightWindows()) { Xcb::sync(); // TODO this should be - // QMetaObject::invokeMethod(this, "updateHighlightWindows", Qt::QueuedConnection); + // QMetaObject::invokeMethod(this, "initHighlightWindows", Qt::QueuedConnection); // but we somehow need to cross > 1 event cycle (likely because of queued invocation in the effects) // to ensure the EffectWindow is present when updateHighlightWindows, thus elevating the window/tabbox - QTimer::singleShot(1, this, SLOT(updateHighlightWindows())); + QTimer::singleShot(1, this, SLOT(initHighlightWindows())); } } -void TabBoxHandler::updateHighlightWindows() +void TabBoxHandler::initHighlightWindows() { + if (isKWinCompositing()) { + foreach (const QWeakPointer &clientPointer, stackingOrder()) { + if (QSharedPointer client = clientPointer.toStrongRef()) + shadeClient(client.data(), false); + } + } d->updateHighlightWindows(); } diff --git a/tabbox/tabboxhandler.h b/tabbox/tabboxhandler.h index d548d3acfb..007a0dc93b 100644 --- a/tabbox/tabboxhandler.h +++ b/tabbox/tabboxhandler.h @@ -180,6 +180,13 @@ public: */ virtual void restack(TabBoxClient *c, TabBoxClient *under) = 0; + /** + * Toggle between ShadeHover and ShadeNormal - not shaded windows are unaffected + * @param c The client to be shaded + * @param b Whether to un- or shade + */ + virtual void shadeClient(TabBoxClient *c, bool b) const = 0; + /** * @return The current stacking order of TabBoxClients */ @@ -334,7 +341,7 @@ Q_SIGNALS: void selectedIndexChanged(); private Q_SLOTS: - void updateHighlightWindows(); + void initHighlightWindows(); private: friend class TabBoxHandlerPrivate;