diff options
author | fluxgen <fluxgen> | 2002-01-20 02:08:12 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-01-20 02:08:12 (GMT) |
commit | 6c10acb3cb57a6038202e8967ecd64ac234d0075 (patch) | |
tree | e4788a4c4c7cfe9d3f238fcc0a30a8af5c2463da | |
parent | 5a0014f4105787ef57c0ea6f17d45a98c1bf5e76 (diff) | |
download | fluxbox-6c10acb3cb57a6038202e8967ecd64ac234d0075.zip fluxbox-6c10acb3cb57a6038202e8967ecd64ac234d0075.tar.bz2 |
fixed workspace name to std string
-rw-r--r-- | src/Workspace.cc | 47 | ||||
-rw-r--r-- | src/Workspace.hh | 8 |
2 files changed, 28 insertions, 27 deletions
diff --git a/src/Workspace.cc b/src/Workspace.cc index 8862263..a98f970 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc | |||
@@ -19,8 +19,9 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // stupid macros needed to access some functions in version 2 of the GNU C | 22 | // $Id: Workspace.cc,v 1.6 2002/01/20 02:08:12 fluxgen Exp $ |
23 | // library | 23 | |
24 | // use GNU extensions | ||
24 | #ifndef _GNU_SOURCE | 25 | #ifndef _GNU_SOURCE |
25 | #define _GNU_SOURCE | 26 | #define _GNU_SOURCE |
26 | #endif // _GNU_SOURCE | 27 | #endif // _GNU_SOURCE |
@@ -29,9 +30,6 @@ | |||
29 | # include "../config.h" | 30 | # include "../config.h" |
30 | #endif // HAVE_CONFIG_H | 31 | #endif // HAVE_CONFIG_H |
31 | 32 | ||
32 | #include <X11/Xlib.h> | ||
33 | #include <X11/Xatom.h> | ||
34 | |||
35 | #include "i18n.hh" | 33 | #include "i18n.hh" |
36 | #include "fluxbox.hh" | 34 | #include "fluxbox.hh" |
37 | #include "Clientmenu.hh" | 35 | #include "Clientmenu.hh" |
@@ -50,7 +48,15 @@ | |||
50 | # include <string.h> | 48 | # include <string.h> |
51 | #endif // STDC_HEADERS | 49 | #endif // STDC_HEADERS |
52 | 50 | ||
53 | Workspace::Workspace(BScreen *scrn, int i) { | 51 | #include <X11/Xlib.h> |
52 | #include <X11/Xatom.h> | ||
53 | |||
54 | Workspace::Workspace(BScreen *scrn, int i): | ||
55 | screen(scrn), | ||
56 | lastfocus(0), | ||
57 | name(""), | ||
58 | cascade_x(32), cascade_y(32) | ||
59 | { | ||
54 | screen = scrn; | 60 | screen = scrn; |
55 | 61 | ||
56 | cascade_x = cascade_y = 32; | 62 | cascade_x = cascade_y = 32; |
@@ -61,10 +67,7 @@ Workspace::Workspace(BScreen *scrn, int i) { | |||
61 | windowList = new LinkedList<FluxboxWindow>; | 67 | windowList = new LinkedList<FluxboxWindow>; |
62 | clientmenu = new Clientmenu(this); | 68 | clientmenu = new Clientmenu(this); |
63 | 69 | ||
64 | lastfocus = (FluxboxWindow *) 0; | ||
65 | |||
66 | char *tmp; | 70 | char *tmp; |
67 | name = (char *) 0; | ||
68 | screen->getNameOfWorkspace(id, &tmp); | 71 | screen->getNameOfWorkspace(id, &tmp); |
69 | setName(tmp); | 72 | setName(tmp); |
70 | 73 | ||
@@ -73,20 +76,19 @@ Workspace::Workspace(BScreen *scrn, int i) { | |||
73 | } | 76 | } |
74 | 77 | ||
75 | 78 | ||
76 | Workspace::~Workspace(void) { | 79 | Workspace::~Workspace() { |
77 | delete stackingList; | 80 | delete stackingList; |
78 | delete windowList; | 81 | delete windowList; |
79 | delete clientmenu; | 82 | delete clientmenu; |
80 | |||
81 | if (name) | ||
82 | delete [] name; | ||
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | const int Workspace::addWindow(FluxboxWindow *w, Bool place) { | 86 | const int Workspace::addWindow(FluxboxWindow *w, Bool place) { |
87 | if (! w) return -1; | 87 | if (! w) |
88 | return -1; | ||
88 | 89 | ||
89 | if (place) placeWindow(w); | 90 | if (place) |
91 | placeWindow(w); | ||
90 | 92 | ||
91 | w->setWorkspace(id); | 93 | w->setWorkspace(id); |
92 | w->setWindowNumber(windowList->count()); | 94 | w->setWindowNumber(windowList->count()); |
@@ -123,8 +125,8 @@ const int Workspace::removeWindow(FluxboxWindow *w) { | |||
123 | if (! top || ! top->setInputFocus()) { | 125 | if (! top || ! top->setInputFocus()) { |
124 | Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0); | 126 | Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0); |
125 | XSetInputFocus(Fluxbox::instance()->getXDisplay(), | 127 | XSetInputFocus(Fluxbox::instance()->getXDisplay(), |
126 | screen->getToolbar()->getWindowID(), | 128 | screen->getToolbar()->getWindowID(), |
127 | RevertToParent, CurrentTime); | 129 | RevertToParent, CurrentTime); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | } | 132 | } |
@@ -302,14 +304,12 @@ void Workspace::setCurrent(void) { | |||
302 | 304 | ||
303 | 305 | ||
304 | void Workspace::setName(char *new_name) { | 306 | void Workspace::setName(char *new_name) { |
305 | if (name) | ||
306 | delete [] name; | ||
307 | 307 | ||
308 | if (new_name) { | 308 | if (new_name) { |
309 | name = StringUtil::strdup(new_name); | 309 | name = new_name; |
310 | } else { | 310 | } else { |
311 | name = new char[128]; | 311 | char tname[128]; |
312 | sprintf(name, I18n::instance()-> | 312 | sprintf(tname, I18n::instance()-> |
313 | getMessage( | 313 | getMessage( |
314 | #ifdef NLS | 314 | #ifdef NLS |
315 | WorkspaceSet, WorkspaceDefaultNameFormat, | 315 | WorkspaceSet, WorkspaceDefaultNameFormat, |
@@ -317,11 +317,12 @@ void Workspace::setName(char *new_name) { | |||
317 | 0, 0, | 317 | 0, 0, |
318 | #endif // NLS | 318 | #endif // NLS |
319 | "Workspace %d"), id + 1); | 319 | "Workspace %d"), id + 1); |
320 | name = tname; | ||
320 | } | 321 | } |
321 | 322 | ||
322 | screen->updateWorkspaceNamesAtom(); | 323 | screen->updateWorkspaceNamesAtom(); |
323 | 324 | ||
324 | clientmenu->setLabel(name); | 325 | clientmenu->setLabel(name.c_str()); |
325 | clientmenu->update(); | 326 | clientmenu->update(); |
326 | } | 327 | } |
327 | 328 | ||
diff --git a/src/Workspace.hh b/src/Workspace.hh index 17de03c..9e621c3 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh | |||
@@ -22,15 +22,15 @@ | |||
22 | #ifndef _WORKSPACE_HH_ | 22 | #ifndef _WORKSPACE_HH_ |
23 | #define _WORKSPACE_HH_ | 23 | #define _WORKSPACE_HH_ |
24 | 24 | ||
25 | #include "LinkedList.hh" | ||
25 | #include <X11/Xlib.h> | 26 | #include <X11/Xlib.h> |
27 | #include <string> | ||
26 | 28 | ||
27 | class BScreen; | 29 | class BScreen; |
28 | class Clientmenu; | 30 | class Clientmenu; |
29 | class Workspace; | 31 | class Workspace; |
30 | class FluxboxWindow; | 32 | class FluxboxWindow; |
31 | 33 | ||
32 | #include "LinkedList.hh" | ||
33 | |||
34 | 34 | ||
35 | class Workspace { | 35 | class Workspace { |
36 | private: | 36 | private: |
@@ -40,7 +40,7 @@ private: | |||
40 | 40 | ||
41 | LinkedList<FluxboxWindow> *stackingList, *windowList; | 41 | LinkedList<FluxboxWindow> *stackingList, *windowList; |
42 | 42 | ||
43 | char *name; | 43 | std::string name; |
44 | int id, cascade_x, cascade_y; | 44 | int id, cascade_x, cascade_y; |
45 | 45 | ||
46 | 46 | ||
@@ -58,7 +58,7 @@ public: | |||
58 | 58 | ||
59 | inline Clientmenu *getMenu(void) { return clientmenu; } | 59 | inline Clientmenu *getMenu(void) { return clientmenu; } |
60 | 60 | ||
61 | inline const char *getName(void) const { return name; } | 61 | inline const char *getName(void) const { return name.c_str(); } |
62 | 62 | ||
63 | inline const int &getWorkspaceID(void) const { return id; } | 63 | inline const int &getWorkspaceID(void) const { return id; } |
64 | 64 | ||