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)
{
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<Client*>(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);
}
}

View File

@ -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)

View File

@ -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; }

View File

@ -29,8 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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()
}
}

View File

@ -36,14 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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;

View File

@ -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;

View File

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

View File

@ -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);

View File

@ -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;

View File

@ -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