diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client.cc | 26 | ||||
| -rw-r--r-- | src/client.hh | 4 | ||||
| -rw-r--r-- | src/frame.cc | 19 | ||||
| -rw-r--r-- | src/frame.hh | 30 |
4 files changed, 37 insertions, 42 deletions
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; |
