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

@ -32,17 +32,19 @@ int main(int argc, char** argv)
{
int width = -1;
int height = -1;
int scale = 1;
Core::ArgsParser args_parser;
args_parser.set_general_help("Change the screen resolution.");
args_parser.add_positional_argument(width, "Width", "width");
args_parser.add_positional_argument(height, "Height", "height");
args_parser.add_positional_argument(scale, "Scale Factor", "scale", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv);
// A Core::EventLoop is all we need, but WindowServerConnection needs a full Application object.
char* dummy_argv[] = { argv[0] };
auto app = GUI::Application::construct(1, dummy_argv);
auto result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(Gfx::IntSize { width, height });
auto result = GUI::WindowServerConnection::the().send_sync<Messages::WindowServer::SetResolution>(Gfx::IntSize { width, height }, scale);
if (!result->success()) {
warnln("failed to set resolution");
return 1;