dont try free the widget's pixmap until it is no longer in use
This commit is contained in:
parent
24e20d5ed6
commit
68a6fce53b
7 changed files with 16 additions and 11 deletions
|
@ -67,7 +67,7 @@ void FocusLabel::renderForeground(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
display->renderControl(_screen)->
|
display->renderControl(_screen)->
|
||||||
drawString(_surface, *ft, x, 0, *text_color, t);
|
drawString(*_surface, *ft, x, 0, *text_color, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ void Label::renderForeground(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
display->renderControl(_screen)->
|
display->renderControl(_screen)->
|
||||||
drawString(_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
|
drawString(*_surface, *ft, x, 0, *style()->getTextUnfocus(), t);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char **argv)
|
||||||
otk::AppWidget foo(&app);
|
otk::AppWidget foo(&app);
|
||||||
foo.resize(600, 500);
|
foo.resize(600, 500);
|
||||||
|
|
||||||
otk::RenderColor color(0, 0xff, 0x20, 0x20);
|
otk::RenderColor color(0, 0, 0xff, 0xff);
|
||||||
otk::RenderTexture tex(false,
|
otk::RenderTexture tex(false,
|
||||||
otk::RenderTexture::Flat,
|
otk::RenderTexture::Flat,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -39,7 +39,6 @@ void Surface::setPixmap(const RenderColor &color)
|
||||||
|
|
||||||
void Surface::setPixmap(XImage *image)
|
void Surface::setPixmap(XImage *image)
|
||||||
{
|
{
|
||||||
printf("SET PIXMAP\n");
|
|
||||||
assert(image->width == _size.x());
|
assert(image->width == _size.x());
|
||||||
assert(image->height == _size.y());
|
assert(image->height == _size.y());
|
||||||
|
|
||||||
|
|
|
@ -132,5 +132,7 @@ void TrueRenderControl::drawBackground(Surface& sf,
|
||||||
|
|
||||||
delete [] im->data;
|
delete [] im->data;
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
XDestroyImage(im);}
|
XDestroyImage(im);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ Widget::Widget(Widget *parent, Direction direction)
|
||||||
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
|
_stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
|
||||||
_bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
|
_bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
|
||||||
_fixed_width(false), _fixed_height(false),
|
_fixed_width(false), _fixed_height(false),
|
||||||
_surface(parent->screen(), _rect.size()),
|
_surface(0),
|
||||||
_event_dispatcher(parent->eventDispatcher())
|
_event_dispatcher(parent->eventDispatcher())
|
||||||
{
|
{
|
||||||
assert(parent);
|
assert(parent);
|
||||||
|
@ -46,7 +46,7 @@ Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
|
||||||
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
|
_stretchable_vert(false), _stretchable_horz(false), _texture(0),
|
||||||
_bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
|
_bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
|
||||||
_screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
|
_screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
|
||||||
_surface(style->getScreen(), _rect.size()),
|
_surface(0),
|
||||||
_event_dispatcher(event_dispatcher)
|
_event_dispatcher(event_dispatcher)
|
||||||
{
|
{
|
||||||
assert(event_dispatcher);
|
assert(event_dispatcher);
|
||||||
|
@ -261,12 +261,16 @@ void Widget::render(void)
|
||||||
if (!_texture) return;
|
if (!_texture) return;
|
||||||
printf("RENDER\n");
|
printf("RENDER\n");
|
||||||
|
|
||||||
_surface = Surface(_screen, _rect.size());
|
Surface *s = _surface; // save the current surface
|
||||||
display->renderControl(_screen)->drawBackground(_surface, *_texture);
|
|
||||||
|
_surface = new Surface(_screen, _rect.size());
|
||||||
|
display->renderControl(_screen)->drawBackground(*_surface, *_texture);
|
||||||
|
|
||||||
renderForeground();
|
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)
|
void Widget::adjust(void)
|
||||||
|
|
|
@ -167,7 +167,7 @@ protected:
|
||||||
bool _fixed_width;
|
bool _fixed_width;
|
||||||
bool _fixed_height;
|
bool _fixed_height;
|
||||||
|
|
||||||
Surface _surface;
|
Surface *_surface;
|
||||||
|
|
||||||
EventDispatcher *_event_dispatcher;
|
EventDispatcher *_event_dispatcher;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue