- XSetWindowBorderWidth(otk::OBDisplay::display, _plate.getWindow(), cbwidth);
-
- XSetWindowBorderWidth(otk::OBDisplay::display, getWindow(), bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _titlebar.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_left.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _grip_right.getWindow(),
- bwidth);
- XSetWindowBorderWidth(otk::OBDisplay::display, _handle.getWindow(), bwidth);
-
- if (_decorations & OBClient::Decor_Titlebar) {
- // set the titlebar size
- _titlebar.setGeometry(-bwidth,
- -bwidth,
- width,
- (_style->getFont().height() +
- _style->getBevelWidth() * 2));
- _size.top += _titlebar.height() + bwidth;
-
- // set the label size
- _label.setGeometry(0, _style->getBevelWidth(),
- width, _style->getFont().height());
- // set the buttons sizes
- if (_decorations & OBClient::Decor_Iconify)
- _button_iconify.setGeometry(0, _style->getBevelWidth() + 1,
- _label.height() - 2,
- _label.height() - 2);
- if (_decorations & OBClient::Decor_Maximize)
- _button_max.setGeometry(0, _style->getBevelWidth() + 1,
- _label.height() - 2,
- _label.height() - 2);
- if (_decorations & OBClient::Decor_Sticky)
- _button_stick.setGeometry(0, _style->getBevelWidth() + 1,
- _label.height() - 2,
- _label.height() - 2);
- if (_decorations & OBClient::Decor_Close)
- _button_close.setGeometry(0, _style->getBevelWidth() + 1,
- _label.height() - 2,
- _label.height() - 2);
-
- // separation between titlebar elements
- const int sep = _style->getBevelWidth() + 1;
-
- std::string layout = "SLIMC"; // XXX: get this from somewhere
- // XXX: it is REQUIRED that by this point, the string only has one of each
- // possible letter, all of the letters are valid, and L exists somewhere in
- // the string!
-
- // the size of the label. this ASSUMES the layout has only buttons other
- // that the ONE LABEL!!
- // adds an extra sep so that there's a space on either side of the
- // titlebar.. note: x = sep, below.
- _label.setWidth(_label.width() -
- ((_button_iconify.width() + sep) *
- (layout.size() - 1) + sep * 2));
-
- int x = sep;
- for (int i = 0, len = layout.size(); i < len; ++i) {
- switch (layout[i]) {
- case 'I':
- _button_iconify.move(x, _button_iconify.getRect().y());
- x += _button_iconify.width();
- break;
- case 'L':
- _label.move(x, _label.getRect().y());
- x += _label.width();
- break;
- case 'M':
- _button_max.move(x, _button_max.getRect().y());
- x += _button_max.width();
- break;
- case 'S':
- _button_stick.move(x, _button_stick.getRect().y());
- x += _button_stick.width();
- break;
- case 'C':
- _button_close.move(x, _button_close.getRect().y());
- x += _button_close.width();
- break;
- default:
- assert(false); // the layout string is invalid!
- }
- x += sep;
- }
+ _innersize.left = _innersize.top = _innersize.bottom = _innersize.right =
+ geom.cbwidth;
+ geom.width = _client->area().width() + geom.cbwidth * 2;
+ assert(geom.width > 0);
+
+ // set border widths
+ XSetWindowBorderWidth(**otk::display, _plate, geom.cbwidth);
+ XSetWindowBorderWidth(**otk::display, _frame, geom.bwidth);
+ XSetWindowBorderWidth(**otk::display, _title, geom.bwidth);
+ XSetWindowBorderWidth(**otk::display, _handle, geom.bwidth);
+ XSetWindowBorderWidth(**otk::display, _lgrip, geom.bwidth);
+ XSetWindowBorderWidth(**otk::display, _rgrip, geom.bwidth);
+
+ // position/size and map/unmap all the windows
+
+ if (decorations & Client::Decor_Titlebar) {
+ XMoveResizeWindow(**otk::display, _title, -geom.bwidth, -geom.bwidth,
+ geom.width, geom.title_height());
+ _innersize.top += geom.title_height() + geom.bwidth;
+ XMapWindow(**otk::display, _title);
+
+ // layout the title bar elements
+ layoutTitle();
+ } else
+ XUnmapWindow(**otk::display, _title);
+
+ if (decorations & Client::Decor_Handle) {
+ geom.handle_y = _innersize.top + _client->area().height() + geom.cbwidth;
+ XMoveResizeWindow(**otk::display, _handle, -geom.bwidth, geom.handle_y,
+ geom.width, geom.handle_height);
+ XMoveWindow(**otk::display, _lgrip, -geom.bwidth, -geom.bwidth);
+ XMoveWindow(**otk::display, _rgrip,
+ -geom.bwidth + geom.width - geom.grip_width(),
+ -geom.bwidth);
+ _innersize.bottom += geom.handle_height + geom.bwidth;
+ XMapWindow(**otk::display, _handle);
+ } else
+ XUnmapWindow(**otk::display, _handle);
+
+ XResizeWindow(**otk::display, _frame, geom.width,
+ (_client->shaded() ? geom.title_height() :
+ _innersize.top + _innersize.bottom +
+ _client->area().height()));
+
+ // do this in two steps because clients whose gravity is set to
+ // 'Static' don't end up getting moved at all with an XMoveResizeWindow
+ XMoveWindow(**otk::display, _plate, _innersize.left - geom.cbwidth,
+ _innersize.top - geom.cbwidth);
+ XResizeWindow(**otk::display, _plate, _client->area().width(),
+ _client->area().height());
+
+ _size.left = _innersize.left + geom.bwidth;
+ _size.right = _innersize.right + geom.bwidth;
+ _size.top = _innersize.top + geom.bwidth;
+ _size.bottom = _innersize.bottom + geom.bwidth;
+
+ _area = otk::Rect(_area.position(), otk::Size(_client->area().width() +
+ _size.left + _size.right,
+ _client->area().height() +
+ _size.top + _size.bottom));
+
+ // render all the elements
+ int screen = _client->screen();
+ bool focus = _client->focused();
+ if (decorations & Client::Decor_Titlebar) {
+ render(screen, otk::Size(geom.width, geom.title_height()), _title,
+ &_title_sur, *(focus ? style->titlebarFocusBackground() :
+ style->titlebarUnfocusBackground()));
+
+ renderLabel();