diff options
author | FrHun <28605587+frhun@users.noreply.github.com> | 2022-12-04 19:20:57 +0100 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-12-23 12:16:46 +0000 |
commit | 837625e42247e55218585c85cac206f8387dcf72 (patch) | |
tree | bd7825c65b1f0ae1d39de03183ede93c3f11a4eb /Userland/Applications/Magnifier/MagnifierWidget.cpp | |
parent | 6d4e37138e89dab420b944ea99e9a2497f1e35a8 (diff) | |
download | serenity-837625e42247e55218585c85cac206f8387dcf72.zip |
Magnifier: Allow locking location at current cursor position
Diffstat (limited to 'Userland/Applications/Magnifier/MagnifierWidget.cpp')
-rw-r--r-- | Userland/Applications/Magnifier/MagnifierWidget.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Applications/Magnifier/MagnifierWidget.cpp b/Userland/Applications/Magnifier/MagnifierWidget.cpp index 3595ece21e..9148cecfff 100644 --- a/Userland/Applications/Magnifier/MagnifierWidget.cpp +++ b/Userland/Applications/Magnifier/MagnifierWidget.cpp @@ -24,6 +24,14 @@ void MagnifierWidget::set_scale_factor(int scale_factor) update(); } +void MagnifierWidget::lock_location(bool lock) +{ + if (lock) + m_locked_location = GUI::ConnectionToWindowServer::the().get_global_cursor_position(); + else + m_locked_location = {}; +} + void MagnifierWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter) { m_color_filter = move(color_filter); @@ -53,7 +61,12 @@ void MagnifierWidget::sync() auto size = frame_inner_rect().size(); Gfx::IntSize grab_size { size.width() / m_scale_factor, size.height() / m_scale_factor }; - m_grabbed_bitmap = GUI::ConnectionToWindowServer::the().get_screen_bitmap_around_cursor(grab_size).bitmap(); + + 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(); } |