WindowServer: Add API to set/get screen layouts

This sets the stage so that DisplaySettings can configure the screen
layout and set various screen resolutions in one go. It also allows
for an easy "atomic" revert of the previous settings.
This commit is contained in:
Tom 2021-06-14 21:19:56 -06:00 committed by Andreas Kling
commit aa15bf81e4
Notes: sideshowbarker 2024-07-18 11:58:55 +09:00
23 changed files with 558 additions and 228 deletions

View file

@ -26,9 +26,16 @@ int main(int argc, char** 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().set_resolution(screen, Gfx::IntSize { width, height }, scale);
if (!result.success()) {
warnln("failed to set resolution");
auto screen_layout = GUI::WindowServerConnection::the().get_screen_layout();
if (screen < 0 || (size_t)screen >= screen_layout.screens.size()) {
warnln("invalid screen index: {}", screen);
return 1;
}
auto& main_screen = screen_layout.screens[screen];
main_screen.resolution = { width, height };
auto set_result = GUI::WindowServerConnection::the().set_screen_layout(screen_layout, true);
if (!set_result.success()) {
warnln("failed to set resolution: {}", set_result.error_msg());
return 1;
}
}