diff --git a/main.cpp b/main.cpp index 9c9e25563c..5cc6eba35f 100644 --- a/main.cpp +++ b/main.cpp @@ -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(); } diff --git a/main.h b/main.h index c189b6a4ed..8e1f7b6fe8 100644 --- a/main.h +++ b/main.h @@ -9,7 +9,6 @@ Copyright (C) 1999, 2000 Matthias Ettrich #include #include "workspace.h" -typedef QValueList WorkspaceList; class Application : public KApplication { public: @@ -21,9 +20,6 @@ public: protected: bool x11EventFilter( XEvent * ); - -private: - WorkspaceList workspaces; }; diff --git a/workspace.cpp b/workspace.cpp index a3bf7176b8..8931230bfb 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -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; } diff --git a/workspace.h b/workspace.h index bea759fdb9..d9b8f40630 100644 --- a/workspace.h +++ b/workspace.h @@ -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