all repos — fluxbox @ 6c10acb3cb57a6038202e8967ecd64ac234d0075

custom fork of the fluxbox windowmanager

fixed workspace name to std string
fluxgen fluxgen
commit

6c10acb3cb57a6038202e8967ecd64ac234d0075

parent

5a0014f4105787ef57c0ea6f17d45a98c1bf5e76

2 files changed, 28 insertions(+), 27 deletions(-)

jump to
M src/Workspace.ccsrc/Workspace.cc

@@ -19,8 +19,9 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// stupid macros needed to access some functions in version 2 of the GNU C -// library +// $Id: Workspace.cc,v 1.6 2002/01/20 02:08:12 fluxgen Exp $ + +// use GNU extensions #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // _GNU_SOURCE

@@ -28,9 +29,6 @@

#ifdef HAVE_CONFIG_H # include "../config.h" #endif // HAVE_CONFIG_H - -#include <X11/Xlib.h> -#include <X11/Xatom.h> #include "i18n.hh" #include "fluxbox.hh"

@@ -50,7 +48,15 @@ #ifdef STDC_HEADERS

# include <string.h> #endif // STDC_HEADERS -Workspace::Workspace(BScreen *scrn, int i) { +#include <X11/Xlib.h> +#include <X11/Xatom.h> + +Workspace::Workspace(BScreen *scrn, int i): +screen(scrn), +lastfocus(0), +name(""), +cascade_x(32), cascade_y(32) +{ screen = scrn; cascade_x = cascade_y = 32;

@@ -61,10 +67,7 @@ stackingList = new LinkedList<FluxboxWindow>;

windowList = new LinkedList<FluxboxWindow>; clientmenu = new Clientmenu(this); - lastfocus = (FluxboxWindow *) 0; - char *tmp; - name = (char *) 0; screen->getNameOfWorkspace(id, &tmp); setName(tmp);

@@ -73,20 +76,19 @@ delete [] tmp;

} -Workspace::~Workspace(void) { +Workspace::~Workspace() { delete stackingList; delete windowList; delete clientmenu; - - if (name) - delete [] name; } const int Workspace::addWindow(FluxboxWindow *w, Bool place) { - if (! w) return -1; + if (! w) + return -1; - if (place) placeWindow(w); + if (place) + placeWindow(w); w->setWorkspace(id); w->setWindowNumber(windowList->count());

@@ -123,8 +125,8 @@

if (! top || ! top->setInputFocus()) { Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0); XSetInputFocus(Fluxbox::instance()->getXDisplay(), - screen->getToolbar()->getWindowID(), - RevertToParent, CurrentTime); + screen->getToolbar()->getWindowID(), + RevertToParent, CurrentTime); } } }

@@ -302,14 +304,12 @@ }

void Workspace::setName(char *new_name) { - if (name) - delete [] name; if (new_name) { - name = StringUtil::strdup(new_name); + name = new_name; } else { - name = new char[128]; - sprintf(name, I18n::instance()-> + char tname[128]; + sprintf(tname, I18n::instance()-> getMessage( #ifdef NLS WorkspaceSet, WorkspaceDefaultNameFormat,

@@ -317,11 +317,12 @@ #else // !NLS

0, 0, #endif // NLS "Workspace %d"), id + 1); + name = tname; } screen->updateWorkspaceNamesAtom(); - clientmenu->setLabel(name); + clientmenu->setLabel(name.c_str()); clientmenu->update(); }
M src/Workspace.hhsrc/Workspace.hh

@@ -22,14 +22,14 @@

#ifndef _WORKSPACE_HH_ #define _WORKSPACE_HH_ +#include "LinkedList.hh" #include <X11/Xlib.h> +#include <string> class BScreen; class Clientmenu; class Workspace; class FluxboxWindow; - -#include "LinkedList.hh" class Workspace {

@@ -40,7 +40,7 @@ Clientmenu *clientmenu;

LinkedList<FluxboxWindow> *stackingList, *windowList; - char *name; + std::string name; int id, cascade_x, cascade_y;

@@ -58,7 +58,7 @@ inline FluxboxWindow *getLastFocusedWindow(void) { return lastfocus; }

inline Clientmenu *getMenu(void) { return clientmenu; } - inline const char *getName(void) const { return name; } + inline const char *getName(void) const { return name.c_str(); } inline const int &getWorkspaceID(void) const { return id; }