TabBoxClientImpl changed to using an AbstractClient

The change is mostly straight forward. Effects are straight forward
adjusted. Client::findModal is moved up, this causes still a few
dynamic_casts to Client. Mostly because Workspace::activateClient still
operates on Client.
This commit is contained in:
Martin Gräßlin 2015-03-05 13:59:18 +01:00
parent f800477be5
commit 6e45901844
7 changed files with 41 additions and 34 deletions

View file

@ -47,6 +47,9 @@ public:
virtual bool wantsTabFocus() const = 0;
virtual bool isFullScreen() const = 0;
virtual const QIcon &icon() const = 0;
virtual bool skipSwitcher() const = 0;
// TODO: remove boolean trap
virtual AbstractClient *findModal(bool allow_itself = false) = 0;
virtual void cancelAutoRaise() = 0;
virtual bool isTransient() const;
/**

View file

@ -349,7 +349,7 @@ void Workspace::takeActivity(Client* c, ActivityFlags flags)
}
if (flags & ActivityFocus) {
Client* modal = c->findModal();
Client* modal = dynamic_cast<Client*>(c->findModal());
if (modal != NULL && modal != c) {
if (!modal->isOnDesktop(c->desktop())) {
modal->setDesktop(c->desktop());

View file

@ -303,7 +303,7 @@ public:
bool hasTransient(const Client* c, bool indirect) const;
const ClientList& transients() const; // Is not indirect
void checkTransient(xcb_window_t w);
Client* findModal(bool allow_itself = false);
AbstractClient* findModal(bool allow_itself = false) override;
const Group* group() const;
Group* group();
void checkGroup(Group* gr = NULL, bool force = false);
@ -422,7 +422,7 @@ public:
bool skipPager() const;
void setSkipPager(bool);
bool skipSwitcher() const;
bool skipSwitcher() const override;
void setSkipSwitcher(bool set);
bool keepAbove() const;

View file

@ -1073,9 +1073,8 @@ EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
{
#ifdef KWIN_BUILD_TABBOX
EffectWindowList ret;
ClientList clients;
clients = TabBox::TabBox::self()->currentClientList();
for (Client * c : clients)
const auto clients = TabBox::TabBox::self()->currentClientList();
for (auto c : clients)
ret.append(c->effectWindow());
return ret;
#else
@ -1123,7 +1122,7 @@ int EffectsHandlerImpl::currentTabBoxDesktop() const
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
{
#ifdef KWIN_BUILD_TABBOX
if (Client* c = TabBox::TabBox::self()->currentClient())
if (auto c = TabBox::TabBox::self()->currentClient())
return c->effectWindow();
#endif
return NULL;
@ -1633,8 +1632,8 @@ void EffectWindowImpl::deleteProperty(long int atom) const
EffectWindow* EffectWindowImpl::findModal()
{
if (Client* c = dynamic_cast< Client* >(toplevel)) {
if (Client* c2 = c->findModal())
if (AbstractClient* c = dynamic_cast< AbstractClient* >(toplevel)) {
if (AbstractClient* c2 = c->findModal())
return c2->effectWindow();
}
return NULL;

View file

@ -902,12 +902,12 @@ ClientList Client::allMainClients() const
return result;
}
Client* Client::findModal(bool allow_itself)
AbstractClient* Client::findModal(bool allow_itself)
{
for (ClientList::ConstIterator it = transients().constBegin();
it != transients().constEnd();
++it)
if (Client* ret = (*it)->findModal(true))
if (AbstractClient* ret = (*it)->findModal(true))
return ret;
if (isModal() && allow_itself)
return this;
@ -1054,7 +1054,7 @@ void Client::checkActiveModal()
// exist loops, breaking findModal
Client* check_modal = workspace()->mostRecentlyActivatedClient();
if (check_modal != NULL && check_modal->check_active_modal) {
Client* new_modal = check_modal->findModal();
Client* new_modal = dynamic_cast<Client*>(check_modal->findModal());
if (new_modal != NULL && new_modal != check_modal) {
if (!new_modal->isManaged())
return; // postpone check until end of manage()

View file

@ -155,7 +155,7 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::activeClient() const
bool TabBoxHandlerImpl::checkDesktop(TabBoxClient* client, int desktop) const
{
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
auto current = (static_cast< TabBoxClientImpl* >(client))->client();
switch (config().clientDesktopMode()) {
case TabBoxConfig::AllDesktopsClients:
@ -169,7 +169,7 @@ bool TabBoxHandlerImpl::checkDesktop(TabBoxClient* client, int desktop) const
bool TabBoxHandlerImpl::checkActivity(TabBoxClient* client) const
{
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
auto current = (static_cast< TabBoxClientImpl* >(client))->client();
switch (config().clientActivitiesMode()) {
case TabBoxConfig::AllActivitiesClients:
@ -183,7 +183,7 @@ bool TabBoxHandlerImpl::checkActivity(TabBoxClient* client) const
bool TabBoxHandlerImpl::checkApplications(TabBoxClient* client) const
{
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
auto current = (static_cast< TabBoxClientImpl* >(client))->client();
TabBoxClientImpl* c;
QListIterator< QWeakPointer<TabBoxClient> > i(clientList());
@ -233,7 +233,7 @@ bool TabBoxHandlerImpl::checkMinimized(TabBoxClient* client) const
bool TabBoxHandlerImpl::checkMultiScreen(TabBoxClient* client) const
{
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
auto current = (static_cast< TabBoxClientImpl* >(client))->client();
switch (config().clientMultiScreenMode()) {
case TabBoxConfig::IgnoreMultiScreen:
@ -250,8 +250,8 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::clientToAddToList(TabBoxClient* cl
if (!client) {
return QWeakPointer<TabBoxClient>();
}
Client* ret = nullptr;
Client* current = (static_cast< TabBoxClientImpl* >(client))->client();
AbstractClient* ret = nullptr;
AbstractClient* current = (static_cast< TabBoxClientImpl* >(client))->client();
bool addClient = checkDesktop(client, desktop)
&& checkActivity(client)
@ -261,7 +261,7 @@ QWeakPointer<TabBoxClient> TabBoxHandlerImpl::clientToAddToList(TabBoxClient* cl
addClient = addClient && current->wantsTabFocus() && !current->skipSwitcher();
if (addClient) {
// don't add windows that have modal dialogs
Client* modal = current->findModal();
AbstractClient* modal = current->findModal();
if (modal == nullptr || modal == current)
ret = current;
else if (!clientList().contains(modal->tabBoxClient()))
@ -305,7 +305,7 @@ void TabBoxHandlerImpl::restack(TabBoxClient *c, TabBoxClient *under)
void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, WId tabbox, bool b) const
{
Client *cl = static_cast<TabBoxClientImpl*>(c)->client();
auto cl = static_cast<TabBoxClientImpl*>(c)->client();
cl->elevate(b);
if (Unmanaged *w = Workspace::self()->findUnmanaged(tabbox))
w->elevate(b);
@ -313,7 +313,11 @@ void TabBoxHandlerImpl::elevateClient(TabBoxClient *c, WId tabbox, bool b) const
void TabBoxHandlerImpl::shadeClient(TabBoxClient *c, bool b) const
{
Client *cl = static_cast<TabBoxClientImpl*>(c)->client();
Client *cl = dynamic_cast<Client*>(static_cast<TabBoxClientImpl*>(c)->client());
if (!cl) {
// shading is X11 specific
return;
}
cl->cancelShadeHoverTimer(); // stop core shading action
if (!b && cl->shadeMode() == ShadeNormal)
cl->setShade(ShadeHover);
@ -341,7 +345,7 @@ void TabBoxHandlerImpl::activateAndClose()
* TabBoxClientImpl
*********************************************************/
TabBoxClientImpl::TabBoxClientImpl(Client *client)
TabBoxClientImpl::TabBoxClientImpl(AbstractClient *client)
: TabBoxClient()
, m_client(client)
{
@ -640,7 +644,7 @@ void TabBox::nextPrev(bool next)
Returns the currently displayed client ( only works in TabBoxWindowsMode ).
Returns 0 if no client is displayed.
*/
Client* TabBox::currentClient()
AbstractClient* TabBox::currentClient()
{
if (TabBoxClientImpl* client = static_cast< TabBoxClientImpl* >(m_tabBox->client(m_tabBox->currentIndex()))) {
if (!Workspace::self()->hasClient(client->client()))
@ -655,10 +659,10 @@ Client* TabBox::currentClient()
TabBoxWindowsMode ).
Returns an empty list if no clients are available.
*/
ClientList TabBox::currentClientList()
QList<AbstractClient*> TabBox::currentClientList()
{
TabBoxClientList list = m_tabBox->clientList();
ClientList ret;
QList<AbstractClient*> ret;
foreach (const QWeakPointer<TabBoxClient> &clientPointer, list) {
QSharedPointer<TabBoxClient> client = clientPointer.toStrongRef();
if (!client)
@ -694,7 +698,7 @@ QList< int > TabBox::currentDesktopList()
\sa setCurrentDesktop()
*/
void TabBox::setCurrentClient(Client* newClient)
void TabBox::setCurrentClient(AbstractClient *newClient)
{
setCurrentIndex(m_tabBox->index(newClient->tabBoxClient()));
}
@ -1245,7 +1249,7 @@ void TabBox::KDEOneStepThroughWindows(bool forward, TabBoxMode mode)
setMode(mode);
reset();
nextPrev(forward);
if (Client* c = currentClient()) {
if (Client* c = dynamic_cast<Client*>(currentClient())) {
Workspace::self()->activateClient(c);
shadeActivate(c);
}
@ -1435,7 +1439,7 @@ void TabBox::close(bool abort)
void TabBox::accept()
{
Client* c = currentClient();
Client* c = dynamic_cast<Client*>(currentClient());
close();
if (c) {
Workspace::self()->activateClient(c);

View file

@ -40,6 +40,7 @@ namespace KWin
{
class Workspace;
class AbstractClient;
class Client;
namespace TabBox
{
@ -86,7 +87,7 @@ private:
class TabBoxClientImpl : public TabBoxClient
{
public:
explicit TabBoxClientImpl(Client *client);
explicit TabBoxClientImpl(AbstractClient *client);
virtual ~TabBoxClientImpl();
virtual QString caption() const;
@ -101,12 +102,12 @@ public:
virtual void close();
virtual bool isFirstInTabBox() const;
Client* client() const {
AbstractClient* client() const {
return m_client;
}
private:
Client* m_client;
AbstractClient* m_client;
};
class TabBox : public QObject
@ -115,12 +116,12 @@ class TabBox : public QObject
public:
~TabBox();
Client* currentClient();
ClientList currentClientList();
AbstractClient *currentClient();
QList<AbstractClient*> currentClientList();
int currentDesktop();
QList< int > currentDesktopList();
void setCurrentClient(Client* newClient);
void setCurrentClient(AbstractClient *newClient);
void setCurrentDesktop(int newDesktop);
void setMode(TabBoxMode mode);