diff options
Diffstat (limited to 'plugingui')
-rw-r--r-- | plugingui/pixelbuffer.cc | 9 | ||||
-rw-r--r-- | plugingui/tooltip.cc | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/plugingui/pixelbuffer.cc b/plugingui/pixelbuffer.cc index c73e663..3c666cd 100644 --- a/plugingui/pixelbuffer.cc +++ b/plugingui/pixelbuffer.cc @@ -30,6 +30,7 @@ #include <cstdlib> #include <cstring> +#include <algorithm> namespace GUI { @@ -85,10 +86,10 @@ Rect PixelBuffer::updateBuffer(std::vector<PixelBufferAlpha*>& pixel_buffers) { if(pixel_buffer->dirty) { - auto x1 = (std::size_t)pixel_buffer->x; - auto x2 = (std::size_t)(pixel_buffer->x + pixel_buffer->width); - auto y1 = (std::size_t)pixel_buffer->y; - auto y2 = (std::size_t)(pixel_buffer->y + pixel_buffer->height); + auto x1 = (std::size_t)std::max(pixel_buffer->x, 0); + auto x2 = (std::size_t)std::max((pixel_buffer->x + (int)pixel_buffer->width), 0); + auto y1 = (std::size_t)std::max(pixel_buffer->y, 0); + auto y2 = (std::size_t)std::max((pixel_buffer->y + (int)pixel_buffer->height), 0); pixel_buffer->dirty = false; if(!has_dirty_rect) diff --git a/plugingui/tooltip.cc b/plugingui/tooltip.cc index 19bc89b..e251ed5 100644 --- a/plugingui/tooltip.cc +++ b/plugingui/tooltip.cc @@ -177,6 +177,10 @@ void Tooltip::show() y += activating_widget->height(); } + // Make sure the tip is displayed inside the window + x = std::max(x, 0); + y = std::max(y, 0); + move(x, y); Widget::show(); |