Remove Workspace pointer from Toplevel

Instead have a simple workspace() method returning the pointer.
icc-effect-5.14.5
Martin Gräßlin 2013-05-08 13:39:06 +02:00
parent c4b3d11261
commit d305185247
13 changed files with 36 additions and 42 deletions

View File

@ -71,13 +71,13 @@ bool Bridge::isActive() const
void Bridge::setKeepAbove(bool set) void Bridge::setKeepAbove(bool set)
{ {
if (c->keepAbove() != set) if (c->keepAbove() != set)
c->workspace()->performWindowOperation(c, KeepAboveOp); workspace()->performWindowOperation(c, KeepAboveOp);
} }
void Bridge::setKeepBelow(bool set) void Bridge::setKeepBelow(bool set)
{ {
if (c->keepBelow() != set) if (c->keepBelow() != set)
c->workspace()->performWindowOperation(c, KeepBelowOp); workspace()->performWindowOperation(c, KeepBelowOp);
} }
NET::WindowType Bridge::windowType(unsigned long supported_types) const NET::WindowType Bridge::windowType(unsigned long supported_types) const
@ -99,7 +99,7 @@ bool Bridge::isSetShade() const
void Bridge::showWindowMenu(const QPoint &p) 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) void Bridge::showWindowMenu(const QPoint &p, long id)
@ -107,12 +107,12 @@ void Bridge::showWindowMenu(const QPoint &p, long id)
Client *cc = clientForId(id); Client *cc = clientForId(id);
if (!cc) if (!cc)
cc = c; cc = c;
cc->workspace()->showWindowMenu(QRect(p,p), cc); workspace()->showWindowMenu(QRect(p,p), cc);
} }
void Bridge::showWindowMenu(const QRect &p) void Bridge::showWindowMenu(const QRect &p)
{ {
c->workspace()->showWindowMenu(p, c); workspace()->showWindowMenu(p, c);
} }
void Bridge::showApplicationMenu(const QPoint &p) void Bridge::showApplicationMenu(const QPoint &p)
@ -133,7 +133,7 @@ bool Bridge::menuAvailable() const
void Bridge::performWindowOperation(WindowOperation op) void Bridge::performWindowOperation(WindowOperation op)
{ {
c->workspace()->performWindowOperation(c, op); workspace()->performWindowOperation(c, op);
} }
void Bridge::setMask(const QRegion& r, int mode) void Bridge::setMask(const QRegion& r, int mode)
@ -159,7 +159,7 @@ WId Bridge::windowId() const
void Bridge::titlebarDblClickOperation() void Bridge::titlebarDblClickOperation()
{ {
c->workspace()->performWindowOperation(c, options->operationTitlebarDblClick()); workspace()->performWindowOperation(c, options->operationTitlebarDblClick());
} }
void Bridge::titlebarMouseWheelOperation(int delta) void Bridge::titlebarMouseWheelOperation(int delta)
@ -190,7 +190,7 @@ Qt::WFlags Bridge::initialWFlags() const
QRegion Bridge::unobscuredRegion(const QRegion& r) const QRegion Bridge::unobscuredRegion(const QRegion& r) const
{ {
QRegion reg(r); QRegion reg(r);
const ToplevelList stacking_order = c->workspace()->stackingOrder(); const ToplevelList stacking_order = workspace()->stackingOrder();
int pos = stacking_order.indexOf(c); int pos = stacking_order.indexOf(c);
++pos; ++pos;
for (; pos < stacking_order.count(); ++pos) { for (; pos < stacking_order.count(); ++pos) {
@ -246,7 +246,7 @@ QRect Bridge::transparentRect() const
Client *Bridge::clientForId(long id) const Client *Bridge::clientForId(long id) const
{ {
Client* client = reinterpret_cast<Client*>(id); Client* client = reinterpret_cast<Client*>(id);
if (!c->workspace()->hasClient(client)) { if (!workspace()->hasClient(client)) {
kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******" << id; kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******" << id;
return 0; return 0;
} }
@ -342,8 +342,8 @@ void Bridge::untab(long id, const QRect& newGeom)
if (Client* client = clientForId(id)) if (Client* client = clientForId(id))
if (client->untab(newGeom)) { if (client->untab(newGeom)) {
if (options->focusPolicyIsReasonable()) if (options->focusPolicyIsReasonable())
c->workspace()->takeActivity(client, ActivityFocus | ActivityRaise, true); workspace()->takeActivity(client, ActivityFocus | ActivityRaise, true);
c->workspace()->raiseClient(client); workspace()->raiseClient(client);
} }
} }

View File

@ -87,8 +87,8 @@ bool Client::s_haveResizeEffect = false;
* This ctor is "dumb" - it only initializes data. All the real initialization * This ctor is "dumb" - it only initializes data. All the real initialization
* is done in manage(). * is done in manage().
*/ */
Client::Client(Workspace* ws) Client::Client()
: Toplevel(ws) : Toplevel()
, client(None) , client(None)
, wrapper(None) , wrapper(None)
, decoration(NULL) , decoration(NULL)

View File

@ -54,8 +54,6 @@ namespace TabBox
class TabBoxClientImpl; class TabBoxClientImpl;
} }
class Workspace;
class Bridge; class Bridge;
class PaintRedirector; class PaintRedirector;
@ -271,7 +269,7 @@ class Client
**/ **/
Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
public: public:
explicit Client(Workspace* ws); explicit Client();
Window wrapperId() const; Window wrapperId() const;
Window decorationId() const; Window decorationId() const;
xcb_window_t inputId() const { return m_decoInputExtent; } xcb_window_t inputId() const { return m_decoInputExtent; }

View File

@ -29,8 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
Deleted::Deleted(Workspace* ws) Deleted::Deleted()
: Toplevel(ws) : Toplevel()
, delete_refcount(1) , delete_refcount(1)
, no_border(true) , no_border(true)
, padding_left(0) , padding_left(0)
@ -54,9 +54,9 @@ Deleted::~Deleted()
Deleted* Deleted::create(Toplevel* c) Deleted* Deleted::create(Toplevel* c)
{ {
Deleted* d = new Deleted(c->workspace()); Deleted* d = new Deleted();
d->copyToDeleted(c); d->copyToDeleted(c);
d->workspace()->addDeleted(d, c); workspace()->addDeleted(d, c);
return d; return d;
} }

View File

@ -63,7 +63,7 @@ protected:
virtual void debug(QDebug& stream) const; virtual void debug(QDebug& stream) const;
virtual bool shouldUnredirect() const; virtual bool shouldUnredirect() const;
private: private:
Deleted(Workspace *ws); // use create() Deleted(); // use create()
void copyToDeleted(Toplevel* c); void copyToDeleted(Toplevel* c);
virtual ~Deleted(); // deleted only using unrefWindow() virtual ~Deleted(); // deleted only using unrefWindow()
int delete_refcount; int delete_refcount;

View File

@ -1297,10 +1297,10 @@ static bool follows_focusin = false;
static bool follows_focusin_failed = false; static bool follows_focusin_failed = false;
static Bool predicate_follows_focusin(Display*, XEvent* e, XPointer arg) static Bool predicate_follows_focusin(Display*, XEvent* e, XPointer arg)
{ {
Q_UNUSED(arg)
if (follows_focusin || follows_focusin_failed) if (follows_focusin || follows_focusin_failed)
return False; return False;
Client* c = (Client*) arg; if (e->type == FocusIn && workspace()->findClient(WindowMatchPredicate(e->xfocus.window))) {
if (e->type == FocusIn && c->workspace()->findClient(WindowMatchPredicate(e->xfocus.window))) {
// found FocusIn // found FocusIn
follows_focusin = true; follows_focusin = true;
return False; return False;

View File

@ -133,11 +133,11 @@ bool TabGroup::add(Client* c, Client *other, bool after, bool becomeVisible)
if (!effects || c->readyForPainting()) { if (!effects || c->readyForPainting()) {
setCurrent(c); setCurrent(c);
if (options->focusPolicyIsReasonable()) if (options->focusPolicyIsReasonable())
m_current->workspace()->requestFocus( c ); workspace()->requestFocus( c );
} }
else { else {
if (options->focusPolicyIsReasonable()) if (options->focusPolicyIsReasonable())
m_current->workspace()->requestFocus( m_current ); workspace()->requestFocus( m_current );
m_current = c; // setCurrent will be called by Toplevel::setReadyForPainting() m_current = c; // setCurrent will be called by Toplevel::setReadyForPainting()
} }
} }

View File

@ -36,14 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
Toplevel::Toplevel(Workspace* ws) Toplevel::Toplevel()
: vis(NULL) : vis(NULL)
, info(NULL) , info(NULL)
, ready_for_painting(true) , ready_for_painting(true)
, m_isDamaged(false) , m_isDamaged(false)
, client(None) , client(None)
, frame(None) , frame(None)
, wspace(ws)
, window_pix(None) , window_pix(None)
, damage_handle(None) , damage_handle(None)
, is_shape(false) , is_shape(false)
@ -114,7 +113,6 @@ void Toplevel::copyToDeleted(Toplevel* c)
info = c->info; info = c->info;
client = c->client; client = c->client;
frame = c->frame; frame = c->frame;
wspace = c->wspace;
window_pix = c->window_pix; window_pix = c->window_pix;
ready_for_painting = c->ready_for_painting; ready_for_painting = c->ready_for_painting;
damage_handle = None; damage_handle = None;

View File

@ -40,7 +40,6 @@ namespace KWin
{ {
class ClientMachine; class ClientMachine;
class Workspace;
class EffectWindowImpl; class EffectWindowImpl;
class Shadow; class Shadow;
@ -165,10 +164,9 @@ class Toplevel
**/ **/
Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
public: public:
explicit Toplevel(Workspace *ws); explicit Toplevel();
Window frameId() const; Window frameId() const;
Window window() const; Window window() const;
Workspace* workspace() const;
QRect geometry() const; QRect geometry() const;
QSize size() const; QSize size() const;
QPoint pos() const; QPoint pos() const;
@ -397,7 +395,6 @@ private:
// when adding new data members, check also copyToDeleted() // when adding new data members, check also copyToDeleted()
Window client; Window client;
Window frame; Window frame;
Workspace* wspace;
Pixmap window_pix; Pixmap window_pix;
xcb_damage_damage_t damage_handle; xcb_damage_damage_t damage_handle;
QRegion damage_region; // damage is really damaged window (XDamage) and texture needs 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; frame = f;
} }
inline Workspace* Toplevel::workspace() const
{
return wspace;
}
inline QRect Toplevel::geometry() const inline QRect Toplevel::geometry() const
{ {
return geom; return geom;

View File

@ -32,8 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin namespace KWin
{ {
Unmanaged::Unmanaged(Workspace* ws) Unmanaged::Unmanaged()
: Toplevel(ws) : Toplevel()
{ {
connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SIGNAL(geometryChanged())); connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SIGNAL(geometryChanged()));
} }

View File

@ -33,7 +33,7 @@ class Unmanaged
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit Unmanaged(Workspace *ws); explicit Unmanaged();
bool windowEvent(XEvent* e); bool windowEvent(XEvent* e);
void release(bool on_shutdown = false); void release(bool on_shutdown = false);
bool track(Window w); bool track(Window w);

View File

@ -456,7 +456,7 @@ Workspace::~Workspace()
Client* Workspace::createClient(xcb_window_t w, bool is_mapped) Client* Workspace::createClient(xcb_window_t w, bool is_mapped)
{ {
StackingUpdatesBlocker blocker(this); StackingUpdatesBlocker blocker(this);
Client* c = new Client(this); Client* c = new Client();
connect(c, SIGNAL(needsRepaint()), m_compositor, SLOT(scheduleRepaint())); connect(c, SIGNAL(needsRepaint()), m_compositor, SLOT(scheduleRepaint()));
connect(c, SIGNAL(activeChanged()), m_compositor, SLOT(checkUnredirect())); connect(c, SIGNAL(activeChanged()), m_compositor, SLOT(checkUnredirect()));
connect(c, SIGNAL(fullScreenChanged()), 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)) if (m_compositor && m_compositor->checkForOverlayWindow(w))
return NULL; return NULL;
Unmanaged* c = new Unmanaged(this); Unmanaged* c = new Unmanaged();
if (!c->track(w)) { if (!c->track(w)) {
Unmanaged::deleteUnmanaged(c); Unmanaged::deleteUnmanaged(c);
return NULL; return NULL;

View File

@ -550,6 +550,7 @@ private:
private: private:
friend bool performTransiencyCheck(); friend bool performTransiencyCheck();
friend Workspace *workspace();
}; };
/** /**
@ -723,6 +724,11 @@ inline bool Workspace::hasClient(const Client* c)
return findClient(ClientMatchPredicate(c)); return findClient(ClientMatchPredicate(c));
} }
inline Workspace *workspace()
{
return Workspace::_self;
}
} // namespace } // namespace
#endif #endif