]> Dogcows Code - chaz/openbox/commitdiff
dont try free the widget's pixmap until it is no longer in use
authorDana Jansens <danakj@orodu.net>
Mon, 20 Jan 2003 19:28:57 +0000 (19:28 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 20 Jan 2003 19:28:57 +0000 (19:28 +0000)
otk/focuslabel.cc
otk/label.cc
otk/rendertest.cc
otk/surface.cc
otk/truerendercontrol.cc
otk/widget.cc
otk/widget.hh

index 79d68b092903f1f05fabc69036d82bf447a71a6c..6869d231c081a3ce21f0476cf99796e5f8d6bd1b 100644 (file)
@@ -67,7 +67,7 @@ void FocusLabel::renderForeground(void)
   }
 
   display->renderControl(_screen)->
-    drawString(_surface, *ft, x, 0, *text_color, t);
+    drawString(*_surface, *ft, x, 0, *text_color, t);
 }
 
 }
index 8c429dba92157bc962b0362c9eefe52369cc3b47..b536451e0a4fbb3b295fda7c7e5796d785f3ffc9 100644 (file)
@@ -61,7 +61,7 @@ void Label::renderForeground(void)
   }
 
   display->renderControl(_screen)->
-    drawString(_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
+    drawString(*_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
 }
 
 }
index 33b1db36ca367c8b6771424316bf5790fe83ab4e..d6e3dbfcab9ca596c0e4f1b2fe8650deeeb36cb5 100644 (file)
@@ -13,7 +13,7 @@ int main(int argc, char **argv)
   otk::AppWidget foo(&app);
   foo.resize(600, 500);
 
-  otk::RenderColor color(0, 0xff, 0x20, 0x20);
+  otk::RenderColor color(0, 0, 0xff, 0xff);
   otk::RenderTexture tex(false,
                         otk::RenderTexture::Flat,
                         false,
index 4f6ef3862453015fddc0c53ae89d1d0a5f537b47..70acf70ac5f16289897bcdad0be7c99f94c94928 100644 (file)
@@ -39,7 +39,6 @@ void Surface::setPixmap(const RenderColor &color)
 
 void Surface::setPixmap(XImage *image)
 {
-  printf("SET PIXMAP\n");
   assert(image->width == _size.x());
   assert(image->height == _size.y());
   
index 786a3b0997a8d4b11034724e94cbe8a1eff35d5d..078cde5bb18cc2045aa5730ab78d679f4bf2aa56 100644 (file)
@@ -132,5 +132,7 @@ void TrueRenderControl::drawBackground(Surface& sf,
 
   delete [] im->data;
   im->data = NULL;
-  XDestroyImage(im);}
+  XDestroyImage(im);
+}
+
 }
index 9f574ee930ba022a57ea333b3bdce1beb9ff58f2..d32cb624f4629e2fb48282f33c1ea35c6c1128e5 100644 (file)
@@ -25,7 +25,7 @@ Widget::Widget(Widget *parent, Direction direction)
     _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
     _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
     _fixed_width(false), _fixed_height(false),
-    _surface(parent->screen(), _rect.size()),
+    _surface(0),
     _event_dispatcher(parent->eventDispatcher())
 {
   assert(parent);
@@ -46,7 +46,7 @@ Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
     _stretchable_vert(false), _stretchable_horz(false), _texture(0),
     _bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
     _screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
-    _surface(style->getScreen(), _rect.size()),
+    _surface(0),
     _event_dispatcher(event_dispatcher)
 {
   assert(event_dispatcher);
@@ -261,12 +261,16 @@ void Widget::render(void)
   if (!_texture) return;
   printf("RENDER\n");
 
-  _surface = Surface(_screen, _rect.size());
-  display->renderControl(_screen)->drawBackground(_surface, *_texture);
+  Surface *s = _surface; // save the current surface
+  
+  _surface = new Surface(_screen, _rect.size());
+  display->renderControl(_screen)->drawBackground(*_surface, *_texture);
 
   renderForeground();
 
-  XSetWindowBackgroundPixmap(**display, _window, _surface.pixmap());
+  XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
+
+  delete s; // delete the old surface *after* its pixmap isn't in use anymore
 }
 
 void Widget::adjust(void)
index 7d183c28963571b2e69cb1e48049275d27505388..c7fc713bbb79a7b392db8a6c9f1722b5cdf86282 100644 (file)
@@ -167,7 +167,7 @@ protected:
   bool _fixed_width;
   bool _fixed_height;
 
-  Surface _surface;
+  Surface *_surface;
 
   EventDispatcher *_event_dispatcher;
 };
This page took 0.032744 seconds and 4 git commands to generate.