Workspace::allowClientActivation operates on AbstractClient

Still requires a dynamic_cast for check on should_get_focus. To be
removed once Workspace::should_get_focus is a list of AbstractClients.
icc-effect-5.14.5
Martin Gräßlin 2015-03-12 11:35:31 +01:00
parent dde1947461
commit f28d759352
2 changed files with 8 additions and 6 deletions

View File

@ -534,7 +534,7 @@ void Workspace::setShouldGetFocus(Client* c)
// focus_in -> the window got FocusIn event
// ignore_desktop - call comes from _NET_ACTIVE_WINDOW message, don't refuse just because of window
// is on a different desktop
bool Workspace::allowClientActivation(const KWin::Client *c, xcb_timestamp_t time, bool focus_in, bool ignore_desktop)
bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timestamp_t time, bool focus_in, bool ignore_desktop)
{
// options->focusStealingPreventionLevel :
// 0 - none - old KWin behaviour, new windows always get focus
@ -550,10 +550,12 @@ bool Workspace::allowClientActivation(const KWin::Client *c, xcb_timestamp_t tim
if (session_saving && level <= 2) { // <= normal
return true;
}
Client* ac = mostRecentlyActivatedClient();
AbstractClient* ac = mostRecentlyActivatedClient();
if (focus_in) {
if (should_get_focus.contains(const_cast< Client* >(c)))
return true; // FocusIn was result of KWin's action
if (const Client *cc = dynamic_cast<const Client*>(c)) {
if (should_get_focus.contains(const_cast< Client* >(cc)))
return true; // FocusIn was result of KWin's action
}
// Before getting FocusIn, the active Client already
// got FocusOut, and therefore got deactivated.
ac = last_active_client;
@ -573,7 +575,7 @@ bool Workspace::allowClientActivation(const KWin::Client *c, xcb_timestamp_t tim
return true; // no active client -> always allow
}
// TODO window urgency -> return true?
if (Client::belongToSameApplication(c, ac, true)) {
if (AbstractClient::belongToSameApplication(c, ac, true)) {
qCDebug(KWIN_CORE) << "Activation: Belongs to active application";
return true;
}

View File

@ -157,7 +157,7 @@ public:
};
Q_DECLARE_FLAGS(ActivityFlags, ActivityFlag)
void takeActivity(AbstractClient* c, ActivityFlags flags);
bool allowClientActivation(const Client* c, xcb_timestamp_t time = -1U, bool focus_in = false,
bool allowClientActivation(const AbstractClient* c, xcb_timestamp_t time = -1U, bool focus_in = false,
bool ignore_desktop = false);
void restoreFocus();
void gotFocusIn(const Client*);