From 494e7218597a6cd94902b3ae6f827e74b41c00b0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Mar 2017 17:25:04 +0100 Subject: Fix redrawing of underlying exposed area on Widget moves/resizing. --- plugingui/widget.cc | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'plugingui/widget.cc') diff --git a/plugingui/widget.cc b/plugingui/widget.cc index 7d92a22..00acfbf 100644 --- a/plugingui/widget.cc +++ b/plugingui/widget.cc @@ -42,6 +42,9 @@ Widget::Widget(Widget* parent) parent->addChild(this); _window = parent->window(); } + + pixbuf.x = translateToWindowX(); + pixbuf.y = translateToWindowY(); } Widget::~Widget() @@ -64,12 +67,14 @@ void Widget::hide() void Widget::setVisible(bool visible) { - _visible = visible; - - if(visible) + if(_visible == visible) { - redraw(); + return; } + + _visible = visible; + pixbuf.visible = visible; + redraw(); } bool Widget::visible() const @@ -130,7 +135,20 @@ void Widget::resize(std::size_t width, std::size_t height) _width = width; _height = height; + + // Store old size/position in pixelbuffer for rendering invalidation. + if(!pixbuf.has_last) + { + pixbuf.last_width = pixbuf.width; + pixbuf.last_height = pixbuf.height; + pixbuf.last_x = pixbuf.x; + pixbuf.last_y = pixbuf.y; + pixbuf.has_last = true; + } + pixbuf.realloc(width, height); + pixbuf.x = translateToWindowX(); + pixbuf.y = translateToWindowY(); redraw(); sizeChangeNotifier(width, height); } @@ -145,6 +163,20 @@ void Widget::move(int x, int y) _x = x; _y = y; + + // Store old size/position in pixelbuffer for rendering invalidation. + if(!pixbuf.has_last) + { + pixbuf.last_width = pixbuf.width; + pixbuf.last_height = pixbuf.height; + pixbuf.last_x = pixbuf.x; + pixbuf.last_y = pixbuf.y; + pixbuf.has_last = true; + } + + //pixbuf.x = translateToWindowX(); + //pixbuf.y = translateToWindowY(); + positionChangeNotifier(x, y); } @@ -216,11 +248,14 @@ std::vector Widget::getPixelBuffers() dirty = false; } - pixelBuffers.push_back(&pixbuf); + if(pixbuf.dirty || visible()) + { + pixelBuffers.push_back(&pixbuf); + } - for(auto child : children) + if(visible()) { - if(child->visible()) + for(auto child : children) { auto childPixelBuffers = child->getPixelBuffers(); pixelBuffers.insert(pixelBuffers.end(), -- cgit v1.2.3