From 3a01df9fb117468a802fe8b825b680303029a738 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Nov 2019 12:53:05 +0100 Subject: [PATCH] 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. --- Libraries/LibGUI/GWidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/GWidget.cpp b/Libraries/LibGUI/GWidget.cpp index 7ea80e4c79..a7088352cd 100644 --- a/Libraries/LibGUI/GWidget.cpp +++ b/Libraries/LibGUI/GWidget.cpp @@ -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;