]> Dogcows Code - chaz/openbox/commitdiff
signed ints instead of unsigned ints again. less pain. pain bad.
authorDana Jansens <danakj@orodu.net>
Sun, 9 Feb 2003 22:40:47 +0000 (22:40 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 9 Feb 2003 22:40:47 +0000 (22:40 +0000)
15 files changed:
otk/label.cc
otk/rect.hh
otk/renderstyle.cc
otk/screeninfo.cc
otk/screeninfo.hh
otk/size.hh
otk/surface.cc
otk/truerendercontrol.cc
otk/widget.cc
otk/widget.hh
scripts/motion.py
src/client.cc
src/client.hh
src/frame.cc
src/frame.hh

index 16fa25a0b674f249c460091676a258b585b45437..c17e295e49f4119c08551894f479a088fb3424a0 100644 (file)
@@ -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
 
index fe98dcb59d9e45725efc2ea8c0068c7cd2c775da..f5e755ccb9ce9f6600cf029856a2a9a2a7161d4c 100644 (file)
@@ -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(); }
index 13d9e577b28811a8b680dea56eb245c405a0309a..ae2a3a18f8bf5323fd6cf7349060ca79a245f77e 100644 (file)
@@ -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);
index 560a56362a6edd164284c9d2b7de723da29947e9..535156e99eadb74037d363ce6436779901001f19 100644 (file)
@@ -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);
index 440573aa80058325df8c5afe18a64742769f6ff0..584d92ece76313893a0bc9e2011fa64971c52429 100644 (file)
@@ -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
index 915396142bd19a5c42e2694dbf8820c3f3bfd269..57447d5dc45b8200e1c586b6f8233c373d5cab34 100644 (file)
@@ -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; }
index aabbf85af8bc4d9042734367f6e8d666cbc6fc06..60e6824cd50e037fe63d8180710adb68badb0970 100644 (file)
@@ -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();
index 2c7c42a4188381b21d60cf91ca9b9fb7fef8a977..fffaa05a24fe9240b7bbf470f77b93b51a6e807d 100644 (file)
@@ -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;
index 8ab57708f276981e9907f101ca9fa43087b7f1df..25d5043d2ee81adb5cfd833c7015d42b5edaebdf 100644 (file)
@@ -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();
     }
index 5c366503ffc866e0071b971581d552f51ebe8b29..31103debdb6e5a49e7cf55694f863058d6d0cfa3 100644 (file)
@@ -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;
index 2ed07863fb9bc28580db26dc9beab7f9ef12545c..2d6939c519c6f4416d98abe370d79550ca1a960c 100644 (file)
@@ -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 ...
index e78336d3966b50bd152668685a5c67c018af8dbc..e2c2dcb4f1dc7e9be172739ea24454615521e0c4 100644 (file)
@@ -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;
index 6e11ed8c27ead0e191ca9b0c8573e8dd797b17fa..634d0e3de39720e55b5d64fd1f9eae96fe554eb9 100644 (file)
@@ -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
   /*!
index 5ffdc726ada7ea2bb9be421e99203d02fc664e97..17ebdb65f1dd54ff5056beb59f21a488e6ac770e 100644 (file)
@@ -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
index c587c112ad2e863e4758a60f0cf9e72ee9be3a23..c5d68de98a08362fe039410352650300e084b973 100644 (file)
@@ -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;
This page took 0.05442 seconds and 4 git commands to generate.