GWidget: Fix accidentally ignored set_relative_rect() with empty size

To protect the layout system from negative input values, we were using
an empty Rect() whenever an empty rect (width/height <= 0) was provided
to set_relative_rect().

This caused Terminal's scrollbar code to fail, since it relies on first
setting only the scrollbar width on startup, and then setting up the
proper geometry in response to the initial resize event.

Fixes #753.
This commit is contained in:
Andreas Kling 2019-11-10 12:53:05 +01:00
commit 3a01df9fb1
Notes: sideshowbarker 2024-07-19 11:17:12 +09:00

View file

@ -101,7 +101,13 @@ void GWidget::child_event(CChildEvent& event)
void GWidget::set_relative_rect(const Rect& a_rect)
{
Rect rect = a_rect.is_empty() ? Rect() : a_rect;
// Get rid of negative width/height values.
Rect rect = {
a_rect.x(),
a_rect.y(),
max(a_rect.width(), 0),
max(a_rect.height(), 0)
};
if (rect == m_relative_rect)
return;