Make Workspace a singleton, accesible via Workspace::self()

svn path=/trunk/kdebase/kwin/; revision=93375
This commit is contained in:
Waldo Bastian 2001-04-22 06:51:07 +00:00
parent 57f4808d0f
commit 42291d5b87
4 changed files with 13 additions and 13 deletions

View file

@ -124,8 +124,8 @@ Application::Application( )
options = new Options;
atoms = new Atoms;
// create a workspace.
workspaces += new Workspace( isSessionRestored() );
// create workspace.
(void) new Workspace( isSessionRestored() );
syncX(); // trigger possible errors, there's still a chance to abort
@ -136,9 +136,7 @@ Application::Application( )
Application::~Application()
{
for ( WorkspaceList::Iterator it = workspaces.begin(); it != workspaces.end(); ++it) {
delete (*it);
}
delete Workspace::self();
delete options;
}
@ -167,10 +165,8 @@ bool Application::x11EventFilter( XEvent *e )
break;
}
for ( WorkspaceList::Iterator it = workspaces.begin(); it != workspaces.end(); ++it) {
if ( (*it)->workspaceEvent( e ) )
if ( Workspace::self()->workspaceEvent( e ) )
return TRUE;
}
return KApplication::x11EventFilter( e );
}
@ -195,7 +191,7 @@ void Application::saveState( QSessionManager& sm )
return;
}
workspaces.first()->storeSession( kapp->sessionConfig() );
Workspace::self()->storeSession( kapp->sessionConfig() );
kapp->sessionConfig()->sync();
}

4
main.h
View file

@ -9,7 +9,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
#include <kapp.h>
#include "workspace.h"
typedef QValueList<KWinInternal::Workspace*> WorkspaceList;
class Application : public KApplication
{
public:
@ -21,9 +20,6 @@ public:
protected:
bool x11EventFilter( XEvent * );
private:
WorkspaceList workspaces;
};

View file

@ -212,6 +212,8 @@ Client* Workspace::clientFactory( WId w )
return ( mgr->allocateClient( this, w, false ) );
}
Workspace *Workspace::_self = 0;
// Rikkus: This class is too complex. It needs splitting further.
// It's a nightmare to understand, especially with so few comments :(
@ -240,6 +242,7 @@ Workspace::Workspace( bool restore )
keys (0),
root (0)
{
_self = this;
d = new WorkspacePrivate;
mgr = new PluginMgr;
connect(options, SIGNAL(resetPlugin()), mgr, SLOT(resetPlugin()));
@ -299,6 +302,7 @@ Workspace::Workspace( bool restore )
restoreLegacySession(kapp->sessionConfig());
}
void Workspace::init()
{
supportWindow = new QWidget;
@ -419,6 +423,7 @@ Workspace::~Workspace()
delete supportWindow;
delete mgr;
delete d;
_self = 0;
}

View file

@ -96,6 +96,8 @@ public:
Workspace( bool restore = FALSE );
virtual ~Workspace();
static Workspace * self() { return _self; }
virtual bool workspaceEvent( XEvent * );
bool hasClient(Client *);
@ -386,6 +388,7 @@ private:
QTimer focusEnsuranceTimer;
WorkspacePrivate* d;
static Workspace *_self;
};
inline WId Workspace::rootWin() const