From 8daa080d11a6bf9e6ed208563e738a02c9eb6cf8 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 23 Mar 2002 15:14:45 +0000 Subject: some signed/unsigned stuff --- src/Basemenu.cc | 5 ++-- src/IconBar.cc | 4 ++-- src/Screen.cc | 31 +++++++++++------------- src/Screen.hh | 19 +++++++-------- src/Toolbar.cc | 22 ++++++++--------- src/Window.cc | 26 ++++++++++---------- src/Window.hh | 72 ++++++++++++++++++++++++++------------------------------ src/Workspace.cc | 16 ++++++------- src/Workspace.hh | 11 +++++---- 9 files changed, 100 insertions(+), 106 deletions(-) diff --git a/src/Basemenu.cc b/src/Basemenu.cc index f78b47e..22e8886 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -22,10 +22,9 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.cc,v 1.14 2002/03/21 10:54:29 fluxgen Exp $ +// $Id: Basemenu.cc,v 1.15 2002/03/23 15:14:45 fluxgen Exp $ -// stupid macros needed to access some functions in version 2 of the GNU C -// library +//use GNU extensions #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // _GNU_SOURCE diff --git a/src/IconBar.cc b/src/IconBar.cc index 392a84c..380b7a5 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.10 2002/02/07 14:45:02 fluxgen Exp $ +// $Id: IconBar.cc,v 1.11 2002/03/23 15:14:45 fluxgen Exp $ #include "IconBar.hh" #include "i18n.hh" @@ -239,7 +239,7 @@ void IconBar::draw(IconBarObj *obj, int width) { FluxboxWindow *fluxboxwin = obj->getFluxboxWin(); Window iconwin = obj->getIconWin(); - char *title = *fluxboxwin->getIconTitle(); + const char *title = fluxboxwin->getIconTitle(); unsigned int title_len = strlen(title); unsigned int title_text_w; diff --git a/src/Screen.cc b/src/Screen.cc index 3c7f4a9..816c869 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.37 2002/03/19 14:30:42 fluxgen Exp $ +// $Id: Screen.cc,v 1.38 2002/03/23 15:14:45 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -728,11 +728,11 @@ void BScreen::removeIcon(FluxboxWindow *w) { } -FluxboxWindow *BScreen::getIcon(int index) { - if (index >= 0 && index < iconList.size()) +FluxboxWindow *BScreen::getIcon(unsigned int index) { + if (index < iconList.size()) return iconList[index]; - return (FluxboxWindow *) 0; + return 0; } @@ -782,8 +782,8 @@ int BScreen::removeLastWorkspace(void) { } -void BScreen::changeWorkspaceID(int id) { - if (! current_workspace || id >= workspacesList.size() || id < 0) +void BScreen::changeWorkspaceID(unsigned int id) { + if (! current_workspace || id >= workspacesList.size()) return; if (id != current_workspace->getWorkspaceID()) { @@ -819,13 +819,10 @@ void BScreen::changeWorkspaceID(int id) { updateNetizenCurrentWorkspace(); } -void BScreen::sendToWorkspace(int id) { - BScreen::sendToWorkspace(id, true); -} -void BScreen::sendToWorkspace(int id, bool changeWS) { +void BScreen::sendToWorkspace(unsigned int id, bool changeWS) { FluxboxWindow *win; - if (! current_workspace || id >= workspacesList.size() || id < 0) + if (! current_workspace || id >= workspacesList.size()) return; if (id != current_workspace->getWorkspaceID()) { @@ -1084,9 +1081,9 @@ void BScreen::addWorkspaceName(char *name) { } -void BScreen::getNameOfWorkspace(int id, char **name) { - if (id >= 0 && id < workspaceNames.size()) { - const char *wkspc_name = workspaceNames[id].c_str(); +void BScreen::getNameOfWorkspace(unsigned int workspace, char **name) { + if (workspace < workspaceNames.size()) { + const char *wkspc_name = workspaceNames[workspace].c_str(); if (wkspc_name) *name = StringUtil::strdup(wkspc_name); @@ -1095,10 +1092,10 @@ void BScreen::getNameOfWorkspace(int id, char **name) { } -void BScreen::reassociateWindow(FluxboxWindow *w, int wkspc_id, Bool ignore_sticky) { +void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) { if (! w) return; - if (wkspc_id == -1) + if (wkspc_id >= workspaceNames.size()) wkspc_id = current_workspace->getWorkspaceID(); if (w->getWorkspaceNumber() == wkspc_id) @@ -1807,7 +1804,7 @@ void BScreen::rightWorkspace(const int delta) { // Goes to the workspace "left" of the current //-------------------------------------------- void BScreen::leftWorkspace(const int delta) { - if (getCurrentWorkspaceID() >= delta) + if (getCurrentWorkspaceID() >= static_cast(delta)) changeWorkspaceID(getCurrentWorkspaceID()-delta); } diff --git a/src/Screen.hh b/src/Screen.hh index 5201eb7..9c3c39b 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.24 2002/03/19 14:30:42 fluxgen Exp $ +// $Id: Screen.hh,v 1.25 2002/03/23 15:14:45 fluxgen Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -111,7 +111,7 @@ public: inline Toolbar *getToolbar(void) { return toolbar; } - inline Workspace *getWorkspace(int w) { return workspacesList[w]; } + inline Workspace *getWorkspace(unsigned int w) { return ( w < workspacesList.size() ? workspacesList[w] : 0); } inline Workspace *getCurrentWorkspace(void) { return current_workspace; } inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; } @@ -121,10 +121,10 @@ public: inline const unsigned int getFrameWidth(void) const { return theme->getFrameWidth(); } inline const unsigned int getBorderWidth(void) const { return theme->getBorderWidth(); } inline const unsigned int getBorderWidth2x(void) const { return theme->getBorderWidth()*2; } - inline const int getCurrentWorkspaceID() { return current_workspace->getWorkspaceID(); } + inline const unsigned int getCurrentWorkspaceID() const { return current_workspace->getWorkspaceID(); } typedef std::vector Icons; - inline const int getCount(void) { return workspacesList.size(); } + inline const unsigned int getCount(void) { return workspacesList.size(); } inline const int getIconCount(void) { return iconList.size(); } inline Icons &getIconList(void) { return iconList; } @@ -191,7 +191,7 @@ public: inline Theme::MenuStyle *getMenuStyle(void) { return &theme->getMenuStyle(); } inline Theme::ToolbarStyle *getToolbarStyle(void) { return &theme->getToolbarStyle(); } - FluxboxWindow *getIcon(int); + FluxboxWindow *getIcon(unsigned int index); int addWorkspace(void); int removeLastWorkspace(void); @@ -209,12 +209,11 @@ public: void removeNetizen(Window); void addIcon(FluxboxWindow *); void removeIcon(FluxboxWindow *); - void getNameOfWorkspace(int, char **); - void changeWorkspaceID(int); - void sendToWorkspace(int); - void sendToWorkspace(int, bool); + void getNameOfWorkspace(unsigned int workspace, char **name); + void changeWorkspaceID(unsigned int); + void sendToWorkspace(unsigned int workspace, bool changeworkspace=true); void raiseWindows(Window *, int); - void reassociateWindow(FluxboxWindow *, int, Bool); + void reassociateWindow(FluxboxWindow *window, unsigned int workspace_id, bool ignore_sticky); void prevFocus(int = 0); void nextFocus(int = 0); void raiseFocus(void); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 3b9b652..efaefee 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.14 2002/03/19 14:30:42 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.15 2002/03/23 15:14:45 fluxgen Exp $ // stupid macros needed to access some functions in version 2 of the GNU C // library @@ -366,7 +366,7 @@ void Toolbar::reconfigure(void) { #endif // HAVE_STRFTIME - int i; + unsigned int i; unsigned int w = 0; frame.workspace_label_w = 0; @@ -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 = strlen(foc->getTitle()); 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(), dlen, &ink, &logical); l = logical.width; } else - l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, *foc->getTitle(), dlen); + l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle(), 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(), dlen, &ink, &logical); l = logical.width; } else - l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, *foc->getTitle(), dlen); + l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle(), 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(), dlen); else XDrawString(display, frame.window_label, - screen->getToolbarStyle()->w_text_gc, dx, - screen->getToolbarStyle()->font.fontstruct->ascent + 1, - *foc->getTitle(), dlen); + screen->getToolbarStyle()->w_text_gc, dx, + screen->getToolbarStyle()->font.fontstruct->ascent + 1, + foc->getTitle(), dlen); } else XClearWindow(display, frame.window_label); } diff --git a/src/Window.cc b/src/Window.cc index c74f101..bbeb640 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.34 2002/03/19 14:30:42 fluxgen Exp $ +// $Id: Window.cc,v 1.35 2002/03/23 15:14:45 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -411,9 +411,11 @@ FluxboxWindow::~FluxboxWindow(void) { XUngrabPointer(display, CurrentTime); } - if (workspace_number != -1 && window_number != -1) - screen->getWorkspace(workspace_number)->removeWindow(this); - else if (iconic) + if (!iconic) { + Workspace *workspace = screen->getWorkspace(workspace_number); + if (workspace) + workspace->removeWindow(this); + } else //it's iconic screen->removeIcon(this); if (windowmenu) @@ -2022,9 +2024,9 @@ void FluxboxWindow::iconify(void) { void FluxboxWindow::deiconify(bool reassoc, bool raise) { - if (iconic || reassoc) - screen->reassociateWindow(this, -1, false); - else if (workspace_number != screen->getCurrentWorkspace()->getWorkspaceID()) + if (iconic || reassoc) { + screen->reassociateWindow(this, screen->getCurrentWorkspace()->getWorkspaceID(), false); + } else if (workspace_number != screen->getCurrentWorkspace()->getWorkspaceID()) return; setState(NormalState); @@ -2443,7 +2445,7 @@ void FluxboxWindow::stick(void) { stuck = false; if (! iconic) - screen->reassociateWindow(this, -1, true); + screen->reassociateWindow(this, screen->getCurrentWorkspace()->getWorkspaceID(), true); } else { @@ -2712,8 +2714,8 @@ void FluxboxWindow::restoreAttributes(void) { current_state = save_state; } - if (((int) blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && - ((int) blackbox_attrib.workspace < screen->getCount())) { + if (( blackbox_attrib.workspace != screen->getCurrentWorkspaceID()) && + ( blackbox_attrib.workspace < screen->getCount())) { screen->reassociateWindow(this, blackbox_attrib.workspace, true); if (current_state == NormalState) current_state = WithdrawnState; @@ -3675,10 +3677,10 @@ void FluxboxWindow::changeBlackboxHints(BaseDisplay::BlackboxHints *net) { stick(); if ((net->flags & BaseDisplay::ATTRIB_WORKSPACE) && - (workspace_number != (signed) net->workspace)) { + (workspace_number != net->workspace)) { screen->reassociateWindow(this, net->workspace, true); - if (screen->getCurrentWorkspaceID() != (signed) net->workspace) + if (screen->getCurrentWorkspaceID() != net->workspace) withdraw(); else deiconify(); diff --git a/src/Window.hh b/src/Window.hh index 5bf7232..06e482b 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.13 2002/03/19 00:15:58 fluxgen Exp $ +// $Id: Window.hh,v 1.14 2002/03/23 15:14:45 fluxgen Exp $ #ifndef WINDOW_HH #define WINDOW_HH @@ -120,55 +120,50 @@ public: FluxboxWindow(Window, BScreen * = 0); virtual ~FluxboxWindow(void); - inline const bool isTransient(void) const - { return ((transient) ? true : false); } - inline const bool hasTransient(void) const - { return ((client.transient) ? true : false); } + inline const bool isTransient(void) const { return ((transient) ? true : false); } + inline const bool hasTransient(void) const { return ((client.transient) ? true : false); } inline const bool isManaged() const { return managed; } - inline const bool &isFocused(void) const { return focused; } - inline const bool &isVisible(void) const { return visible; } - inline const bool &isIconic(void) const { return iconic; } - inline const bool &isShaded(void) const { return shaded; } - inline const bool &isMaximized(void) const { return maximized; } - inline const bool &isIconifiable(void) const { return functions.iconify; } - inline const bool &isMaximizable(void) const { return functions.maximize; } - inline const bool &isResizable(void) const { return functions.resize; } - inline const bool &isClosable(void) const { return functions.close; } - inline const bool &isStuck(void) const { return stuck; } - inline const bool &hasTitlebar(void) const { return decorations.titlebar; } + inline const bool isFocused(void) const { return focused; } + inline const bool isVisible(void) const { return visible; } + inline const bool isIconic(void) const { return iconic; } + inline const bool isShaded(void) const { return shaded; } + inline const bool isMaximized(void) const { return maximized; } + inline const bool isIconifiable(void) const { return functions.iconify; } + inline const bool isMaximizable(void) const { return functions.maximize; } + inline const bool isResizable(void) const { return functions.resize; } + inline const bool isClosable(void) const { return functions.close; } + inline const bool isStuck(void) const { return stuck; } + inline const bool hasTitlebar(void) const { return decorations.titlebar; } inline const bool hasTab(void) const { return (tab!=0 ? true : false); } static void showError(FluxboxWindow::Error error); - inline BScreen *getScreen(void) { return screen; } - inline Tab *getTab(void) { return tab; } - inline FluxboxWindow *getTransient(void) { return client.transient; } - inline FluxboxWindow *getTransientFor(void) { return client.transient_for; } + inline BScreen *getScreen(void) const { return screen; } + inline Tab *getTab(void) const { return tab; } + inline FluxboxWindow *getTransient(void) const { return client.transient; } + inline FluxboxWindow *getTransientFor(void) const { return client.transient_for; } inline const Window &getFrameWindow(void) const { return frame.window; } inline const Window &getClientWindow(void) const { return client.window; } inline Windowmenu *getWindowmenu(void) { return windowmenu; } - inline char **getTitle(void) { return &client.title; } - inline char **getIconTitle(void) { 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; } - inline const int &getYClient(void) const { return client.y; } - inline const int &getWorkspaceNumber(void) const { return workspace_number; } - inline const int &getWindowNumber(void) const { return window_number; } + inline const char *getTitle(void) const { return client.title; } + inline const char *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; } + inline const int getYClient(void) const { return client.y; } + inline const unsigned int getWorkspaceNumber(void) const { return workspace_number; } + inline const int getWindowNumber(void) const { return window_number; } inline const WinLayer getLayer(void) const { return m_layer; } - inline const unsigned int &getWidth(void) const { return frame.width; } - inline const unsigned int &getHeight(void) const { return frame.height; } - inline const unsigned int &getClientHeight(void) const - { return client.height; } - inline const unsigned int &getClientWidth(void) const - { return client.width; } - inline const unsigned int &getTitleHeight(void) const - { return frame.title_h; } + inline const unsigned int getWidth(void) const { return frame.width; } + inline const unsigned int getHeight(void) const { return frame.height; } + inline const unsigned int getClientHeight(void) const { return client.height; } + inline const unsigned int getClientWidth(void) const { return client.width; } + inline const unsigned int getTitleHeight(void) const { return frame.title_h; } inline void setWindowNumber(int n) { window_number = n; } - inline const timeval& getLastFocusTime() const {return lastFocusTime;} + inline const timeval &getLastFocusTime() const {return lastFocusTime;} bool validateClient(void); bool setInputFocus(void); @@ -232,7 +227,8 @@ private: timeval lastFocusTime; - int focus_mode, window_number, workspace_number; + int focus_mode, window_number; + unsigned int workspace_number; unsigned long current_state; WinLayer m_layer; diff --git a/src/Workspace.cc b/src/Workspace.cc index 85bd2aa..ff6140d 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.13 2002/03/19 14:30:43 fluxgen Exp $ +// $Id: Workspace.cc,v 1.14 2002/03/23 15:14:45 fluxgen Exp $ // use GNU extensions #ifndef _GNU_SOURCE @@ -63,7 +63,7 @@ using namespace std; using namespace std; #endif -Workspace::Workspace(BScreen *scrn, int i): +Workspace::Workspace(BScreen *scrn, unsigned int i): screen(scrn), lastfocus(0), name(""), @@ -87,7 +87,7 @@ Workspace::~Workspace() { } -const int Workspace::addWindow(FluxboxWindow *w, Bool place) { +const int Workspace::addWindow(FluxboxWindow *w, bool place) { if (! w) return -1; @@ -100,7 +100,7 @@ const int Workspace::addWindow(FluxboxWindow *w, Bool place) { stackingList.push_front(w); windowList.push_back(w); - clientmenu->insert((const char **) w->getTitle()); + clientmenu->insert(w->getTitle()); clientmenu->update(); screen->updateNetizenWindowAdd(w->getClientWindow(), id); @@ -286,11 +286,11 @@ void Workspace::reconfigure(void) { } -FluxboxWindow *Workspace::getWindow(int index) { - if ((index >= 0) && (index < windowList.size())) +FluxboxWindow *Workspace::getWindow(unsigned int index) { + if (index < windowList.size()) return windowList[index]; - else - return 0; + + return 0; } diff --git a/src/Workspace.hh b/src/Workspace.hh index dd41281..d53420d 100644 --- a/src/Workspace.hh +++ b/src/Workspace.hh @@ -39,20 +39,20 @@ class Workspace { public: typedef std::vector Windows; - Workspace(BScreen *, int = 0); + Workspace(BScreen *, unsigned int = 0); ~Workspace(void); inline BScreen *getScreen(void) { return screen; } inline FluxboxWindow *getLastFocusedWindow(void) { return lastfocus; } inline Clientmenu *getMenu(void) { return clientmenu; } inline const char *getName(void) const { return name.c_str(); } - inline const int &getWorkspaceID(void) const { return id; } + inline const unsigned int getWorkspaceID(void) const { return id; } inline void setLastFocusedWindow(FluxboxWindow *w) { lastfocus = w; } - FluxboxWindow *getWindow(int); + FluxboxWindow *getWindow(unsigned int id); inline Windows &getWindowList() { return windowList; } bool isCurrent(void); bool isLastWindow(FluxboxWindow *); - const int addWindow(FluxboxWindow *, Bool = False); + const int addWindow(FluxboxWindow *, bool = False); const int removeWindow(FluxboxWindow *); const int getCount(void); @@ -79,7 +79,8 @@ private: Windows windowList; std::string name; - int id, cascade_x, cascade_y; + unsigned int id; + int cascade_x, cascade_y; protected: -- cgit v0.11.2