mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:08:13 +00:00
Magnifier: Add desktop display scale awareness
Continues to magnify correctly at the most current desktop scale.
This commit is contained in:
parent
4ef85de9dc
commit
cab2ee5ea2
2 changed files with 3 additions and 1 deletions
|
@ -38,6 +38,7 @@ void MagnifierWidget::set_scale_factor(int scale_factor)
|
|||
void MagnifierWidget::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
m_mouse_position = GUI::WindowServerConnection::the().get_global_cursor_position();
|
||||
m_desktop_display_scale = GUI::WindowServerConnection::the().get_desktop_display_scale();
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,7 @@ void MagnifierWidget::paint_event(GUI::PaintEvent&)
|
|||
|
||||
// Grab and paint our screenshot.
|
||||
Gfx::IntSize region_size { size().width() / m_scale_factor, size().height() / m_scale_factor };
|
||||
Gfx::Rect region { m_mouse_position.x() - (region_size.width() / 2), m_mouse_position.y() - (region_size.height() / 2), region_size.width(), region_size.height() };
|
||||
Gfx::Rect region { (m_mouse_position.x() * m_desktop_display_scale) - (region_size.width() / 2), (m_mouse_position.y() * m_desktop_display_scale) - (region_size.height() / 2), region_size.width(), region_size.height() };
|
||||
auto map = GUI::WindowServerConnection::the().get_screen_bitmap(region);
|
||||
painter.draw_scaled_bitmap(rect(), *map.bitmap(), map.bitmap()->rect());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue