]> Dogcows Code - chaz/openbox/blobdiff - src/frame.cc
remove the redundant _size property in OBScreen, and set the geometry root property...
[chaz/openbox] / src / frame.cc
index 22249ce55762bf119be418811644633e3f76a975..20e81ebd192d928a034c03aefe81367228ed8fa2 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 
 namespace ob {
 
-OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
+OBFrame::OBFrame(OBClient *client, const otk::Style *style)
   : _client(client),
     _screen(otk::OBDisplay::screenInfo(client->screen()))
 {
@@ -27,9 +27,6 @@ OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
  
   _decorations = client->decorations();
  
-  _style = 0;
-  loadStyle(style);
-
   // create the base frame parent window
   _window = createFrame();
   assert(_window);
@@ -57,23 +54,28 @@ OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
   assert(_grip_right);
   XMapSubwindows(otk::OBDisplay::display, _handle);
   
+  _style = 0;
+  loadStyle(style);
+
   grabClient();
 }
 
 
 OBFrame::~OBFrame()
 {
-  releaseClient(false);
-
-  XDestroyWindow(otk::OBDisplay::display, _titlebar);
   XDestroyWindow(otk::OBDisplay::display, _button_iconify);
   XDestroyWindow(otk::OBDisplay::display, _button_max);
   XDestroyWindow(otk::OBDisplay::display, _button_stick);
   XDestroyWindow(otk::OBDisplay::display, _button_close);
   XDestroyWindow(otk::OBDisplay::display, _label);
-  XDestroyWindow(otk::OBDisplay::display, _handle);
+  XDestroyWindow(otk::OBDisplay::display, _titlebar);
   XDestroyWindow(otk::OBDisplay::display, _grip_left);
   XDestroyWindow(otk::OBDisplay::display, _grip_right);
+  XDestroyWindow(otk::OBDisplay::display, _handle);
+
+  releaseClient(false);
+
+  XDestroyWindow(otk::OBDisplay::display, _window);
 }
 
 
@@ -83,7 +85,6 @@ void OBFrame::loadStyle(const otk::Style *style)
 
   // if a style was previously set, then 'replace' is true, cause we're
   // replacing a style
-  // NOTE: if this is false, then DO NOT DO SHIT WITH _window, it doesnt exist
   bool replace = (_style);
 
   if (replace) {
@@ -92,12 +93,38 @@ void OBFrame::loadStyle(const otk::Style *style)
   
   _style = style;
 
+  XSetWindowBorderWidth(otk::OBDisplay::display, _window,
+                        _style->getBorderWidth());
+  XSetWindowBorder(otk::OBDisplay::display, _window,
+                   _style->getBorderColor().pixel());
+  XSetWindowBorderWidth(otk::OBDisplay::display, _titlebar,
+                        _style->getBorderWidth());
+  XSetWindowBorder(otk::OBDisplay::display, _titlebar,
+                   _style->getBorderColor().pixel());
+  XSetWindowBorderWidth(otk::OBDisplay::display, _grip_left,
+                        _style->getBorderWidth());
+  XSetWindowBorder(otk::OBDisplay::display, _grip_left,
+                   _style->getBorderColor().pixel());
+  XSetWindowBorderWidth(otk::OBDisplay::display, _grip_right,
+                        _style->getBorderWidth());
+  XSetWindowBorder(otk::OBDisplay::display, _grip_right,
+                   _style->getBorderColor().pixel());
+  XSetWindowBorderWidth(otk::OBDisplay::display, _handle,
+                        _style->getBorderWidth());
+  XSetWindowBorder(otk::OBDisplay::display, _handle,
+                   _style->getBorderColor().pixel());
+  
+  // XXX: if (focused)
+    XSetWindowBackground(otk::OBDisplay::display, _window,
+                         _style->getFrameFocus().color().pixel());
+  // XXX: else  
+  // XXX:  XSetWindowBackground(otk::OBDisplay::display, _window,
+  // XXX:                       _style->getFrameUnfocus().color().pixel());
+
+  // if !replace, then update() will get called after the client is grabbed!
   if (replace) {
     update();
     
-    XSetWindowBorderWidth(otk::OBDisplay::display, _window,
-                          _style->getBorderWidth());
-
     // XXX: make everything redraw
   }
 }
@@ -112,7 +139,7 @@ void OBFrame::update()
   
   if (_decorations & OBClient::Decor_Border) {
     _size.left = _size.top = _size.bottom = _size.right =
-      _style->getBorderWidth() + _style->getFrameWidth();
+      _style->getFrameWidth();
     width = _client->area().width() + _style->getFrameWidth() * 2;
   } else {
     _size.left = _size.top = _size.bottom = _size.right = 0;
@@ -120,15 +147,17 @@ void OBFrame::update()
   }
 
   if (_decorations & OBClient::Decor_Titlebar) {
-    _titlebar_area.setRect(0, 0, width,
-                           (_style->getFont()->height() +
-                            _style->getFrameWidth() * 2));
+    // set the titlebar size
+    _titlebar_area.setRect(-_style->getBorderWidth(),
+                           -_style->getBorderWidth(),
+                           width,
+                           (_style->getFont().height() +
+                            _style->getBevelWidth() * 2));
     _size.top += _titlebar_area.height() + _style->getBorderWidth();
 
     // set the label size
     _label_area.setRect(0, _style->getBevelWidth(),
-                        width, (_titlebar_area.height() -
-                                _style->getBevelWidth() * 2));
+                        width, _style->getFont().height());
     // set the buttons sizes
     if (_decorations & OBClient::Decor_Iconify)
       _button_iconify_area.setRect(0, _style->getBevelWidth() + 1,
@@ -155,6 +184,14 @@ void OBFrame::update()
     // 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_area.setWidth(_label_area.width() -
+                         ((_button_iconify_area.width() + sep) *
+                          (layout.size() - 1) + sep));
+
     int x = sep;
     for (int i = 0, len = layout.size(); i < len; ++i) {
       otk::Rect *area;
@@ -192,25 +229,24 @@ void OBFrame::update()
   }
 
   if (_decorations & OBClient::Decor_Handle) {
-    _handle_area.setRect(0, _size.top + _client->area().height() +
-                         _style->getBorderWidth(),
+    _handle_area.setRect(-_style->getBorderWidth(),
+                         _size.top + _client->area().height() +
+                         _style->getFrameWidth(),
                          width, _style->getHandleWidth());
-    _grip_left_area.setRect(0,
-                            _handle_area.y() + _handle_area.height() +
-                            _style->getBorderWidth(),
+    _grip_left_area.setRect(-_style->getBorderWidth(),
+                            -_style->getBorderWidth(),
                             // XXX: get a Point class in otk and use that for
                             // the 'buttons size' since theyre all the same
                             _button_iconify_area.width() * 2,
                             _handle_area.height());
     _grip_right_area.setRect(((_handle_area.right() + 1) -
                               _button_iconify_area.width() * 2),
-                             _handle_area.y() + _handle_area.height() +
-                             _style->getBorderWidth(),
+                             -_style->getBorderWidth(),
                              // XXX: get a Point class in otk and use that for
                              // the 'buttons size' since theyre all the same
                              _button_iconify_area.width() * 2,
                              _handle_area.height());
-    _size.bottom += _handle_area.height() + _style->getBorderWidth() * 2;
+    _size.bottom += _handle_area.height() + _style->getBorderWidth();
   }
   
 
@@ -266,7 +302,6 @@ void OBFrame::update()
 
   // map/unmap all the windows
   if (_decorations & OBClient::Decor_Titlebar) {
-    XMapWindow(otk::OBDisplay::display, _titlebar);
     XMapWindow(otk::OBDisplay::display, _label);
     if (_decorations & OBClient::Decor_Iconify)
       XMapWindow(otk::OBDisplay::display, _button_iconify);
@@ -284,6 +319,7 @@ void OBFrame::update()
       XMapWindow(otk::OBDisplay::display, _button_close);
     else
       XUnmapWindow(otk::OBDisplay::display, _button_close);
+    XMapWindow(otk::OBDisplay::display, _titlebar);
   } else {
     XUnmapWindow(otk::OBDisplay::display, _titlebar);
     XUnmapWindow(otk::OBDisplay::display, _label);
@@ -294,9 +330,9 @@ void OBFrame::update()
   }
 
   if (_decorations & OBClient::Decor_Handle) {
-    XMapWindow(otk::OBDisplay::display, _handle);
     XMapWindow(otk::OBDisplay::display, _grip_left);
     XMapWindow(otk::OBDisplay::display, _grip_right);
+    XMapWindow(otk::OBDisplay::display, _handle);
   } else {
     XUnmapWindow(otk::OBDisplay::display, _handle);
     XUnmapWindow(otk::OBDisplay::display, _grip_left);
@@ -315,14 +351,14 @@ void OBFrame::updateShape()
   if (!_client->shaped()) {
     // clear the shape on the frame window
     XShapeCombineMask(otk::OBDisplay::display, _window, ShapeBounding,
-                      _size.left - 2,//frame.margin.left - frame.border_w,
-                      _size.top - 2,//frame.margin.top - frame.border_w,
+                      _size.left,
+                      _size.top,
                       None, ShapeSet);
   } else {
     // make the frame's shape match the clients
     XShapeCombineShape(otk::OBDisplay::display, _window, ShapeBounding,
-                       _size.left - 2,
-                       _size.top - 2,
+                       _size.left,
+                       _size.top,
                        _client->window(), ShapeBounding, ShapeSet);
 
   int num = 0;
@@ -356,26 +392,18 @@ void OBFrame::updateShape()
 void OBFrame::grabClient()
 {
   
-  XGrabServer(otk::OBDisplay::display);
-
   // select the event mask on the frame
-  XSelectInput(otk::OBDisplay::display, _window, SubstructureRedirectMask);
+  //XSelectInput(otk::OBDisplay::display, _window, SubstructureRedirectMask);
 
   // reparent the client to the frame
-  XSelectInput(otk::OBDisplay::display, _client->window(),
-               OBClient::event_mask & ~StructureNotifyMask);
-  XReparentWindow(otk::OBDisplay::display, _client->window(), _window,
-                  _size.left, _size.top);
-  XSelectInput(otk::OBDisplay::display, _client->window(),
-               OBClient::event_mask);
+  XReparentWindow(otk::OBDisplay::display, _client->window(), _window, 0, 0);
+  _client->ignore_unmaps++;
 
   // raise the client above the frame
-  XRaiseWindow(otk::OBDisplay::display, _client->window());
+  //XRaiseWindow(otk::OBDisplay::display, _client->window());
   // map the client so it maps when the frame does
   XMapWindow(otk::OBDisplay::display, _client->window());
   
-  XUngrabServer(otk::OBDisplay::display);
-
   update();
 }
 
@@ -416,9 +444,10 @@ Window OBFrame::createChild(Window parent, Cursor cursor)
     attrib_create.cursor = cursor;
   }
 
-  return XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0,
-                       _screen->getDepth(), InputOutput, _screen->getVisual(),
-                       create_mask, &attrib_create);
+  Window w = XCreateWindow(otk::OBDisplay::display, parent, 0, 0, 1, 1, 0,
+                           _screen->getDepth(), InputOutput,
+                           _screen->getVisual(), create_mask, &attrib_create);
+  return w;
 }
 
 
@@ -439,7 +468,7 @@ Window OBFrame::createFrame()
   */
 
   return XCreateWindow(otk::OBDisplay::display, _screen->getRootWindow(),
-                       0, 0, 1, 1, _style->getBorderWidth(),
+                       0, 0, 1, 1, 0,
                        _screen->getDepth(), InputOutput, _screen->getVisual(),
                        create_mask, &attrib_create);
 }
This page took 0.033443 seconds and 4 git commands to generate.