mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Magnifier: Prevent 0 size that otherwise hangs
This commit is contained in:
parent
808eafcf1e
commit
9e0deb76b2
Notes:
sideshowbarker
2024-07-17 02:54:03 +09:00
Author: https://github.com/frhun Commit: https://github.com/SerenityOS/serenity/commit/9e0deb76b2 Pull-request: https://github.com/SerenityOS/serenity/pull/16328 Issue: https://github.com/SerenityOS/serenity/issues/8370 Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 10 additions and 0 deletions
|
@ -20,7 +20,10 @@ MagnifierWidget::MagnifierWidget()
|
|||
void MagnifierWidget::set_scale_factor(int scale_factor)
|
||||
{
|
||||
VERIFY(scale_factor == 2 || scale_factor == 4 || scale_factor == 8);
|
||||
if (m_scale_factor == scale_factor)
|
||||
return;
|
||||
m_scale_factor = scale_factor;
|
||||
layout_relevant_change_occurred();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -77,12 +80,14 @@ void MagnifierWidget::sync()
|
|||
|
||||
auto size = frame_inner_rect().size();
|
||||
Gfx::IntSize grab_size { size.width() / m_scale_factor, size.height() / m_scale_factor };
|
||||
VERIFY(grab_size.width() != 0 && grab_size.height() != 0);
|
||||
|
||||
if (m_locked_location.has_value()) {
|
||||
m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_location(grab_size, m_locked_location.value()).bitmap();
|
||||
} else {
|
||||
m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_cursor(grab_size).bitmap();
|
||||
}
|
||||
|
||||
m_grabbed_bitmaps.enqueue(m_grabbed_bitmap);
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ public:
|
|||
void display_next_frame();
|
||||
RefPtr<Gfx::Bitmap> current_bitmap() const { return m_grabbed_bitmap; };
|
||||
|
||||
virtual Optional<GUI::UISize> calculated_min_size() const override
|
||||
{
|
||||
return GUI::UISize { frame_thickness() * 2 + m_scale_factor, frame_thickness() * 2 + m_scale_factor };
|
||||
}
|
||||
|
||||
private:
|
||||
MagnifierWidget();
|
||||
|
||||
|
|
Loading…
Reference in a new issue