1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +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

@ -710,19 +710,19 @@ void Compositor::run_animations(Gfx::DisjointRectSet& flush_rects)
});
}
bool Compositor::set_resolution(int desired_width, int desired_height)
bool Compositor::set_resolution(int desired_width, int desired_height, int scale_factor)
{
auto screen_rect = Screen::the().rect();
if (screen_rect.width() == desired_width && screen_rect.height() == desired_height)
if (screen_rect.width() == desired_width && screen_rect.height() == desired_height && Screen::the().scale_factor() == scale_factor)
return true;
// Make sure it's impossible to set an invalid resolution
if (!(desired_width >= 640 && desired_height >= 480)) {
dbg() << "Compositor: Tried to set invalid resolution: " << desired_width << "x" << desired_height;
if (!(desired_width >= 640 && desired_height >= 480 && scale_factor >= 1)) {
dbg() << "Compositor: Tried to set invalid resolution: " << desired_width << "x" << desired_height << " @ " << scale_factor << "x";
return false;
}
bool success = Screen::the().set_resolution(desired_width, desired_height, 1);
bool success = Screen::the().set_resolution(desired_width, desired_height, scale_factor);
init_bitmaps();
invalidate_occlusions();
compose();