From d305185247bffb5a22a898e7caf984966b5b0c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 8 May 2013 13:39:06 +0200 Subject: [PATCH] Remove Workspace pointer from Toplevel Instead have a simple workspace() method returning the pointer. --- bridge.cpp | 22 +++++++++++----------- client.cpp | 4 ++-- client.h | 4 +--- deleted.cpp | 8 ++++---- deleted.h | 2 +- events.cpp | 4 ++-- tabgroup.cpp | 4 ++-- toplevel.cpp | 4 +--- toplevel.h | 10 +--------- unmanaged.cpp | 4 ++-- unmanaged.h | 2 +- workspace.cpp | 4 ++-- workspace.h | 6 ++++++ 13 files changed, 36 insertions(+), 42 deletions(-) diff --git a/bridge.cpp b/bridge.cpp index 5f3c0a840..5fc6679c8 100644 --- a/bridge.cpp +++ b/bridge.cpp @@ -71,13 +71,13 @@ bool Bridge::isActive() const void Bridge::setKeepAbove(bool set) { if (c->keepAbove() != set) - c->workspace()->performWindowOperation(c, KeepAboveOp); + workspace()->performWindowOperation(c, KeepAboveOp); } void Bridge::setKeepBelow(bool set) { if (c->keepBelow() != set) - c->workspace()->performWindowOperation(c, KeepBelowOp); + workspace()->performWindowOperation(c, KeepBelowOp); } NET::WindowType Bridge::windowType(unsigned long supported_types) const @@ -99,7 +99,7 @@ bool Bridge::isSetShade() const void Bridge::showWindowMenu(const QPoint &p) { - c->workspace()->showWindowMenu(QRect(p,p), c); + workspace()->showWindowMenu(QRect(p,p), c); } void Bridge::showWindowMenu(const QPoint &p, long id) @@ -107,12 +107,12 @@ void Bridge::showWindowMenu(const QPoint &p, long id) Client *cc = clientForId(id); if (!cc) cc = c; - cc->workspace()->showWindowMenu(QRect(p,p), cc); + workspace()->showWindowMenu(QRect(p,p), cc); } void Bridge::showWindowMenu(const QRect &p) { - c->workspace()->showWindowMenu(p, c); + workspace()->showWindowMenu(p, c); } void Bridge::showApplicationMenu(const QPoint &p) @@ -133,7 +133,7 @@ bool Bridge::menuAvailable() const void Bridge::performWindowOperation(WindowOperation op) { - c->workspace()->performWindowOperation(c, op); + workspace()->performWindowOperation(c, op); } void Bridge::setMask(const QRegion& r, int mode) @@ -159,7 +159,7 @@ WId Bridge::windowId() const void Bridge::titlebarDblClickOperation() { - c->workspace()->performWindowOperation(c, options->operationTitlebarDblClick()); + workspace()->performWindowOperation(c, options->operationTitlebarDblClick()); } void Bridge::titlebarMouseWheelOperation(int delta) @@ -190,7 +190,7 @@ Qt::WFlags Bridge::initialWFlags() const QRegion Bridge::unobscuredRegion(const QRegion& r) const { QRegion reg(r); - const ToplevelList stacking_order = c->workspace()->stackingOrder(); + const ToplevelList stacking_order = workspace()->stackingOrder(); int pos = stacking_order.indexOf(c); ++pos; for (; pos < stacking_order.count(); ++pos) { @@ -246,7 +246,7 @@ QRect Bridge::transparentRect() const Client *Bridge::clientForId(long id) const { Client* client = reinterpret_cast(id); - if (!c->workspace()->hasClient(client)) { + if (!workspace()->hasClient(client)) { kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******" << id; return 0; } @@ -342,8 +342,8 @@ void Bridge::untab(long id, const QRect& newGeom) if (Client* client = clientForId(id)) if (client->untab(newGeom)) { if (options->focusPolicyIsReasonable()) - c->workspace()->takeActivity(client, ActivityFocus | ActivityRaise, true); - c->workspace()->raiseClient(client); + workspace()->takeActivity(client, ActivityFocus | ActivityRaise, true); + workspace()->raiseClient(client); } } diff --git a/client.cpp b/client.cpp index 97843dff9..b67897567 100644 --- a/client.cpp +++ b/client.cpp @@ -87,8 +87,8 @@ bool Client::s_haveResizeEffect = false; * This ctor is "dumb" - it only initializes data. All the real initialization * is done in manage(). */ -Client::Client(Workspace* ws) - : Toplevel(ws) +Client::Client() + : Toplevel() , client(None) , wrapper(None) , decoration(NULL) diff --git a/client.h b/client.h index 8683dd97e..9e0be7f70 100644 --- a/client.h +++ b/client.h @@ -54,8 +54,6 @@ namespace TabBox class TabBoxClientImpl; } - -class Workspace; class Bridge; class PaintRedirector; @@ -271,7 +269,7 @@ class Client **/ Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) public: - explicit Client(Workspace* ws); + explicit Client(); Window wrapperId() const; Window decorationId() const; xcb_window_t inputId() const { return m_decoInputExtent; } diff --git a/deleted.cpp b/deleted.cpp index ddec5ce80..4ea146c0d 100644 --- a/deleted.cpp +++ b/deleted.cpp @@ -29,8 +29,8 @@ along with this program. If not, see . namespace KWin { -Deleted::Deleted(Workspace* ws) - : Toplevel(ws) +Deleted::Deleted() + : Toplevel() , delete_refcount(1) , no_border(true) , padding_left(0) @@ -54,9 +54,9 @@ Deleted::~Deleted() Deleted* Deleted::create(Toplevel* c) { - Deleted* d = new Deleted(c->workspace()); + Deleted* d = new Deleted(); d->copyToDeleted(c); - d->workspace()->addDeleted(d, c); + workspace()->addDeleted(d, c); return d; } diff --git a/deleted.h b/deleted.h index a4d8b6b3d..3a729ba17 100644 --- a/deleted.h +++ b/deleted.h @@ -63,7 +63,7 @@ protected: virtual void debug(QDebug& stream) const; virtual bool shouldUnredirect() const; private: - Deleted(Workspace *ws); // use create() + Deleted(); // use create() void copyToDeleted(Toplevel* c); virtual ~Deleted(); // deleted only using unrefWindow() int delete_refcount; diff --git a/events.cpp b/events.cpp index 0858f1baf..fda07e75a 100644 --- a/events.cpp +++ b/events.cpp @@ -1297,10 +1297,10 @@ static bool follows_focusin = false; static bool follows_focusin_failed = false; static Bool predicate_follows_focusin(Display*, XEvent* e, XPointer arg) { + Q_UNUSED(arg) if (follows_focusin || follows_focusin_failed) return False; - Client* c = (Client*) arg; - if (e->type == FocusIn && c->workspace()->findClient(WindowMatchPredicate(e->xfocus.window))) { + if (e->type == FocusIn && workspace()->findClient(WindowMatchPredicate(e->xfocus.window))) { // found FocusIn follows_focusin = true; return False; diff --git a/tabgroup.cpp b/tabgroup.cpp index 15b85cb14..7135929f5 100644 --- a/tabgroup.cpp +++ b/tabgroup.cpp @@ -133,11 +133,11 @@ bool TabGroup::add(Client* c, Client *other, bool after, bool becomeVisible) if (!effects || c->readyForPainting()) { setCurrent(c); if (options->focusPolicyIsReasonable()) - m_current->workspace()->requestFocus( c ); + workspace()->requestFocus( c ); } else { if (options->focusPolicyIsReasonable()) - m_current->workspace()->requestFocus( m_current ); + workspace()->requestFocus( m_current ); m_current = c; // setCurrent will be called by Toplevel::setReadyForPainting() } } diff --git a/toplevel.cpp b/toplevel.cpp index ce9cdbf5c..53b70f962 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -36,14 +36,13 @@ along with this program. If not, see . namespace KWin { -Toplevel::Toplevel(Workspace* ws) +Toplevel::Toplevel() : vis(NULL) , info(NULL) , ready_for_painting(true) , m_isDamaged(false) , client(None) , frame(None) - , wspace(ws) , window_pix(None) , damage_handle(None) , is_shape(false) @@ -114,7 +113,6 @@ void Toplevel::copyToDeleted(Toplevel* c) info = c->info; client = c->client; frame = c->frame; - wspace = c->wspace; window_pix = c->window_pix; ready_for_painting = c->ready_for_painting; damage_handle = None; diff --git a/toplevel.h b/toplevel.h index 4b8bfd821..8928e2bd0 100644 --- a/toplevel.h +++ b/toplevel.h @@ -40,7 +40,6 @@ namespace KWin { class ClientMachine; -class Workspace; class EffectWindowImpl; class Shadow; @@ -165,10 +164,9 @@ class Toplevel **/ Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) public: - explicit Toplevel(Workspace *ws); + explicit Toplevel(); Window frameId() const; Window window() const; - Workspace* workspace() const; QRect geometry() const; QSize size() const; QPoint pos() const; @@ -397,7 +395,6 @@ private: // when adding new data members, check also copyToDeleted() Window client; Window frame; - Workspace* wspace; Pixmap window_pix; xcb_damage_damage_t damage_handle; QRegion damage_region; // damage is really damaged window (XDamage) and texture needs @@ -435,11 +432,6 @@ inline void Toplevel::setWindowHandles(Window w, Window f) frame = f; } -inline Workspace* Toplevel::workspace() const -{ - return wspace; -} - inline QRect Toplevel::geometry() const { return geom; diff --git a/unmanaged.cpp b/unmanaged.cpp index 16569d00d..f782180a8 100644 --- a/unmanaged.cpp +++ b/unmanaged.cpp @@ -32,8 +32,8 @@ along with this program. If not, see . namespace KWin { -Unmanaged::Unmanaged(Workspace* ws) - : Toplevel(ws) +Unmanaged::Unmanaged() + : Toplevel() { connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SIGNAL(geometryChanged())); } diff --git a/unmanaged.h b/unmanaged.h index f81df039e..a414ffec5 100644 --- a/unmanaged.h +++ b/unmanaged.h @@ -33,7 +33,7 @@ class Unmanaged { Q_OBJECT public: - explicit Unmanaged(Workspace *ws); + explicit Unmanaged(); bool windowEvent(XEvent* e); void release(bool on_shutdown = false); bool track(Window w); diff --git a/workspace.cpp b/workspace.cpp index 668a087c1..6adee2762 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -456,7 +456,7 @@ Workspace::~Workspace() Client* Workspace::createClient(xcb_window_t w, bool is_mapped) { StackingUpdatesBlocker blocker(this); - Client* c = new Client(this); + Client* c = new Client(); connect(c, SIGNAL(needsRepaint()), m_compositor, SLOT(scheduleRepaint())); connect(c, SIGNAL(activeChanged()), m_compositor, SLOT(checkUnredirect())); connect(c, SIGNAL(fullScreenChanged()), m_compositor, SLOT(checkUnredirect())); @@ -478,7 +478,7 @@ Unmanaged* Workspace::createUnmanaged(xcb_window_t w) { if (m_compositor && m_compositor->checkForOverlayWindow(w)) return NULL; - Unmanaged* c = new Unmanaged(this); + Unmanaged* c = new Unmanaged(); if (!c->track(w)) { Unmanaged::deleteUnmanaged(c); return NULL; diff --git a/workspace.h b/workspace.h index 71edcd7cc..ffa30958b 100644 --- a/workspace.h +++ b/workspace.h @@ -550,6 +550,7 @@ private: private: friend bool performTransiencyCheck(); + friend Workspace *workspace(); }; /** @@ -723,6 +724,11 @@ inline bool Workspace::hasClient(const Client* c) return findClient(ClientMatchPredicate(c)); } +inline Workspace *workspace() +{ + return Workspace::_self; +} + } // namespace #endif