1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

WindowServer: Add a "scale" parameter to the SetResolution message and plumb it through

Now, `chres 640 480 2` can set the UI to HighDPI 640x480 at runtime. A
real GUI for changing the display factor will come later.

(`chres 640 480 2` followed by `chres 1280 960` is very fast since
we don't have to re-allocate the framebuffer since both modes use
the exact same number of physical pixels.)
This commit is contained in:
Nico Weber 2021-01-15 14:53:53 -05:00 committed by Andreas Kling
parent 248d75e13b
commit 63ac9462ad
9 changed files with 53 additions and 32 deletions

View file

@ -124,9 +124,9 @@ const Gfx::Font& WindowManager::window_title_font() const
return Gfx::FontDatabase::default_bold_font();
}
bool WindowManager::set_resolution(int width, int height)
bool WindowManager::set_resolution(int width, int height, int scale)
{
bool success = Compositor::the().set_resolution(width, height);
bool success = Compositor::the().set_resolution(width, height, scale);
MenuManager::the().set_needs_window_resize();
ClientConnection::for_each_client([&](ClientConnection& client) {
client.notify_about_new_screen_rect(Screen::the().rect());
@ -139,14 +139,16 @@ bool WindowManager::set_resolution(int width, int height)
}
if (m_config) {
if (success) {
dbg() << "Saving resolution: " << Gfx::IntSize(width, height) << " to config file at " << m_config->file_name();
dbg() << "Saving resolution: " << Gfx::IntSize(width, height) << " @ " << scale << "x to config file at " << m_config->file_name();
m_config->write_num_entry("Screen", "Width", width);
m_config->write_num_entry("Screen", "Height", height);
m_config->write_num_entry("Screen", "ScaleFactor", scale);
m_config->sync();
} else {
dbg() << "Saving fallback resolution: " << resolution() << " to config file at " << m_config->file_name();
dbg() << "Saving fallback resolution: " << resolution() << " @ 1x to config file at " << m_config->file_name();
m_config->write_num_entry("Screen", "Width", resolution().width());
m_config->write_num_entry("Screen", "Height", resolution().height());
m_config->write_num_entry("Screen", "ScaleFactor", 1);
m_config->sync();
}
}
@ -174,6 +176,11 @@ void WindowManager::set_scroll_step_size(unsigned step_size)
m_config->sync();
}
int WindowManager::scale_factor() const
{
return Screen::the().scale_factor();
}
void WindowManager::add_window(Window& window)
{
bool is_first_window = m_windows_in_order.is_empty();