summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/Magnifier/MagnifierWidget.cpp15
-rw-r--r--Userland/Applications/Magnifier/MagnifierWidget.h2
-rw-r--r--Userland/Applications/Magnifier/main.cpp6
3 files changed, 22 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();
}
diff --git a/Userland/Applications/Magnifier/MagnifierWidget.h b/Userland/Applications/Magnifier/MagnifierWidget.h
index 0e731f37d8..c3fd416cfc 100644
--- a/Userland/Applications/Magnifier/MagnifierWidget.h
+++ b/Userland/Applications/Magnifier/MagnifierWidget.h
@@ -27,6 +27,7 @@ public:
if (!pause)
m_frame_offset_from_head = 0;
}
+ void lock_location(bool);
void display_previous_frame();
void display_next_frame();
RefPtr<Gfx::Bitmap> current_bitmap() const { return m_grabbed_bitmap; };
@@ -45,4 +46,5 @@ private:
CircularQueue<RefPtr<Gfx::Bitmap>, 512> m_grabbed_bitmaps {};
ssize_t m_frame_offset_from_head { 0 };
bool m_pause_capture { false };
+ Optional<Gfx::IntPoint> m_locked_location {};
};
diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp
index 49b6628758..b1961f8c26 100644
--- a/Userland/Applications/Magnifier/main.cpp
+++ b/Userland/Applications/Magnifier/main.cpp
@@ -111,6 +111,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
magnifier->pause_capture(action.is_checked());
});
+ auto lock_location_action = GUI::Action::create_checkable(
+ "&Lock Location", { Key_L }, [&](auto& action) {
+ magnifier->lock_location(action.is_checked());
+ });
+
size_action_group->add_action(two_x_action);
size_action_group->add_action(four_x_action);
size_action_group->add_action(eight_x_action);
@@ -124,6 +129,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(view_menu->try_add_separator());
TRY(view_menu->try_add_action(pause_action));
+ TRY(view_menu->try_add_action(lock_location_action));
auto timeline_menu = TRY(window->try_add_menu("&Timeline"));
auto previous_frame_action = GUI::Action::create(