From 553104ee1d53104fa0790a9793a7047c61dd073f Mon Sep 17 00:00:00 2001 From: simonb Date: Sun, 16 Apr 2006 11:18:22 +0000 Subject: fix all compiler warnings with -Wall --- ChangeLog | 4 ++++ src/ClientPattern.cc | 7 ++++--- src/Container.cc | 4 ++-- src/FbTk/FbPixmap.cc | 11 ++++++----- src/FbTk/FbPixmap.hh | 12 ++++++------ src/FbTk/Menu.hh | 2 +- src/FbTk/Text.hh | 3 --- src/FbTk/TextBox.cc | 36 ++++++++++++++++++++---------------- src/FbTk/TextBox.hh | 4 ++-- src/FbWinFrame.cc | 8 ++++++++ src/IconButton.cc | 4 ++-- src/IconbarTool.cc | 9 +++++++-- src/ScreenPlacement.hh | 2 ++ src/ScreenResources.cc | 5 ++++- src/ToolFactory.cc | 2 +- src/Toolbar.cc | 1 - src/Window.cc | 14 ++++++++------ 17 files changed, 77 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fd3875..5d736a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ (Format: Year/Month/Day) Changes for 0.9.16: *06/04/16: + * Fix all warnings with (gcc 3.4.6) -Wall, mainly sign comparisons (Simon) + ClientPattern.cc Container.cc FbWinFrame.cc IconButton.cc IconbarTool.cc + ScreenPlacement.hh ScreenResources.cc ToolFactory.cc Toolbar.cc + Window.cc FbTk/... FbPixmap.hh/cc Menu.hh Text.hh TextBox.hh/cc * signedness fix in Container moveItem (thanks _markt) Container.cc * Vertical toolbar (Simon) diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc index 9b1c4e3..38d1602 100644 --- a/src/ClientPattern.cc +++ b/src/ClientPattern.cc @@ -137,10 +137,11 @@ ClientPattern::ClientPattern(const char *str): // there shouldn't be anything else on the line match = str + pos; - err = match.find_first_not_of(" \t\n", pos); - if ((unsigned) err != match.npos) { + size_t uerr;// need a special type here + uerr = match.find_first_not_of(" \t\n", pos); + if (uerr != match.npos) { // found something, not good - had_error = err; + had_error++; } } diff --git a/src/Container.cc b/src/Container.cc index caab11b..ff026e1 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -32,8 +32,8 @@ Container::Container(const FbTk::FbWindow &parent): FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask), - m_align(RELATIVE), m_orientation(FbTk::ROT0), + m_align(RELATIVE), m_max_size_per_client(60), m_max_total_size(0), m_selected(0), @@ -479,7 +479,7 @@ unsigned int Container::maxWidthPerClient() const { if (size() == 0) return width(); else { - int borderW = m_item_list.front()->borderWidth(); + unsigned int borderW = m_item_list.front()->borderWidth(); // there're count-1 borders to fit in with the windows // -> 1 per window plus end unsigned int w = width(), h = height(); diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 0df087d..675e838 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -73,7 +73,7 @@ FbPixmap::FbPixmap(Pixmap pm):m_pm(0), FbPixmap::FbPixmap(const FbDrawable &src, unsigned int width, unsigned int height, - int depth):m_pm(0), + unsigned int depth):m_pm(0), m_width(0), m_height(0), m_depth(0) { @@ -82,7 +82,7 @@ FbPixmap::FbPixmap(const FbDrawable &src, FbPixmap::FbPixmap(Drawable src, unsigned int width, unsigned int height, - int depth):m_pm(0), + unsigned int depth):m_pm(0), m_width(0), m_height(0), m_depth(0) { @@ -157,7 +157,7 @@ void FbPixmap::copy(const FbPixmap &the_copy) { } // screen doesn't count if depth is "zero"... -void FbPixmap::copy(Pixmap pm, int depth, int screen_num) { +void FbPixmap::copy(Pixmap pm, unsigned int depth, int screen_num) { free(); if (pm == 0) return; @@ -248,6 +248,8 @@ void FbPixmap::rotate(FbTk::Orientation orient) { dirx = 1; diry = -1; break; + default: // kill warning + break; } @@ -365,7 +367,6 @@ void FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) { unsigned long items_read, items_left; unsigned long *data; - unsigned int prop = 0; if (XGetWindowProperty(display(), RootWindow(display(), i), root_prop_atoms[i], @@ -474,7 +475,7 @@ void FbPixmap::free() { void FbPixmap::create(Drawable src, unsigned int width, unsigned int height, - int depth) { + unsigned int depth) { if (src == 0) return; diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index 33a64d2..2935978 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -41,15 +41,15 @@ public: explicit FbPixmap(Pixmap pm); FbPixmap(const FbDrawable &src, unsigned int width, unsigned int height, - int depth); + unsigned int depth); FbPixmap(Drawable src, unsigned int width, unsigned int height, - int depth); + unsigned int depth); virtual ~FbPixmap(); void copy(const FbPixmap &the_copy); - void copy(Pixmap pixmap, int depth_convert, int screen_num); + void copy(Pixmap pixmap, unsigned int depth_convert, int screen_num); /// rotates the pixmap to specified orientation (assumes ROT0 now) void rotate(FbTk::Orientation orient); /// scales the pixmap to specified size @@ -67,7 +67,7 @@ public: inline Drawable drawable() const { return m_pm; } inline unsigned int width() const { return m_width; } inline unsigned int height() const { return m_height; } - inline int depth() const { return m_depth; } + inline unsigned int depth() const { return m_depth; } static Pixmap getRootPixmap(int screen_num, bool force_update=false); static void setRootPixmap(int screen_num, Pixmap pm); @@ -75,13 +75,13 @@ public: void create(Drawable src, unsigned int width, unsigned int height, - int depth); + unsigned int depth); private: void free(); Pixmap m_pm; unsigned int m_width, m_height; - int m_depth; + unsigned int m_depth; /// Functions relating to the maintenance of root window pixmap caching static void checkAtoms(); diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index fceec67..2f098d7 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -207,7 +207,7 @@ private: Menuitems menuitems; int m_screen_x, m_screen_y; - int m_screen_width, m_screen_height; + unsigned int m_screen_width, m_screen_height; bool m_moving; ///< if we're moving/draging or not bool m_visible; ///< menu visibility bool m_torn; ///< torn from parent diff --git a/src/FbTk/Text.hh b/src/FbTk/Text.hh index 01ee26e..745102f 100644 --- a/src/FbTk/Text.hh +++ b/src/FbTk/Text.hh @@ -106,9 +106,6 @@ inline void untranslateCoords(Orientation orient, int &orig_x, int &orig_y, unsi // relocate the x,y coordinates inline void translatePosition(Orientation orient, int &x, int &y, unsigned int w, unsigned int h, unsigned int bw) { - int orig_x = x; - int orig_y = y; - switch(orient) { case ROT0: break; diff --git a/src/FbTk/TextBox.cc b/src/FbTk/TextBox.cc index a912775..7c91621 100644 --- a/src/FbTk/TextBox.cc +++ b/src/FbTk/TextBox.cc @@ -247,21 +247,25 @@ void TextBox::keyPressEvent(XKeyEvent &event) { m_end_pos = 0; break; case XK_Left: { - int pos = findEmptySpaceLeft(); - if (pos < m_start_pos){ - m_start_pos = pos; - m_cursor_pos = 0; - } else if (m_start_pos > 0) { - m_cursor_pos = pos - m_start_pos; - } else { - m_cursor_pos = pos; - } - adjustPos(); + unsigned int pos = findEmptySpaceLeft(); + if (pos < m_start_pos){ + m_start_pos = pos; + m_cursor_pos = 0; + } else if (m_start_pos > 0) { + m_cursor_pos = pos - m_start_pos; + } else { + m_cursor_pos = pos; } + adjustPos(); + } break; case XK_Right: if (m_text.size() && m_cursor_pos < m_text.size()){ - int pos = findEmptySpaceRight() - m_start_pos; + unsigned int pos = findEmptySpaceRight(); + if (pos > m_start_pos) + pos -= m_start_pos; + else + pos = 0; if (m_start_pos + pos <= m_end_pos) m_cursor_pos = pos; else if (m_end_pos < text().size()) { @@ -275,7 +279,7 @@ void TextBox::keyPressEvent(XKeyEvent &event) { break; case XK_BackSpace: { - int pos = findEmptySpaceLeft(); + unsigned int pos = findEmptySpaceLeft(); m_text.erase(pos, m_cursor_pos - pos + m_start_pos); if (pos < m_start_pos){ @@ -292,7 +296,7 @@ void TextBox::keyPressEvent(XKeyEvent &event) { case XK_Delete: { if (!m_text.size() || m_cursor_pos >= m_text.size()) break; - int pos = findEmptySpaceRight(); + unsigned int pos = findEmptySpaceRight(); m_text.erase(m_cursor_pos + m_start_pos, pos - (m_cursor_pos + m_start_pos)); adjustPos(); } @@ -406,7 +410,7 @@ void TextBox::adjustStartPos() { m_start_pos = start_pos; } -int TextBox::findEmptySpaceLeft(){ +unsigned int TextBox::findEmptySpaceLeft(){ // found the first left space symbol int pos = m_text.rfind(' ', (m_start_pos + m_cursor_pos) > 0 ? @@ -425,14 +429,14 @@ int TextBox::findEmptySpaceLeft(){ return pos; } -int TextBox::findEmptySpaceRight(){ +unsigned int TextBox::findEmptySpaceRight(){ // found the first right space symbol int pos = m_text.find(' ', m_start_pos + m_cursor_pos); // do we have one more space symbol near? int next_pos = -1; - while (pos > -1 && pos < m_text.size() && (next_pos = m_text.find(' ', pos + 1)) > -1 ){ + while (pos > -1 && pos < static_cast(m_text.size()) && (next_pos = m_text.find(' ', pos + 1)) > -1 ){ if (next_pos - 1 > pos) break; diff --git a/src/FbTk/TextBox.hh b/src/FbTk/TextBox.hh index d5f2b61..660ac80 100644 --- a/src/FbTk/TextBox.hh +++ b/src/FbTk/TextBox.hh @@ -70,8 +70,8 @@ public: int cursorPosition() const { return m_cursor_pos; } inline int textStartPos(){ return m_start_pos; } - int findEmptySpaceLeft(); - int findEmptySpaceRight(); + unsigned int findEmptySpaceLeft(); + unsigned int findEmptySpaceRight(); private: void adjustEndPos(); diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 4416ff6..ccf1087 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -1694,6 +1694,8 @@ int FbWinFrame::widthOffset() const { case RIGHTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); break; + default: // kill warning + break; } return 0; } @@ -1709,6 +1711,8 @@ int FbWinFrame::heightOffset() const { case BOTTOMRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; + default: // kill warning + break; } return 0; } @@ -1722,6 +1726,8 @@ int FbWinFrame::xOffset() const { case LEFTBOTTOM: return m_tab_container.width() + m_window.borderWidth(); break; + default: // kill warning + break; } return 0; } @@ -1735,6 +1741,8 @@ int FbWinFrame::yOffset() const { case TOPRIGHT: return m_tab_container.height() + m_window.borderWidth(); break; + default: // kill warning + break; } return 0; } diff --git a/src/IconButton.cc b/src/IconButton.cc index ab53196..d36987f 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -109,7 +109,7 @@ private: class WheelWorkspaceCmd : public FbTk::Command { public: explicit WheelWorkspaceCmd(const IconbarTool& tool, FluxboxWindow &win, const char* cmd) : - m_win(win), m_tool(tool), m_cmd(CommandParser::instance().parseLine(cmd)){ } + m_win(win), m_cmd(CommandParser::instance().parseLine(cmd)), m_tool(tool) { } void execute() { switch(m_tool.wheelMode()) { @@ -245,7 +245,7 @@ void IconButton::update(FbTk::Subject *subj) { FbTk::translateSize(orientation(), w, h); int iconx = 1, icony = 1; unsigned int neww = w, newh = h; - if (newh > 2*icony) + if (newh > 2*static_cast(icony)) newh -= 2*icony; else newh = 1; diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 1067e0b..f49a1fe 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -99,8 +99,11 @@ std::string FbTk::Resource::getString() const { case IconbarTool::CURRENT: return std::string("Current"); break; + case IconbarTool::FOLLOW: + default: + return std::string("Follow"); + break; }; - return std::string("Follow"); } template<> @@ -131,8 +134,10 @@ std::string FbTk::Resource::getString() const { case IconbarTool::SCREEN: return std::string("Screen"); break; + case IconbarTool::OFF: + default: + return std::string("Off"); }; - return std::string("Off"); } template<> diff --git a/src/ScreenPlacement.hh b/src/ScreenPlacement.hh index b8941bf..be007eb 100644 --- a/src/ScreenPlacement.hh +++ b/src/ScreenPlacement.hh @@ -58,6 +58,8 @@ public: }; explicit ScreenPlacement(BScreen &screen); + + virtual ~ScreenPlacement() {} /// placeWindow is guaranteed to succeed, ignore return value /// @return true bool placeWindow(const std::vector &windowlist, diff --git a/src/ScreenResources.cc b/src/ScreenResources.cc index 533266a..ea88c79 100644 --- a/src/ScreenResources.cc +++ b/src/ScreenResources.cc @@ -88,9 +88,12 @@ std::string FbTk::Resource::getString() const { case BScreen::FETCH_ACTIVE_WINDOW: return std::string("Current"); break; + case BScreen::IGNORE_OTHER_WORKSPACES: + default: + return std::string("Ignore"); + break; } - return std::string("Ignore"); } template<> diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index 2659b67..242b3a0 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -77,9 +77,9 @@ ToolFactory::ToolFactory(BScreen &screen):m_screen(screen), m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"), m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button", "toolbar.clock", "Toolbar.Clock")), + m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")), m_systray_theme(new ButtonTheme(screen.screenNumber(), "toolbar.systray", "Toolbar.Systray", "toolbar.clock", "Toolbar.Systray")), - m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")), m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") { } diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 035fdd6..319f56a 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -977,7 +977,6 @@ void Toolbar::rearrangeItems() { unsigned int width = this->width(), height = this->height(); unsigned int tmpw, tmph; - int tmpx, tmpy; FbTk::translateSize(orient, width, height); for (; item_it != item_it_end; ++item_it) { diff --git a/src/Window.cc b/src/Window.cc index 0504deb..a165d90 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -924,7 +924,7 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x ClientList::iterator client = find(m_clientlist.begin(), m_clientlist.end(), it->first); - if (x > (*it).second->width() / 2) + if (x > static_cast((*it).second->width()) / 2) client++; return client; @@ -960,7 +960,7 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { dest_x, dest_y, &x, &y, &child_return)) return; - if (x > (*it).second->width() / 2) + if (x > static_cast((*it).second->width()) / 2) moveClientRightOf(win, *it->first); else moveClientLeftOf(win, *it->first); @@ -2296,7 +2296,7 @@ void FluxboxWindow::popupMenu() { int menu_y = frame().titlebar().height() + frame().titlebar().borderWidth(); if (!decorations.titlebar) // if we don't have any titlebar menu_y = 0; - if (m_last_button_x < x() || m_last_button_x > x() + width()) + if (m_last_button_x < x() || m_last_button_x > x() + static_cast(width())) m_last_button_x = x(); showMenu(m_last_button_x, menu_y + frame().y()); } @@ -2858,8 +2858,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { int old_resize_x = m_last_resize_x; int old_resize_y = m_last_resize_y; - int old_resize_w = m_last_resize_w; - int old_resize_h = m_last_resize_h; + unsigned int old_resize_w = m_last_resize_w; + unsigned int old_resize_h = m_last_resize_h; // move rectangle int gx = 0, gy = 0; @@ -2892,6 +2892,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { m_last_resize_y = frame().y() - diff/2; } break; + default: // kill warning + break; }; // if not on top or all corner then move bottom @@ -3567,7 +3569,7 @@ void FluxboxWindow::attachTo(int x, int y, bool interrupted) { if (client) { inside_titlebar = client->fbwindow()->hasTitlebar() && - client->fbwindow()->y() + client->fbwindow()->titlebarHeight() > dest_y; + client->fbwindow()->y() + static_cast(client->fbwindow()->titlebarHeight()) > dest_y; Fluxbox::TabsAttachArea area= Fluxbox::instance()->getTabsAttachArea(); if (area == Fluxbox::ATTACH_AREA_WINDOW) -- cgit v0.11.2