From df98e3883f6e6450a888cbd14ac120eb309d4824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 11 Sep 2015 14:14:21 +0200 Subject: [PATCH] Move hasTransient from Client to AbstractClient --- abstract_client.cpp | 6 ++++++ abstract_client.h | 6 ++++++ client.h | 2 +- group.cpp | 11 +++++++---- layers.cpp | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/abstract_client.cpp b/abstract_client.cpp index 0fde7e0d12..6989505af9 100644 --- a/abstract_client.cpp +++ b/abstract_client.cpp @@ -822,4 +822,10 @@ QPoint AbstractClient::transientPlacementHint() const return QPoint(); } +bool AbstractClient::hasTransient(const AbstractClient *c, bool indirect) const +{ + Q_UNUSED(indirect); + return c->transientFor() == this; +} + } diff --git a/abstract_client.h b/abstract_client.h index 993e6597fe..c89aecc039 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -258,6 +258,12 @@ public: virtual QPoint transientPlacementHint() const; const AbstractClient* transientFor() const; AbstractClient* transientFor(); + /** + * @returns @c true if c is the transient_for window for this client, + * or recursively the transient_for window + * @todo: remove boolean trap + **/ + virtual bool hasTransient(const AbstractClient* c, bool indirect) const; /** * Returns true for "special" windows and false for windows which are "normal" * (normal=window which has a border, can be moved by the user, can be closed, etc.) diff --git a/client.h b/client.h index 0908583034..d0b605b1bd 100644 --- a/client.h +++ b/client.h @@ -179,7 +179,7 @@ public: bool wasOriginallyGroupTransient() const; ClientList mainClients() const; // Call once before loop , is not indirect ClientList allMainClients() const; // Call once before loop , is indirect - bool hasTransient(const Client* c, bool indirect) const; + bool hasTransient(const AbstractClient* c, bool indirect) const override; const ClientList& transients() const; // Is not indirect void checkTransient(xcb_window_t w); AbstractClient* findModal(bool allow_itself = false) override; diff --git a/group.cpp b/group.cpp index bd30700aaa..22c0c2744a 100644 --- a/group.cpp +++ b/group.cpp @@ -842,11 +842,14 @@ void Client::checkTransient(xcb_window_t w) // returns true if cl is the transient_for window for this client, // or recursively the transient_for window -bool Client::hasTransient(const Client* cl, bool indirect) const +bool Client::hasTransient(const AbstractClient* cl, bool indirect) const { - // checkGroupTransients() uses this to break loops, so hasTransient() must detect them - ConstClientList set; - return hasTransientInternal(cl, indirect, set); + if (const Client *c = dynamic_cast(cl)) { + // checkGroupTransients() uses this to break loops, so hasTransient() must detect them + ConstClientList set; + return hasTransientInternal(c, indirect, set); + } + return false; } bool Client::hasTransientInternal(const Client* cl, bool indirect, ConstClientList& set) const diff --git a/layers.cpp b/layers.cpp index b0e48a0b7a..336aae3579 100644 --- a/layers.cpp +++ b/layers.cpp @@ -554,7 +554,7 @@ ToplevelList Workspace::constrainedStackingOrder() i2 = -1; // don't reorder, already the topmost in the group break; } - Client *c2 = qobject_cast(stacking[ i2 ]); + AbstractClient *c2 = qobject_cast(stacking[ i2 ]); if (!c2) { continue; }