summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-11-15 15:42:14 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-11-15 15:42:14 +0100
commit37e0c7ece76d2fdc23a42f87f9112ec1423dd988 (patch)
tree9d52181de738cf69784f017e8975ac39b790eccc /plugingui
parenta8eea6e9c1f32d5562594656c68dc4b9f985b790 (diff)
Make sure tooltips are always shown inside the window.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/pixelbuffer.cc9
-rw-r--r--plugingui/tooltip.cc4
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();