From 70f3639c0247c667b3ec5ddfb9e2726c08cbe12c Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 3 Apr 2002 23:04:01 +0000 Subject: std::string for title and icon title in FluxboxWindow --- src/IconBar.cc | 22 ++++++++---------- src/Screen.cc | 4 ++-- src/Tab.cc | 12 +++++----- src/Toolbar.cc | 16 ++++++------- src/Window.cc | 71 +++++++++++++++++--------------------------------------- src/Window.hh | 12 ++++------ src/Workspace.cc | 4 ++-- 7 files changed, 54 insertions(+), 87 deletions(-) diff --git a/src/IconBar.cc b/src/IconBar.cc index 380b7a5..0377d3b 100644 --- a/src/IconBar.cc +++ b/src/IconBar.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconBar.cc,v 1.11 2002/03/23 15:14:45 fluxgen Exp $ +// $Id: IconBar.cc,v 1.12 2002/04/03 23:01:49 fluxgen Exp $ #include "IconBar.hh" #include "i18n.hh" @@ -239,8 +239,6 @@ void IconBar::draw(IconBarObj *obj, int width) { FluxboxWindow *fluxboxwin = obj->getFluxboxWin(); Window iconwin = obj->getIconWin(); - const char *title = fluxboxwin->getIconTitle(); - unsigned int title_len = strlen(title); unsigned int title_text_w; const int multibyte = I18n::instance()->multibyte(); @@ -248,15 +246,15 @@ void IconBar::draw(IconBarObj *obj, int width) { if (multibyte) { XRectangle ink, logical; XmbTextExtents(m_screen->getWindowStyle()->font.set, - title, title_len, &ink, &logical); + fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size(), &ink, &logical); title_text_w = logical.width; } else { title_text_w = XTextWidth(m_screen->getWindowStyle()->font.fontstruct, - title, title_len); + fluxboxwin->getIconTitle().c_str(), fluxboxwin->getIconTitle().size()); } int l = title_text_w; - int dlen=title_len; + unsigned int dlen=fluxboxwin->getIconTitle().size(); unsigned int bevel_w = m_screen->getBevelWidth(); int dx=bevel_w*2; @@ -264,12 +262,12 @@ void IconBar::draw(IconBarObj *obj, int width) { if (multibyte) { XRectangle ink, logical; XmbTextExtents(m_screen->getWindowStyle()->tab.font.set, - title, dlen, - &ink, &logical); + fluxboxwin->getIconTitle().c_str(), dlen, + &ink, &logical); l = logical.width; } else l = XTextWidth(m_screen->getWindowStyle()->tab.font.fontstruct, - title, dlen); + fluxboxwin->getIconTitle().c_str(), dlen); l += (bevel_w * 4); if (l < width) @@ -295,13 +293,13 @@ void IconBar::draw(IconBarObj *obj, int width) { XmbDrawString(m_display, iconwin, m_screen->getWindowStyle()->tab.font.set, m_screen->getWindowStyle()->tab.l_text_focus_gc, dx, - 1 - m_screen->getWindowStyle()->tab.font.set_extents->max_ink_extent.y, - title, dlen); + 1 - m_screen->getWindowStyle()->tab.font.set_extents->max_ink_extent.y, + fluxboxwin->getIconTitle().c_str(), dlen); } else { XDrawString(m_display, iconwin, m_screen->getWindowStyle()->tab.l_text_focus_gc, dx, m_screen->getWindowStyle()->tab.font.fontstruct->ascent + 1, - title, dlen); + fluxboxwin->getIconTitle().c_str(), dlen); } } diff --git a/src/Screen.cc b/src/Screen.cc index c34e73c..cce934d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.40 2002/04/02 23:14:54 fluxgen Exp $ +// $Id: Screen.cc,v 1.41 2002/04/03 23:02:16 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -696,7 +696,7 @@ void BScreen::addIcon(FluxboxWindow *w) { iconList.push_back(w); - iconmenu->insert(w->getIconTitle()); + iconmenu->insert(w->getIconTitle().c_str()); iconmenu->update(); toolbar->addIcon(w); } diff --git a/src/Tab.cc b/src/Tab.cc index 22925c0..a14de09 100644 --- a/src/Tab.cc +++ b/src/Tab.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Tab.cc,v 1.21 2002/04/03 12:08:54 fluxgen Exp $ +// $Id: Tab.cc,v 1.22 2002/04/03 23:01:04 fluxgen Exp $ #include "Tab.hh" @@ -361,33 +361,33 @@ void Tab::draw(bool pressed) { (!m_win->isShaded() && m_win->getScreen()->isTabRotateVertical())) { tabtext_w = DrawUtil::XRotTextWidth(m_win->getScreen()->getWindowStyle()->tab.rot_font, - m_win->client.title, m_win->client.title_len); + m_win->getTitle().c_str(), m_win->getTitle().size()); tabtext_w += (m_win->frame.bevel_w * 4); DrawUtil::DrawRotString(m_display, m_tabwin, gc, m_win->getScreen()->getWindowStyle()->tab.rot_font, m_win->getScreen()->getWindowStyle()->tab.font.justify, tabtext_w, m_size_w, m_size_h, - m_win->frame.bevel_w, m_win->client.title); + m_win->frame.bevel_w, m_win->getTitle().c_str()); } else { if (I18n::instance()->multibyte()) { // TODO: maybe move this out from here? XRectangle ink, logical; XmbTextExtents(m_win->getScreen()->getWindowStyle()->tab.font.set, - m_win->client.title, m_win->client.title_len, + m_win->getTitle().c_str(), m_win->getTitle().size(), &ink, &logical); tabtext_w = logical.width; } else { tabtext_w = XTextWidth( m_win->getScreen()->getWindowStyle()->tab.font.fontstruct, - m_win->client.title, m_win->client.title_len); + m_win->getTitle().c_str(), m_win->getTitle().size()); } tabtext_w += (m_win->frame.bevel_w * 4); DrawUtil::DrawString(m_display, m_tabwin, gc, &m_win->getScreen()->getWindowStyle()->tab.font, tabtext_w, m_size_w, - m_win->frame.bevel_w, m_win->client.title); + m_win->frame.bevel_w, m_win->getTitle().c_str()); } } diff --git a/src/Toolbar.cc b/src/Toolbar.cc index fc61d55..295a44c 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.17 2002/04/03 12:08:54 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.18 2002/04/03 23:02:49 fluxgen Exp $ // stupid macros needed to access some functions in version 2 of the GNU C // library @@ -727,17 +727,17 @@ void Toolbar::redrawWindowLabel(Bool redraw) { if (foc->getScreen() != screen) return; - int dx = (frame.bevel_w * 2), dlen = strlen(foc->getTitle()); + int dx = (frame.bevel_w * 2), dlen = foc->getTitle().size(); unsigned int l; I18n *i18n = I18n::instance(); if (i18n->multibyte()) { XRectangle ink, logical; - XmbTextExtents(screen->getToolbarStyle()->font.set, foc->getTitle(), dlen, + XmbTextExtents(screen->getToolbarStyle()->font.set, foc->getTitle().c_str(), dlen, &ink, &logical); l = logical.width; } else - l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle(), dlen); + l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle().c_str(), dlen); l += (frame.bevel_w * 4); @@ -746,10 +746,10 @@ void Toolbar::redrawWindowLabel(Bool redraw) { if (i18n->multibyte()) { XRectangle ink, logical; XmbTextExtents(screen->getToolbarStyle()->font.set, - foc->getTitle(), dlen, &ink, &logical); + foc->getTitle().c_str(), dlen, &ink, &logical); l = logical.width; } else - l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle(), dlen); + l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle().c_str(), dlen); l += (frame.bevel_w * 4); @@ -774,12 +774,12 @@ void Toolbar::redrawWindowLabel(Bool redraw) { screen->getToolbarStyle()->font.set, screen->getToolbarStyle()->w_text_gc, dx, 1 - screen->getToolbarStyle()->font.set_extents->max_ink_extent.y, - foc->getTitle(), dlen); + foc->getTitle().c_str(), dlen); else XDrawString(display, frame.window_label, screen->getToolbarStyle()->w_text_gc, dx, screen->getToolbarStyle()->font.fontstruct->ascent + 1, - foc->getTitle(), dlen); + foc->getTitle().c_str(), dlen); } else XClearWindow(display, frame.window_label); } diff --git a/src/Window.cc b/src/Window.cc index bbeb640..06c295a 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.35 2002/03/23 15:14:45 fluxgen Exp $ +// $Id: Window.cc,v 1.36 2002/04/03 23:01:04 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -152,9 +152,6 @@ tab(0) client.wm_hint_flags = client.normal_hint_flags = 0; client.transient_for = client.transient = 0; - client.title = 0; - client.title_len = 0; - client.icon_title = 0; client.mwm_hint = (MwmHints *) 0; client.blackbox_hint = 0; @@ -421,12 +418,6 @@ FluxboxWindow::~FluxboxWindow(void) { if (windowmenu) delete windowmenu; - if (client.title) - delete [] client.title; - - if (client.icon_title) - delete [] client.icon_title; - if (tab!=0) delete tab; tab = 0; @@ -1366,15 +1357,15 @@ void FluxboxWindow::reconfigure(void) { client.y = frame.y + frame.y_border + frame.mwm_border_w + screen->getBorderWidth(); - if (client.title) { + if (getTitle().size()>0) { if (I18n::instance()->multibyte()) { XRectangle ink, logical; XmbTextExtents(screen->getWindowStyle()->font.set, - client.title, client.title_len, &ink, &logical); + getTitle().c_str(), getTitle().size(), &ink, &logical); client.title_text_w = logical.width; } else { client.title_text_w = XTextWidth(screen->getWindowStyle()->font.fontstruct, - client.title, client.title_len); + getTitle().c_str(), getTitle().size()); } client.title_text_w += (frame.bevel_w * 4); @@ -1447,10 +1438,6 @@ void FluxboxWindow::positionWindows(void) { void FluxboxWindow::getWMName(void) { - if (client.title) { - delete [] client.title; - client.title = 0; - } XTextProperty text_prop; char **list; @@ -1466,44 +1453,32 @@ void FluxboxWindow::getWMName(void) { if ((XmbTextPropertyToTextList(display, &text_prop, &list, &num) == Success) && (num > 0) && *list) { - client.title = StringUtil::strdup(*list); + client.title = static_cast(*list); XFreeStringList(list); } else - client.title = StringUtil::strdup((char *) text_prop.value); + client.title = (char *)text_prop.value; } else - client.title = StringUtil::strdup((char *) text_prop.value); - + client.title = (char *)text_prop.value; XFree((char *) text_prop.value); } else - client.title = StringUtil::strdup(i18n->getMessage( -#ifdef NLS - WindowSet, WindowUnnamed, -#else // !NLS - 0, 0, -#endif // - "Unnamed")); + client.title = i18n->getMessage( + WindowSet, WindowUnnamed, + "Unnamed"); } else { - client.title = StringUtil::strdup(i18n->getMessage( -#ifdef NLS - WindowSet, WindowUnnamed, -#else // !NLS - 0, 0, -#endif // - "Unnamed")); + client.title = i18n->getMessage( + WindowSet, WindowUnnamed, + "Unnamed"); } - - client.title_len = strlen(client.title); if (i18n->multibyte()) { XRectangle ink, logical; XmbTextExtents(screen->getWindowStyle()->font.set, - client.title, client.title_len, &ink, &logical); + getTitle().c_str(), getTitle().size(), &ink, &logical); client.title_text_w = logical.width; } else { - client.title_len = strlen(client.title); client.title_text_w = XTextWidth(screen->getWindowStyle()->font.fontstruct, - client.title, client.title_len); + getTitle().c_str(), getTitle().size()); } client.title_text_w += (frame.bevel_w * 4); @@ -1511,10 +1486,6 @@ void FluxboxWindow::getWMName(void) { void FluxboxWindow::getWMIconName(void) { - if (client.icon_title) { - delete [] client.icon_title; - client.icon_title = (char *) 0; - } XTextProperty text_prop; char **list; @@ -1528,18 +1499,18 @@ void FluxboxWindow::getWMIconName(void) { if ((XmbTextPropertyToTextList(display, &text_prop, &list, &num) == Success) && (num > 0) && *list) { - client.icon_title = StringUtil::strdup(*list); + client.icon_title = (char *)*list; XFreeStringList(list); } else - client.icon_title = StringUtil::strdup((char *) text_prop.value); + client.icon_title = (char *)text_prop.value; } else - client.icon_title = StringUtil::strdup((char *) text_prop.value); + client.icon_title = (char *)text_prop.value; XFree((char *) text_prop.value); } else - client.icon_title = StringUtil::strdup(client.title); + client.icon_title = getTitle(); //assign title to icon title } else - client.icon_title = StringUtil::strdup(client.title); + client.icon_title = getTitle(); //assign title to icon title } @@ -2829,7 +2800,7 @@ void FluxboxWindow::redrawLabel(void) { DrawUtil::DrawString(display, frame.label, gc, &screen->getWindowStyle()->font, client.title_text_w, frame.label_w, - frame.bevel_w, client.title); + frame.bevel_w, getTitle().c_str()); } diff --git a/src/Window.hh b/src/Window.hh index 06e482b..73612d9 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.hh,v 1.14 2002/03/23 15:14:45 fluxgen Exp $ +// $Id: Window.hh,v 1.15 2002/04/03 23:01:04 fluxgen Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -146,8 +146,8 @@ public: inline Windowmenu *getWindowmenu(void) { return windowmenu; } - inline const char *getTitle(void) const { return client.title; } - inline const char *getIconTitle(void) const { return client.icon_title; } + inline const std::string &getTitle(void) const { return client.title; } + inline const std::string &getIconTitle(void) const { return client.icon_title; } inline const int getXFrame(void) const { return frame.x; } inline const int getYFrame(void) const { return frame.y; } inline const int getXClient(void) const { return client.x; } @@ -237,8 +237,8 @@ private: *transient; // which window is our transient? Window window, window_group; - char *title, *icon_title; - int x, y, old_bw, title_len; + std::string title, icon_title; + int x, y, old_bw; unsigned int width, height, title_text_w, min_width, min_height, max_width, max_height, width_inc, height_inc, min_aspect_x, min_aspect_y, max_aspect_x, max_aspect_y, @@ -384,8 +384,6 @@ protected: void downsize(void); void right_fixsize(int * = 0, int * = 0); void left_fixsize(int * = 0, int * = 0); - - }; diff --git a/src/Workspace.cc b/src/Workspace.cc index 814a0a2..761cdb1 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.15 2002/04/02 23:14:07 fluxgen Exp $ +// $Id: Workspace.cc,v 1.16 2002/04/03 23:04:01 fluxgen Exp $ // use GNU extensions #ifndef _GNU_SOURCE @@ -115,7 +115,7 @@ const int Workspace::addWindow(FluxboxWindow *w, bool place) { windowList.insert(it, w); } - clientmenu->insert(w->getTitle()); + clientmenu->insert(w->getTitle().c_str()); clientmenu->update(); screen->updateNetizenWindowAdd(w->getClientWindow(), id); -- cgit v0.11.2