[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
icc-effect-5.14.5
Martin Gräßlin 2014-03-20 13:39:00 +01:00
parent a3878f2c7f
commit 970e8765f0
12 changed files with 25 additions and 94 deletions

View File

@ -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),

View File

@ -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);
}
}

View File

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

View File

@ -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

View File

@ -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;

View File

@ -384,7 +384,6 @@ void Workspace::raiseClient(Client* c, bool nogroup)
if (!c->isSpecialWindow()) {
most_recently_raised = c;
pending_take_activity = NULL;
}
}

View File

@ -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));

View File

@ -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:

View File

@ -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;

View File

@ -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,

View File

@ -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
*/

View File

@ -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