mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
Pong: Port to LibMain
Simplified two pledge() and two unveil() by using TRY().
This commit is contained in:
parent
3ca2f192af
commit
d68196969d
Notes:
sideshowbarker
2024-07-18 00:46:54 +09:00
Author: https://github.com/pmhpereira Commit: https://github.com/SerenityOS/serenity/commit/d68196969d1 Pull-request: https://github.com/SerenityOS/serenity/pull/11034
2 changed files with 9 additions and 21 deletions
|
@ -10,4 +10,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_app(Pong ICON app-pong)
|
||||
target_link_libraries(Pong LibGUI)
|
||||
target_link_libraries(Pong LibGUI LibMain)
|
||||
|
|
|
@ -5,37 +5,25 @@
|
|||
*/
|
||||
|
||||
#include "Game.h"
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Icon.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Menubar.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <unistd.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr));
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
auto app = GUI::Application::construct(arguments);
|
||||
|
||||
if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr));
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::unveil("/res", "r"));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->resize(Pong::Game::game_width, Pong::Game::game_height);
|
||||
|
|
Loading…
Reference in a new issue