From 970e8765f0d0b9f321303bf0b1b2c04085cdf181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 20 Mar 2014 13:39:00 +0100 Subject: [PATCH] [kwin] Remove support for _NET_WM_TAKE_ACTIVITY protocol As can be seen in [1] the patches to KWin were in CVS HEAD before the protocol got standardized and it never got any adoption. It's neither in the NETWM spec, nor implemented in Qt4 nor in Qt5. KWin did not even add the protocol to the NET::Supported property. Thus it doesn't make much sense to keep a protocol which nobody speaks. Still the code around the protocol is kept and also the names are kept. Only difference is that Client::takeActivity got removed and the code moved to the only calling place in Workspace. Motivated by that change the enum defined in utils.h is moved into Workspace, it's turned into a proper QFlags class and used as a type in the method argument instead of a generic long. [1] https://mail.gnome.org/archives/wm-spec-list/2004-April/msg00013.html REVIEW: 116922 --- activation.cpp | 25 ++++++++----------------- bridge.cpp | 2 +- client.cpp | 34 ---------------------------------- client.h | 4 +--- events.cpp | 5 +---- layers.cpp | 1 - netinfo.cpp | 7 ------- netinfo.h | 1 - useractions.cpp | 12 ++++++------ utils.h | 7 ------- workspace.cpp | 9 --------- workspace.h | 12 ++++++++---- 12 files changed, 25 insertions(+), 94 deletions(-) diff --git a/activation.cpp b/activation.cpp index 877e6e8dfb..cde06b4c37 100644 --- a/activation.cpp +++ b/activation.cpp @@ -262,7 +262,6 @@ void Workspace::setActiveClient(Client* c) } } } - pending_take_activity = NULL; updateToolWindows(false); if (c) @@ -336,10 +335,10 @@ void Workspace::activateClient(Client* c, bool force) */ void Workspace::requestFocus(Client* c, bool force) { - takeActivity(c, ActivityFocus | (force ? ActivityFocusForce : 0), false); + takeActivity(c, force ? ActivityFocusForce : ActivityFocus); } -void Workspace::takeActivity(Client* c, int flags, bool handled) +void Workspace::takeActivity(Client* c, ActivityFlags flags) { // the 'if ( c == active_client ) return;' optimization mustn't be done here if (!focusChangeEnabled() && (c != active_client)) @@ -365,7 +364,6 @@ void Workspace::takeActivity(Client* c, int flags, bool handled) if (flags & ActivityRaise) raiseClient(c); c = modal; - handled = false; } cancelDelayFocus(); } @@ -378,7 +376,6 @@ void Workspace::takeActivity(Client* c, int flags, bool handled) focusToNull(); } flags &= ~ActivityFocus; - handled = false; // no point, can't get clicks } if (c->tabGroup() && c->tabGroup()->current() != c) c->tabGroup()->setCurrent(c); @@ -386,22 +383,16 @@ void Workspace::takeActivity(Client* c, int flags, bool handled) qWarning() << "takeActivity: not shown" ; return; } - c->takeActivity(flags, handled); + + if (flags & ActivityFocus) + c->takeFocus(); + if (flags & ActivityRaise) + workspace()->raiseClient(c); + if (!c->isOnActiveScreen()) screens()->setCurrent(c->screen()); } -void Workspace::handleTakeActivity(KWin::Client *c, xcb_timestamp_t /*timestamp*/, int flags) -{ - if (pending_take_activity != c) // pending_take_activity is reset when doing restack or activation - return; - if ((flags & ActivityRaise) != 0) - raiseClient(c); - if ((flags & ActivityFocus) != 0 && c->isShown(false)) - c->takeFocus(); - pending_take_activity = NULL; -} - /*! Informs the workspace that the client \a c has been hidden. If it was the active client (or to-become the active client), diff --git a/bridge.cpp b/bridge.cpp index dbdeb41f2f..55faf53ca4 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -347,7 +347,7 @@ void Bridge::untab(long id, const QRect& newGeom) if (Client* client = clientForId(id)) if (client->untab(newGeom)) { if (options->focusPolicyIsReasonable()) - workspace()->takeActivity(client, ActivityFocus | ActivityRaise, true); + workspace()->takeActivity(client, Workspace::ActivityFocus | Workspace::ActivityRaise); workspace()->raiseClient(client); } } diff --git a/client.cpp b/client.cpp index 2f98692b89..7d4ef33d8b 100644 --- a/client.cpp +++ b/client.cpp @@ -273,7 +273,6 @@ Client::Client() Pdeletewindow = 0; Ptakefocus = 0; - Ptakeactivity = 0; Pcontexthelp = 0; Pping = 0; input = false; @@ -1731,36 +1730,6 @@ void Client::setOnAllActivities(bool on) #endif } -/** - * Performs activation and/or raising of the window - */ -void Client::takeActivity(int flags, bool handled) -{ - if (!handled || !Ptakeactivity) { - if (flags & ActivityFocus) - takeFocus(); - if (flags & ActivityRaise) - workspace()->raiseClient(this); - return; - } - -#ifndef NDEBUG - static Time previous_activity_timestamp; - static Client* previous_client; - - //if ( previous_activity_timestamp == xTime() && previous_client != this ) - // { - // qDebug() << "Repeated use of the same X timestamp for activity"; - // qDebug() << kBacktrace(); - // } - - previous_activity_timestamp = xTime(); - previous_client = this; -#endif - - workspace()->sendTakeActivity(this, xTime(), flags); -} - /** * Performs the actual focusing of the window using XSetInputFocus and WM_TAKE_FOCUS */ @@ -2160,7 +2129,6 @@ void Client::getWindowProtocols() Pdeletewindow = 0; Ptakefocus = 0; - Ptakeactivity = 0; Pcontexthelp = 0; Pping = 0; @@ -2170,8 +2138,6 @@ void Client::getWindowProtocols() Pdeletewindow = 1; else if (p[i] == atoms->wm_take_focus) Ptakefocus = 1; - else if (p[i] == atoms->net_wm_take_activity) - Ptakeactivity = 1; else if (p[i] == atoms->net_wm_context_help) Pcontexthelp = 1; else if (p[i] == atoms->net_wm_ping) diff --git a/client.h b/client.h index 01067ce828..5f5ac91583 100644 --- a/client.h +++ b/client.h @@ -414,7 +414,6 @@ public: bool isMovableAcrossScreens() const; bool isCloseable() const; ///< May be closed by the user (May have a close button) - void takeActivity(int flags, bool handled); // Takes ActivityFlags as arg (in utils.h) void takeFocus(); bool isDemandingAttention() const { return demands_attention; @@ -465,7 +464,7 @@ public: void setShortcut(const QString& cut); WindowOperation mouseButtonToWindowOperation(Qt::MouseButtons button); - bool performMouseCommand(Options::MouseCommand, const QPoint& globalPos, bool handled = false); + bool performMouseCommand(Options::MouseCommand, const QPoint& globalPos); QRect adjustedClientArea(const QRect& desktop, const QRect& area) const; @@ -907,7 +906,6 @@ private: uint original_skip_taskbar : 1; ///< Unaffected by KWin uint Pdeletewindow : 1; ///< Does the window understand the DeleteWindow protocol? uint Ptakefocus : 1;///< Does the window understand the TakeFocus protocol? - uint Ptakeactivity : 1; ///< Does it support _NET_WM_TAKE_ACTIVITY uint Pcontexthelp : 1; ///< Does the window understand the ContextHelp protocol? uint Pping : 1; ///< Does it support _NET_WM_PING? uint input : 1; ///< Does the window want input in its wm_hints diff --git a/events.cpp b/events.cpp index 463462dc15..bed8efd891 100644 --- a/events.cpp +++ b/events.cpp @@ -1066,7 +1066,6 @@ bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int Options::MouseCommand com = Options::MouseNothing; bool was_action = false; - bool perform_handled = false; if (bModKeyHeld) { was_action = true; switch(button) { @@ -1088,7 +1087,6 @@ bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int // inactive inner window if (!isActive() && w == wrapperId() && button < 6) { was_action = true; - perform_handled = true; switch(button) { case XCB_BUTTON_INDEX_1: com = options->commandWindow1(); @@ -1110,11 +1108,10 @@ bool Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int && options->isClickRaise() && button < 4) { // exclude wheel com = Options::MouseActivateRaiseAndPassClick; was_action = true; - perform_handled = true; } } if (was_action) { - bool replay = performMouseCommand(com, QPoint(x_root, y_root), perform_handled); + bool replay = performMouseCommand(com, QPoint(x_root, y_root)); if (isSpecialWindow()) replay = true; diff --git a/layers.cpp b/layers.cpp index de03f18037..1d15e780f7 100644 --- a/layers.cpp +++ b/layers.cpp @@ -384,7 +384,6 @@ void Workspace::raiseClient(Client* c, bool nogroup) if (!c->isSpecialWindow()) { most_recently_raised = c; - pending_take_activity = NULL; } } diff --git a/netinfo.cpp b/netinfo.cpp index b97ca3a14b..391ffb3956 100644 --- a/netinfo.cpp +++ b/netinfo.cpp @@ -193,13 +193,6 @@ void RootInfo::restackWindow(xcb_window_t w, RequestSource src, xcb_window_t abo } } -void RootInfo::gotTakeActivity(xcb_window_t w, xcb_timestamp_t timestamp, long flags) -{ - Workspace *workspace = Workspace::self(); - if (Client* c = workspace->findClient(WindowMatchPredicate(w))) - workspace->handleTakeActivity(c, timestamp, flags); -} - void RootInfo::closeWindow(xcb_window_t w) { Client* c = Workspace::self()->findClient(WindowMatchPredicate(w)); diff --git a/netinfo.h b/netinfo.h index 4fc4188335..46a91b1402 100644 --- a/netinfo.h +++ b/netinfo.h @@ -53,7 +53,6 @@ protected: virtual void moveResizeWindow(xcb_window_t w, int flags, int x, int y, int width, int height) override; virtual void gotPing(xcb_window_t w, xcb_timestamp_t timestamp) override; virtual void restackWindow(xcb_window_t w, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp) override; - virtual void gotTakeActivity(xcb_window_t w, xcb_timestamp_t timestamp, long flags) override; virtual void changeShowingDesktop(bool showing) override; private: diff --git a/useractions.cpp b/useractions.cpp index a483d8d93f..834fe055c1 100755 --- a/useractions.cpp +++ b/useractions.cpp @@ -1088,7 +1088,7 @@ void Workspace::performWindowOperation(Client* c, Options::WindowOperation op) break; case Options::RemoveTabFromGroupOp: if (c->untab(c->geometry().translated(cascadeOffset(c))) && options->focusPolicyIsReasonable()) - takeActivity(c, ActivityFocus | ActivityRaise, true); + takeActivity(c, ActivityFocus | ActivityRaise); break; case Options::ActivateNextTabOp: if (c->tabGroup()) @@ -1133,7 +1133,7 @@ Options::WindowOperation Client::mouseButtonToWindowOperation(Qt::MouseButtons b /*! Performs a mouse command on this client (see options.h) */ -bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &globalPos, bool handled) +bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &globalPos) { bool replay = false; switch(command) { @@ -1184,7 +1184,7 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl mustReplay = !(c->isOnCurrentDesktop() && c->isOnCurrentActivity() && c->geometry().intersects(geometry())); } } - workspace()->takeActivity(this, ActivityFocus | ActivityRaise, handled && replay); + workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise); screens()->setCurrent(globalPos); replay = replay || mustReplay; break; @@ -1197,17 +1197,17 @@ bool Client::performMouseCommand(Options::MouseCommand command, const QPoint &gl break; case Options::MouseActivate: replay = isActive(); // for clickraise mode - workspace()->takeActivity(this, ActivityFocus, handled && replay); + workspace()->takeActivity(this, Workspace::ActivityFocus); screens()->setCurrent(globalPos); replay = replay || !rules()->checkAcceptFocus(input); break; case Options::MouseActivateRaiseAndPassClick: - workspace()->takeActivity(this, ActivityFocus | ActivityRaise, handled); + workspace()->takeActivity(this, Workspace::ActivityFocus | Workspace::ActivityRaise); screens()->setCurrent(globalPos); replay = true; break; case Options::MouseActivateAndPassClick: - workspace()->takeActivity(this, ActivityFocus, handled); + workspace()->takeActivity(this, Workspace::ActivityFocus); screens()->setCurrent(globalPos); replay = true; break; diff --git a/utils.h b/utils.h index a39fb65962..5e8c0ccf41 100644 --- a/utils.h +++ b/utils.h @@ -89,13 +89,6 @@ inline void operator++(Layer& lay) lay = static_cast< Layer >(lay + 1); } -// for Client::takeActivity() -enum ActivityFlags { - ActivityFocus = 1 << 0, // focus the window - ActivityFocusForce = 1 << 1, // focus even if Dock etc. - ActivityRaise = 1 << 2 // raise the window -}; - enum StrutArea { StrutAreaInvalid = 0, // Null StrutAreaTop = 1 << 0, diff --git a/workspace.cpp b/workspace.cpp index d5f1181fcb..fe89e5dffb 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -115,7 +115,6 @@ Workspace::Workspace(bool restore) , last_active_client(0) , most_recently_raised(0) , movingClient(0) - , pending_take_activity(NULL) , delayfocus_client(0) , force_restacking(false) , x_stacking_dirty(true) @@ -591,8 +590,6 @@ void Workspace::removeClient(Client* c) Q_ASSERT(c != active_client); if (c == last_active_client) last_active_client = 0; - if (c == pending_take_activity) - pending_take_activity = NULL; if (c == delayfocus_client) cancelDelayFocus(); @@ -1203,12 +1200,6 @@ void Workspace::sendPingToWindow(xcb_window_t window, xcb_timestamp_t timestamp) rootInfo()->sendPing(window, timestamp); } -void Workspace::sendTakeActivity(KWin::Client *c, xcb_timestamp_t timestamp, long int flags) -{ - rootInfo()->takeActivity(c->window(), timestamp, flags); - pending_take_activity = c; -} - /** * Delayed focus functions */ diff --git a/workspace.h b/workspace.h index 5563b2ab07..8529152ed5 100644 --- a/workspace.h +++ b/workspace.h @@ -105,8 +105,13 @@ public: void activateClient(Client*, bool force = false); void requestFocus(Client* c, bool force = false); - void takeActivity(Client* c, int flags, bool handled); // Flags are ActivityFlags - void handleTakeActivity(Client* c, xcb_timestamp_t timestamp, int flags); // Flags are ActivityFlags + enum ActivityFlag { + ActivityFocus = 1 << 0, // focus the window + ActivityFocusForce = 1 << 1 | ActivityFocus, // focus even if Dock etc. + ActivityRaise = 1 << 2 // raise the window + }; + Q_DECLARE_FLAGS(ActivityFlags, ActivityFlag) + void takeActivity(Client* c, ActivityFlags flags); bool allowClientActivation(const Client* c, xcb_timestamp_t time = -1U, bool focus_in = false, bool ignore_desktop = false); void restoreFocus(); @@ -235,7 +240,6 @@ public: bool showingDesktop() const; void sendPingToWindow(xcb_window_t w, xcb_timestamp_t timestamp); // Called from Client::pingWindow() - void sendTakeActivity(Client* c, xcb_timestamp_t timestamp, long flags); // Called from Client::takeActivity() void removeClient(Client*); // Only called from Client::destroyClient() or Client::releaseWindow() void setActiveClient(Client*); @@ -457,7 +461,6 @@ private: Client* last_active_client; Client* most_recently_raised; // Used ONLY by raiseOrLowerClient() Client* movingClient; - Client* pending_take_activity; // Delay(ed) window focus timer and client QTimer* delayFocusTimer; @@ -726,5 +729,6 @@ inline Workspace *workspace() } } // namespace +Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags) #endif