From 0ec9f1a21dba10a3f7dab273a0ba485d5cb9cb41 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 7 May 2002 13:57:09 +0000 Subject: changed clientmenu to regular --- src/Workspace.cc | 59 +++++++++++++++++++++++++++++++++----------------------- src/Workspace.hh | 57 +++++++++++++++++++++++++++--------------------------- 2 files changed, 64 insertions(+), 52 deletions(-) diff --git a/src/Workspace.cc b/src/Workspace.cc index 3f57e37..57d3a74 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Workspace.cc,v 1.18 2002/04/09 23:18:12 fluxgen Exp $ +// $Id: Workspace.cc,v 1.19 2002/05/07 13:57:09 fluxgen Exp $ // use GNU extensions #ifndef _GNU_SOURCE @@ -43,13 +43,8 @@ #include "Windowmenu.hh" #include "StringUtil.hh" -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef STDC_HEADERS -# include -#endif // STDC_HEADERS +#include +#include #include #include @@ -58,16 +53,16 @@ #include using namespace std; + Workspace::Workspace(BScreen *scrn, unsigned int i): screen(scrn), lastfocus(0), +m_clientmenu(this), m_name(""), m_id(i), cascade_x(32), cascade_y(32) { - clientmenu = new Clientmenu(this); - char *tmp; screen->getNameOfWorkspace(m_id, &tmp); setName(tmp); @@ -78,7 +73,7 @@ cascade_x(32), cascade_y(32) Workspace::~Workspace() { - delete clientmenu; + } @@ -96,23 +91,34 @@ const int Workspace::addWindow(FluxboxWindow *w, bool place) { //insert window after the currently focused window FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow(); + //if there isn't any window that's focused, just add it to the end of the list if (focused == 0) { windowList.push_back(w); + //Add client to clientmenu + m_clientmenu.insert(w->getTitle().c_str()); } else { Windows::iterator it = windowList.begin(); - for (; it != windowList.end(); ++it) { + size_t client_insertpoint=0; + for (; it != windowList.end(); ++it, ++client_insertpoint) { if (*it == focused) { - ++it; + ++it; break; } } - windowList.insert(it, w); - } - clientmenu->insert(w->getTitle().c_str()); - clientmenu->update(); + windowList.insert(it, w); + //Add client to clientmenu + m_clientmenu.insert(w->getTitle().c_str(), client_insertpoint); + + } + + + + //update menugraphics + m_clientmenu.update(); + screen->updateNetizenWindowAdd(w->getClientWindow(), m_id); raiseWindow(w); @@ -159,8 +165,8 @@ const int Workspace::removeWindow(FluxboxWindow *w) { } } - clientmenu->remove(w->getWindowNumber()); - clientmenu->update(); + m_clientmenu.remove(w->getWindowNumber()); + m_clientmenu.update(); screen->updateNetizenWindowDel(w->getClientWindow()); @@ -294,7 +300,7 @@ void Workspace::lowerWindow(FluxboxWindow *w) { void Workspace::reconfigure(void) { - clientmenu->reconfigure(); + m_clientmenu.reconfigure(); Windows::iterator it = windowList.begin(); Windows::iterator it_end = windowList.end(); @@ -305,10 +311,15 @@ void Workspace::reconfigure(void) { } -FluxboxWindow *Workspace::getWindow(unsigned int index) const{ +const FluxboxWindow *Workspace::getWindow(unsigned int index) const { if (index < windowList.size()) return windowList[index]; + return 0; +} +FluxboxWindow *Workspace::getWindow(unsigned int index) { + if (index < windowList.size()) + return windowList[index]; return 0; } @@ -319,7 +330,7 @@ const int Workspace::getCount(void) const { void Workspace::update(void) { - clientmenu->update(); + m_clientmenu.update(); screen->getToolbar()->redrawWindowLabel(True); } @@ -353,8 +364,8 @@ void Workspace::setName(const char *name) { screen->updateWorkspaceNamesAtom(); - clientmenu->setLabel(m_name.c_str()); - clientmenu->update(); + m_clientmenu.setLabel(m_name.c_str()); + m_clientmenu.update(); } //------------ shutdown --------- diff --git a/src/Workspace.hh b/src/Workspace.hh index 5e4507b..fa7f245 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -25,7 +25,9 @@ #ifndef WORKSPACE_HH #define WORKSPACE_HH +#include "Clientmenu.hh" #include "Window.hh" +#include "NotCopyable.hh" #include #include @@ -33,46 +35,49 @@ #include class BScreen; -class Clientmenu; -class Workspace; - -class Workspace { +class Workspace:private NotCopyable { public: typedef std::vector Windows; Workspace(BScreen *screen, unsigned int workspaceid= 0); - ~Workspace(void); - - inline BScreen *getScreen(void) const { return screen; } - inline FluxboxWindow *getLastFocusedWindow(void) const { return lastfocus; } - inline Clientmenu *menu(void) const { return clientmenu; } - inline const std::string &name(void) const { return m_name; } - inline const unsigned int workspaceID(void) const { return m_id; } + ~Workspace(); inline void setLastFocusedWindow(FluxboxWindow *w) { lastfocus = w; } - FluxboxWindow *getWindow(unsigned int id) const; - inline Windows &getWindowList() { return windowList; } - bool isCurrent(void) const; - bool isLastWindow(FluxboxWindow *window) const; - const int addWindow(FluxboxWindow *window, bool place = false); - const int removeWindow(FluxboxWindow *); - const int getCount(void) const; void setName(const char *name); - void showAll(void); - void hideAll(void); - void removeAll(void); + void showAll(); + void hideAll(); + void removeAll(); void raiseWindow(FluxboxWindow *); void lowerWindow(FluxboxWindow *); void reconfigure(); void update(); - void setCurrent(void); - void shutdown(void); + void setCurrent(); + void shutdown(); + const int addWindow(FluxboxWindow *window, bool place = false); + const int removeWindow(FluxboxWindow *); + + inline BScreen *getScreen() const { return screen; } + inline FluxboxWindow *getLastFocusedWindow(void) const { return lastfocus; } + inline Clientmenu *menu() { return &m_clientmenu; } + inline const Clientmenu *menu() const { return &m_clientmenu; } + inline const std::string &name() const { return m_name; } + inline const unsigned int workspaceID() const { return m_id; } + + FluxboxWindow *getWindow(unsigned int id); + const FluxboxWindow *getWindow(unsigned int id) const; + inline const Windows &getWindowList() const { return windowList; } + bool isCurrent() const; + bool isLastWindow(FluxboxWindow *window) const; + const int getCount() const; + +protected: + void placeWindow(FluxboxWindow *); private: BScreen *screen; FluxboxWindow *lastfocus; - Clientmenu *clientmenu; + Clientmenu m_clientmenu; typedef std::list WindowStack; @@ -83,10 +88,6 @@ private: std::string m_name; unsigned int m_id; int cascade_x, cascade_y; - - -protected: - void placeWindow(FluxboxWindow *); }; -- cgit v0.11.2