summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--otk/label.cc14
-rw-r--r--otk/rect.hh6
-rw-r--r--otk/renderstyle.cc4
-rw-r--r--otk/screeninfo.cc4
-rw-r--r--otk/screeninfo.hh6
-rw-r--r--otk/size.hh12
-rw-r--r--otk/surface.cc4
-rw-r--r--otk/truerendercontrol.cc56
-rw-r--r--otk/widget.cc50
-rw-r--r--otk/widget.hh2
-rw-r--r--scripts/motion.py2
-rw-r--r--src/client.cc26
-rw-r--r--src/client.hh4
-rw-r--r--src/frame.cc19
-rw-r--r--src/frame.hh30
15 files changed, 114 insertions, 125 deletions
diff --git a/otk/label.cc b/otk/label.cc
index 16fa25a0..c17e295e 100644
--- a/otk/label.cc
+++ b/otk/label.cc
@@ -71,11 +71,12 @@ void Label::setFont(const Font *f)
void Label::calcDefaultSizes()
{
- unsigned int longest = 0;
+ int longest = 0;
// find the longest line
std::vector<ustring>::iterator it, end = _parsedtext.end();
for (it = _parsedtext.begin(); it != end; ++it) {
- unsigned int length = _font->measureString(*it);
+ int length = _font->measureString(*it);
+ if (length < 0) continue; // lines too long get skipped
if (length > longest) longest = length;
}
setMinSize(Size(longest + borderWidth() * 2 + bevel() * 4,
@@ -101,10 +102,10 @@ void Label::styleChanged(const RenderStyle &style)
void Label::renderForeground(Surface &surface)
{
const RenderControl *control = display->renderControl(screen());
- unsigned int sidemargin = bevel() * 2;
+ int sidemargin = bevel() * 2;
int y = bevel();
- unsigned int w = area().width() - borderWidth() * 2 - sidemargin * 2;
- unsigned int h = area().height() - borderWidth() * 2 - bevel() * 2;
+ int w = area().width() - borderWidth() * 2 - sidemargin * 2;
+ int h = area().height() - borderWidth() * 2 - bevel() * 2;
switch (_justify_vert) {
case RenderStyle::RightBottomJustify:
@@ -128,12 +129,13 @@ void Label::renderForeground(Surface &surface)
// find a string that will fit inside the area for text
ustring::size_type text_len = t.size();
- unsigned int length;
+ int length;
do {
t.resize(text_len);
length = _font->measureString(t);
} while (length > w && text_len-- > 0);
+ if (length < 0) continue; // lines too long get skipped
if (text_len <= 0) continue; // won't fit anything
diff --git a/otk/rect.hh b/otk/rect.hh
index fe98dcb5..f5e755cc 100644
--- a/otk/rect.hh
+++ b/otk/rect.hh
@@ -14,13 +14,13 @@ public:
Rect() : _p(), _s() {}
Rect(const Point &p, const Size &s) : _p(p), _s(s) {}
Rect(const Rect &r) : _p(r._p), _s(r._s) {}
- Rect(int x, int y, unsigned int w, unsigned int h)
+ Rect(int x, int y, int w, int h)
: _p(x, y), _s(w, h) {}
inline int x() const { return _p.x(); }
inline int y() const { return _p.y(); }
- inline unsigned int width() const { return _s.width(); }
- inline unsigned int height() const { return _s.height(); }
+ inline int width() const { return _s.width(); }
+ inline int height() const { return _s.height(); }
inline int left() const { return _p.x(); }
inline int top() const { return _p.y(); }
diff --git a/otk/renderstyle.cc b/otk/renderstyle.cc
index 13d9e577..ae2a3a18 100644
--- a/otk/renderstyle.cc
+++ b/otk/renderstyle.cc
@@ -56,8 +56,8 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
_file(stylefile)
{
// pick one..
-#define FIERON
-//#define MERRY
+//#define FIERON
+#define MERRY
#ifdef FIERON
_root_color = new RenderColor(_screen, 0x272a2f);
diff --git a/otk/screeninfo.cc b/otk/screeninfo.cc
index 560a5636..535156e9 100644
--- a/otk/screeninfo.cc
+++ b/otk/screeninfo.cc
@@ -17,7 +17,9 @@ using std::string;
namespace otk {
-ScreenInfo::ScreenInfo(unsigned int num) {
+ScreenInfo::ScreenInfo(int num) {
+ assert(num >= 0 && num < ScreenCount(**display));
+
_screen = num;
_root_window = RootWindow(**display, _screen);
diff --git a/otk/screeninfo.hh b/otk/screeninfo.hh
index 440573aa..584d92ec 100644
--- a/otk/screeninfo.hh
+++ b/otk/screeninfo.hh
@@ -21,7 +21,7 @@ private:
Colormap _colormap;
int _depth;
- unsigned int _screen;
+ int _screen;
std::string _display_string;
Size _size;
#ifdef XINERAMA
@@ -30,13 +30,13 @@ private:
#endif
public:
- ScreenInfo(unsigned int num);
+ ScreenInfo(int num);
inline Visual *visual() const { return _visual; }
inline Window rootWindow() const { return _root_window; }
inline Colormap colormap() const { return _colormap; }
inline int depth() const { return _depth; }
- inline unsigned int screen() const { return _screen; }
+ inline int screen() const { return _screen; }
inline const Size& size() const { return _size; }
inline const std::string& displayString() const { return _display_string; }
#ifdef XINERAMA
diff --git a/otk/size.hh b/otk/size.hh
index 91539614..57447d5d 100644
--- a/otk/size.hh
+++ b/otk/size.hh
@@ -2,17 +2,19 @@
#ifndef __size_hh
#define __size_hh
+#include <cassert>
+
namespace otk {
class Size {
- unsigned int _w, _h;
+ int _w, _h;
public:
Size() : _w(1), _h(1) {}
- Size(unsigned int w, unsigned int h) : _w(w), _h(h) {}
- Size(const Size &s) : _w(s._w), _h(s._h) {}
+ Size(int w, int h) : _w(w), _h(h) { assert(_w >= 0 && _h >= 0); }
+ Size(const Size &s) : _w(s._w), _h(s._h) { assert(_w >= 0 && _h >= 0); }
- inline unsigned int width() const { return _w; }
- inline unsigned int height() const { return _h; }
+ inline int width() const { return _w; }
+ inline int height() const { return _h; }
bool operator==(const Size &o) const { return _w == o._w && _h == o._h; }
bool operator!=(const Size &o) const { return _w != o._w || _h != o._h; }
diff --git a/otk/surface.cc b/otk/surface.cc
index aabbf85a..60e6824c 100644
--- a/otk/surface.cc
+++ b/otk/surface.cc
@@ -39,8 +39,8 @@ void Surface::setPixmap(const RenderColor &color)
void Surface::setPixmap(XImage *image)
{
- assert((unsigned)image->width == _size.width());
- assert((unsigned)image->height == _size.height());
+ assert(image->width == _size.width());
+ assert(image->height == _size.height());
if (_pixmap == None)
createObjects();
diff --git a/otk/truerendercontrol.cc b/otk/truerendercontrol.cc
index 2c7c42a4..fffaa05a 100644
--- a/otk/truerendercontrol.cc
+++ b/otk/truerendercontrol.cc
@@ -59,8 +59,8 @@ void TrueRenderControl::drawGradientBackground(
Surface &sf, const RenderTexture &texture) const
{
unsigned int r,g,b;
- unsigned int w = sf.size().width(), h = sf.size().height();
- unsigned int off, x;
+ int w = sf.size().width(), h = sf.size().height();
+ int off, x;
const ScreenInfo *info = display->screenInfo(_screen);
XImage *im = XCreateImage(**display, info->visual(), info->depth(),
@@ -102,29 +102,25 @@ void TrueRenderControl::drawGradientBackground(
if (texture.relief() != RenderTexture::Flat) {
if (texture.bevel() == RenderTexture::Bevel1) {
- if (w >= 1 && h >= 1) {
- for (off = 1, x = 1; x < w - 1; ++x, off++)
- highlight(data + off,
- data + off + (h-1) * w,
- texture.relief()==RenderTexture::Raised);
- for (off = 0, x = 0; x < h; ++x, off++)
- highlight(data + off * w,
- data + off * w + w - 1,
- texture.relief()==RenderTexture::Raised);
- }
+ for (off = 1, x = 1; x < w - 1; ++x, off++)
+ highlight(data + off,
+ data + off + (h-1) * w,
+ texture.relief()==RenderTexture::Raised);
+ for (off = 0, x = 0; x < h; ++x, off++)
+ highlight(data + off * w,
+ data + off * w + w - 1,
+ texture.relief()==RenderTexture::Raised);
}
if (texture.bevel() == RenderTexture::Bevel2) {
- if (w >= 2 && h >= 2) {
- for (off = 2, x = 2; x < w - 2; ++x, off++)
- highlight(data + off + w,
- data + off + (h-2) * w,
- texture.relief()==RenderTexture::Raised);
- for (off = 1, x = 1; x < h-1; ++x, off++)
- highlight(data + off * w + 1,
- data + off * w + w - 2,
- texture.relief()==RenderTexture::Raised);
- }
+ for (off = 2, x = 2; x < w - 2; ++x, off++)
+ highlight(data + off + w,
+ data + off + (h-2) * w,
+ texture.relief()==RenderTexture::Raised);
+ for (off = 1, x = 1; x < h-1; ++x, off++)
+ highlight(data + off * w + 1,
+ data + off * w + w - 2,
+ texture.relief()==RenderTexture::Raised);
}
}
@@ -146,7 +142,7 @@ void TrueRenderControl::verticalGradient(Surface &sf,
pixel32 current;
float dr, dg, db;
unsigned int r,g,b;
- unsigned int w = sf.size().width(), h = sf.size().height();
+ int w = sf.size().width(), h = sf.size().height();
dr = (float)(texture.secondary_color().red() - texture.color().red());
dr/= (float)h;
@@ -157,14 +153,14 @@ void TrueRenderControl::verticalGradient(Surface &sf,
db = (float)(texture.secondary_color().blue() - texture.color().blue());
db/= (float)h;
- for (unsigned int y = 0; y < h; ++y) {
+ for (int y = 0; y < h; ++y) {
r = texture.color().red() + (int)(dr * y);
g = texture.color().green() + (int)(dg * y);
b = texture.color().blue() + (int)(db * y);
current = (r << default_red_shift)
+ (g << default_green_shift)
+ (b << default_blue_shift);
- for (unsigned int x = 0; x < w; ++x, ++data)
+ for (int x = 0; x < w; ++x, ++data)
*data = current;
}
}
@@ -176,9 +172,9 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
pixel32 current;
float drx, dgx, dbx, dry, dgy, dby;
unsigned int r,g,b;
- unsigned int w = sf.size().width(), h = sf.size().height();
+ int w = sf.size().width(), h = sf.size().height();
- for (unsigned int y = 0; y < h; ++y) {
+ for (int y = 0; y < h; ++y) {
drx = (float)(texture.secondary_color().red() - texture.color().red());
dry = drx/(float)h;
drx/= (float)w;
@@ -190,7 +186,7 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
dbx = (float)(texture.secondary_color().blue() - texture.color().blue());
dby = dbx/(float)h;
dbx/= (float)w;
- for (unsigned int x = 0; x < w; ++x, ++data) {
+ for (int x = 0; x < w; ++x, ++data) {
r = texture.color().red() + ((int)(drx * x) + (int)(dry * y))/2;
g = texture.color().green() + ((int)(dgx * x) + (int)(dgy * y))/2;
b = texture.color().blue() + ((int)(dbx * x) + (int)(dby * y))/2;
@@ -209,9 +205,9 @@ void TrueRenderControl::crossDiagonalGradient(Surface &sf,
pixel32 current;
float drx, dgx, dbx, dry, dgy, dby;
unsigned int r,g,b;
- unsigned int w = sf.size().width(), h = sf.size().height();
+ int w = sf.size().width(), h = sf.size().height();
- for (unsigned int y = 0; y < h; ++y) {
+ for (int y = 0; y < h; ++y) {
drx = (float)(texture.secondary_color().red() - texture.color().red());
dry = drx/(float)h;
drx/= (float)w;
diff --git a/otk/widget.cc b/otk/widget.cc
index 8ab57708..25d5043d 100644
--- a/otk/widget.cc
+++ b/otk/widget.cc
@@ -26,7 +26,7 @@ Widget::Widget(int screen, EventDispatcher *ed, Direction direction, int bevel,
ExposureMask | StructureNotifyMask),
_alignment(RenderStyle::CenterJustify),
_direction(direction),
- _max_size(UINT_MAX, UINT_MAX),
+ _max_size(INT_MAX, INT_MAX),
_visible(false),
_bordercolor(0),
_borderwidth(0),
@@ -49,7 +49,7 @@ Widget::Widget(Widget *parent, Direction direction, int bevel)
ExposureMask | StructureNotifyMask),
_alignment(RenderStyle::CenterJustify),
_direction(direction),
- _max_size(UINT_MAX, UINT_MAX),
+ _max_size(INT_MAX, INT_MAX),
_visible(false),
_bordercolor(0),
_borderwidth(0),
@@ -120,7 +120,7 @@ void Widget::update()
void Widget::moveresize(const Rect &r)
{
- unsigned int w, h;
+ int w, h;
w = std::min(std::max(r.width(), minSize().width()), maxSize().width());
h = std::min(std::max(r.height(), minSize().height()), maxSize().height());
@@ -134,7 +134,7 @@ void Widget::moveresize(const Rect &r)
update();
}
-void Widget::internal_moveresize(int x, int y, unsigned w, unsigned int h)
+void Widget::internal_moveresize(int x, int y, int w, int h)
{
assert(w > 0);
assert(h > 0);
@@ -248,18 +248,15 @@ void Widget::layoutHorz()
if (visible.empty()) return;
- if ((unsigned)(_borderwidth * 2 + _bevel * 2) > _area.width() ||
- (unsigned)(_borderwidth * 2 + _bevel * 2) > _area.height())
- return; // not worth laying anything out!
-
- int x, y; unsigned int w, h; // working area
+ int x, y, w, h; // working area
x = y = _bevel;
w = _area.width() - _borderwidth * 2 - _bevel * 2;
h = _area.height() - _borderwidth * 2 - _bevel * 2;
+ if (w < 0 || h < 0) return; // not worth laying anything out!
int free = w - (visible.size() - 1) * _bevel;
if (free < 0) free = 0;
- unsigned int each;
+ int each;
std::list<Widget*> adjustable = visible;
@@ -279,7 +276,7 @@ void Widget::layoutHorz()
each = free / adjustable.size();
for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
std::list<Widget*>::iterator next = it; ++next;
- unsigned int m = (*it)->maxSize().width() - (*it)->minSize().width();
+ int m = (*it)->maxSize().width() - (*it)->minSize().width();
if (m > 0 && m < each) {
free -= m;
if (free < 0) free = 0;
@@ -298,7 +295,7 @@ void Widget::layoutHorz()
else
each = 0;
for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- unsigned int w;
+ int w;
// is the widget adjustable?
std::list<Widget*>::const_iterator
found = std::find(adjustable.begin(), adjustable.end(), *it);
@@ -311,8 +308,8 @@ void Widget::layoutHorz()
}
// align it vertically
int yy = y;
- unsigned int hh = std::max(std::min(h, (*it)->_max_size.height()),
- (*it)->_min_size.height());
+ int hh = std::max(std::min(h, (*it)->_max_size.height()),
+ (*it)->_min_size.height());
if (hh < h) {
switch(_alignment) {
case RenderStyle::RightBottomJustify:
@@ -347,18 +344,15 @@ void Widget::layoutVert()
if (visible.empty()) return;
- if ((unsigned)(_borderwidth * 2 + _bevel * 2) > _area.width() ||
- (unsigned)(_borderwidth * 2 + _bevel * 2) > _area.height())
- return; // not worth laying anything out!
-
- int x, y; unsigned int w, h; // working area
+ int x, y, w, h; // working area
x = y = _bevel;
w = _area.width() - _borderwidth * 2 - _bevel * 2;
h = _area.height() - _borderwidth * 2 - _bevel * 2;
+ if (w < 0 || h < 0) return; // not worth laying anything out!
int free = h - (visible.size() - 1) * _bevel;
if (free < 0) free = 0;
- unsigned int each;
+ int each;
std::list<Widget*> adjustable = visible;
@@ -378,7 +372,7 @@ void Widget::layoutVert()
each = free / adjustable.size();
for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
std::list<Widget*>::iterator next = it; ++next;
- unsigned int m = (*it)->maxSize().height() - (*it)->minSize().height();
+ int m = (*it)->maxSize().height() - (*it)->minSize().height();
if (m > 0 && m < each) {
free -= m;
if (free < 0) free = 0;
@@ -397,7 +391,7 @@ void Widget::layoutVert()
else
each = 0;
for (it = visible.begin(), end = visible.end(); it != end; ++it) {
- unsigned int h;
+ int h;
// is the widget adjustable?
std::list<Widget*>::const_iterator
found = std::find(adjustable.begin(), adjustable.end(), *it);
@@ -410,8 +404,8 @@ void Widget::layoutVert()
}
// align it horizontally
int xx = x;
- unsigned int ww = std::max(std::min(w, (*it)->_max_size.width()),
- (*it)->_min_size.width());
+ int ww = std::max(std::min(w, (*it)->_max_size.width()),
+ (*it)->_min_size.width());
if (ww < w) {
switch(_alignment) {
case RenderStyle::RightBottomJustify:
@@ -434,8 +428,8 @@ void Widget::layoutVert()
void Widget::render()
{
if (!_texture || !_dirty) return;
- if ((unsigned)_borderwidth * 2 > _area.width() ||
- (unsigned)_borderwidth * 2 > _area.height())
+ if (_borderwidth * 2 > _area.width() ||
+ _borderwidth * 2 > _area.height())
return; // no surface to draw on
Surface *s = new Surface(_screen, Size(_area.width() - _borderwidth * 2,
@@ -481,8 +475,8 @@ void Widget::configureHandler(const XConfigureEvent &e)
ev.xconfigure.height = e.height;
while (XCheckTypedWindowEvent(**display, window(), ConfigureNotify, &ev));
- if (!((unsigned)ev.xconfigure.width == area().width() &&
- (unsigned)ev.xconfigure.height == area().height())) {
+ if (!(ev.xconfigure.width == area().width() &&
+ ev.xconfigure.height == area().height())) {
_area = Rect(_area.position(), Size(e.width, e.height));
update();
}
diff --git a/otk/widget.hh b/otk/widget.hh
index 5c366503..31103deb 100644
--- a/otk/widget.hh
+++ b/otk/widget.hh
@@ -102,7 +102,7 @@ protected:
RenderTexture *_texture;
private:
- void internal_moveresize(int x, int y, unsigned w, unsigned int h);
+ void internal_moveresize(int x, int y, int w, int h);
int _screen;
Widget *_parent;
diff --git a/scripts/motion.py b/scripts/motion.py
index 2ed07863..2d6939c5 100644
--- a/scripts/motion.py
+++ b/scripts/motion.py
@@ -214,8 +214,6 @@ def _do_resize():
w = _cw + dx
h = _ch + dy
- if w < 0: w = 0
- if h < 0: h = 0
if RESIZE_RUBBERBAND:
# draw the outline ...
diff --git a/src/client.cc b/src/client.cc
index e78336d3..e2c2dcb4 100644
--- a/src/client.cc
+++ b/src/client.cc
@@ -480,7 +480,7 @@ void Client::updateNormalHints()
_size_inc = otk::Size(1, 1);
_base_size = otk::Size(0, 0);
_min_size = otk::Size(0, 0);
- _max_size = otk::Size(UINT_MAX, UINT_MAX);
+ _max_size = otk::Size(INT_MAX, INT_MAX);
// get the hints from the window
if (XGetWMNormalHints(**otk::display, _window, &size, &ret)) {
@@ -833,6 +833,7 @@ void Client::setModal(bool modal)
while (c->_transient_for) // go up the tree
c = c->_transient_for;
replacement = c->findModalChild(this); // find a modal child, skipping this
+ assert(replacement != this);
c = this;
while (c->_transient_for) {
@@ -1120,33 +1121,26 @@ void Client::shapeHandler(const XShapeEvent &e)
#endif
-void Client::resize(Corner anchor, unsigned int w, unsigned int h)
+void Client::resize(Corner anchor, int w, int h)
{
if (!(_functions & Func_Resize)) return;
internal_resize(anchor, w, h);
}
-void Client::internal_resize(Corner anchor, unsigned int w, unsigned int h,
+void Client::internal_resize(Corner anchor, int w, int h,
bool user, int x, int y)
{
- if (_base_size.width() < w)
- w -= _base_size.width();
- else
- w = 0;
- if (_base_size.height() < h)
- h -= _base_size.height();
- else
- h = 0;
+ w -= _base_size.width();
+ h -= _base_size.height();
if (user) {
// for interactive resizing. have to move half an increment in each
// direction.
- unsigned int mw = w % _size_inc.width(); // how far we are towards the next
- // size inc
- unsigned int mh = h % _size_inc.height();
- unsigned int aw = _size_inc.width() / 2; // amount to add
- unsigned int ah = _size_inc.height() / 2;
+ int mw = w % _size_inc.width(); // how far we are towards the next size inc
+ int mh = h % _size_inc.height();
+ int aw = _size_inc.width() / 2; // amount to add
+ int ah = _size_inc.height() / 2;
// don't let us move into a new size increment
if (mw + aw >= _size_inc.width()) aw = _size_inc.width() - mw - 1;
if (mh + ah >= _size_inc.height()) ah = _size_inc.height() - mh - 1;
diff --git a/src/client.hh b/src/client.hh
index 6e11ed8c..634d0e3d 100644
--- a/src/client.hh
+++ b/src/client.hh
@@ -479,7 +479,7 @@ private:
The x and y coordinates must both be sepcified together, or they will have
no effect. When they are specified, the anchor is ignored.
*/
- void internal_resize(Corner anchor, unsigned int w, unsigned int h,
+ void internal_resize(Corner anchor, int w, int h,
bool user = true, int x = INT_MIN, int y = INT_MIN);
//! Attempts to find and return a modal child of this window, recursively.
@@ -651,7 +651,7 @@ BB @param window The window id that the Client class should handle
@param w The width component of the new size for the client.
@param h The height component of the new size for the client.
*/
- void resize(Corner anchor, unsigned int w, unsigned int h);
+ void resize(Corner anchor, int w, int h);
//! Reapplies the maximized state to the window
/*!
diff --git a/src/frame.cc b/src/frame.cc
index 5ffdc726..17ebdb65 100644
--- a/src/frame.cc
+++ b/src/frame.cc
@@ -88,8 +88,8 @@ Frame::Frame(Client *client)
_numbuttons = 0;
_buttons = new Window[0];
_buttons_sur = new otk::Surface*[0];
- _titleorder = new unsigned int[1];
- _titleorder[0] = (unsigned)-1;
+ _titleorder = new int[1];
+ _titleorder[0] = -1;
// register all of the windows with the event dispatcher
Window *w = allWindows();
@@ -106,7 +106,7 @@ Frame::~Frame()
openbox->clearHandler(w[i]);
delete [] w;
- for (unsigned int i = 0; i < _numbuttons; ++i) {
+ for (int i = 0; i < _numbuttons; ++i) {
XDestroyWindow(**otk::display, _buttons[i]);
delete _buttons_sur[i];
}
@@ -167,7 +167,7 @@ Window *Frame::allWindows() const
w[i++] = _handle;
w[i++] = _lgrip;
w[i++] = _rgrip;
- for (unsigned int j = 0; j < _numbuttons; ++j)
+ for (int j = 0; j < _numbuttons; ++j)
w[j + i++] = _buttons[j];
w[i] = 0;
return w;
@@ -194,7 +194,7 @@ void Frame::applyStyle(const otk::RenderStyle &style)
XResizeWindow(**otk::display, _lgrip, geom.grip_width(), geom.handle_height);
XResizeWindow(**otk::display, _rgrip, geom.grip_width(), geom.handle_height);
- for (unsigned int i = 0; i < _numbuttons; ++i)
+ for (int i = 0; i < _numbuttons; ++i)
XResizeWindow(**otk::display, _buttons[i],
geom.button_size, geom.button_size);
}
@@ -350,16 +350,17 @@ void Frame::renderLabel()
otk::ustring t = _client->title(); // the actual text to draw
int x = geom.bevel; // x coord for the text
- if ((unsigned)x * 2 > geom.label_width) return; // no room at all
+ if (x * 2 > geom.label_width) return; // no room at all
// find a string that will fit inside the area for text
otk::ustring::size_type text_len = t.size();
- unsigned int length;
- unsigned int maxsize = geom.label_width - geom.bevel * 2;
+ int length;
+ int maxsize = geom.label_width - geom.bevel * 2;
do {
t.resize(text_len);
- length = font->measureString(t);
+ length = font->measureString(t); // this returns an unsigned, so check < 0
+ if (length < 0) length = maxsize; // if the string's that long just adjust
} while (length > maxsize && text_len-- > 0);
if (text_len <= 0) return; // won't fit anything
diff --git a/src/frame.hh b/src/frame.hh
index c587c112..c5d68de9 100644
--- a/src/frame.hh
+++ b/src/frame.hh
@@ -25,18 +25,18 @@ class Client;
//! Varius geometry settings in the frame decorations
struct FrameGeometry {
- unsigned int width; // title and handle
- unsigned int font_height;
- unsigned int title_height() { return font_height + bevel*2; }
- unsigned int label_width;
- unsigned int label_height() { return font_height; }
- unsigned int handle_height; // static, from the style
+ int width; // title and handle
+ int font_height;
+ int title_height() { return font_height + bevel*2; }
+ int label_width;
+ int label_height() { return font_height; }
+ int handle_height; // static, from the style
int handle_y;
- unsigned int button_size; // static, from the style
- unsigned grip_width() { return button_size * 2; }
- unsigned bevel; // static, from the style
- unsigned bwidth; // frame elements' border width
- unsigned cbwidth; // client border width
+ int button_size; // static, from the style
+ int grip_width() { return button_size * 2; }
+ int bevel; // static, from the style
+ int bwidth; // frame elements' border width
+ int cbwidth; // client border width
};
//! Holds and decorates a frame around an Client (client window)
@@ -74,10 +74,10 @@ private:
Window _lgrip; // lefthand resize grab on the handle
Window _rgrip; // righthand resize grab on the handle
Window *_buttons; // all of the titlebar buttons
- unsigned int _numbuttons; // number of buttons, size of _buttons array
- unsigned int *_titleorder; // order of the buttons and the label (always
- // holds '_numbuttons + 1' elements (for the
- // label, which is coded as '-1')
+ int _numbuttons; // number of buttons, size of _buttons array
+ int *_titleorder; // order of the buttons and the label (always
+ // holds '_numbuttons + 1' elements (for the
+ // label, which is coded as '-1')
// surfaces for each
otk::Surface *_frame_sur;