chres: Port to LibMain :^)

This commit is contained in:
Kenneth Myhra 2021-11-27 16:27:11 +01:00 committed by Brian Gianforcaro
parent cc3710e19f
commit 67a18d51c7
Notes: sideshowbarker 2024-07-17 22:56:33 +09:00
2 changed files with 7 additions and 4 deletions

View file

@ -66,7 +66,7 @@ target_link_libraries(checksum LibCrypto LibMain)
target_link_libraries(chmod LibMain)
target_link_libraries(chgrp LibMain)
target_link_libraries(chown LibMain)
target_link_libraries(chres LibGUI)
target_link_libraries(chres LibGUI LibMain)
target_link_libraries(cksum LibCrypto)
target_link_libraries(config LibConfig)
target_link_libraries(copy LibGUI LibMain)

View file

@ -7,8 +7,9 @@
#include <LibCore/ArgsParser.h>
#include <LibGUI/Application.h>
#include <LibGUI/WindowServerConnection.h>
#include <LibMain/Main.h>
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
int screen = 0;
int width = -1;
@ -21,10 +22,10 @@ int main(int argc, char** argv)
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);
args_parser.parse(arguments);
// A Core::EventLoop is all we need, but WindowServerConnection needs a full Application object.
char* dummy_argv[] = { argv[0] };
char* dummy_argv[] = { arguments.argv[0] };
auto app = GUI::Application::construct(1, dummy_argv);
auto screen_layout = GUI::WindowServerConnection::the().get_screen_layout();
if (screen < 0 || (size_t)screen >= screen_layout.screens.size()) {
@ -40,4 +41,6 @@ int main(int argc, char** argv)
warnln("failed to set resolution: {}", set_result.error_msg());
return 1;
}
return 0;
}