]> Dogcows Code - chaz/openbox/blobdiff - src/frame.cc
free the surfaces' pixeldata after rendering it
[chaz/openbox] / src / frame.cc
index 5e9d852030fcc2b60f1be52202334d66a2dac867..a4188b6ee44b93111beb9f0d3e84f2c9cd52f798 100644 (file)
@@ -1,8 +1,6 @@
 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
 
-#ifdef HAVE_CONFIG_H
-# include "../config.h"
-#endif
+#include "config.h"
 
 extern "C" {
 #ifdef    SHAPE
@@ -88,8 +86,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 +104,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 +165,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 +192,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);
 }
@@ -229,6 +227,7 @@ static void render(int screen, const otk::Size &size, Window win,
   XSetWindowBackgroundPixmap(**otk::display, win, s->pixmap());
   XClearWindow(**otk::display, win);
   if (*surface) delete *surface;
+  s->freePixelData();
   *surface = s;
 }
 
@@ -287,10 +286,12 @@ void Frame::adjustSize()
                  _innersize.top + _innersize.bottom +
                  _client->area().height()));
 
-  XMoveResizeWindow(**otk::display, _plate,
-                    _innersize.left - geom.cbwidth,
-                    _innersize.top - geom.cbwidth,
-                    _client->area().width(), _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;
@@ -348,16 +349,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
@@ -381,6 +383,7 @@ void Frame::renderLabel()
   XSetWindowBackgroundPixmap(**otk::display, _label, s->pixmap());
   XClearWindow(**otk::display, _label);
   if (_label_sur) delete _label_sur;
+  s->freePixelData();
   _label_sur = s;
 }
 
This page took 0.023131 seconds and 4 git commands to generate.