fix all compiler warnings with -Wall

This commit is contained in:
simonb 2006-04-16 11:18:22 +00:00
parent 02aa83a59e
commit 553104ee1d
17 changed files with 77 additions and 51 deletions

View file

@ -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)

View file

@ -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++;
}
}

View file

@ -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();

View file

@ -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;

View file

@ -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();

View file

@ -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

View file

@ -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;

View file

@ -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<signed>(m_text.size()) && (next_pos = m_text.find(' ', pos + 1)) > -1 ){
if (next_pos - 1 > pos)
break;

View file

@ -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();

View file

@ -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;
}

View file

@ -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<unsigned>(icony))
newh -= 2*icony;
else
newh = 1;

View file

@ -99,8 +99,11 @@ std::string FbTk::Resource<IconbarTool::DeiconifyMode>::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<IconbarTool::WheelMode>::getString() const {
case IconbarTool::SCREEN:
return std::string("Screen");
break;
case IconbarTool::OFF:
default:
return std::string("Off");
};
return std::string("Off");
}
template<>

View file

@ -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<FluxboxWindow *> &windowlist,

View file

@ -88,9 +88,12 @@ std::string FbTk::Resource<BScreen::FollowModel>::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<>

View file

@ -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") {
}

View file

@ -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) {

View file

@ -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<signed>((*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<signed>((*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<signed>(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<signed>(client->fbwindow()->titlebarHeight()) > dest_y;
Fluxbox::TabsAttachArea area= Fluxbox::instance()->getTabsAttachArea();
if (area == Fluxbox::ATTACH_AREA_WINDOW)