#include #include #include #include #include #include #include #include #include #include #include static constexpr ui::Color TASKBAR_COLOR = ui::Color::from_rgb(83, 83, 83); static OwnedPtr launcher_client; void sigchld_handler(int) { wait(nullptr); } Result create_widget_group_for_app(ui::HorizontalLayout& layout, StringView path, StringView icon) { auto* button = new (std::nothrow) ui::Button({ 0, 0, 50, 50 }); if (!button) return err(ENOMEM); layout.add_widget(*button); auto* container = new (std::nothrow) ui::Container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center); if (!container) return err(ENOMEM); button->set_widget(*container); button->set_action([=] { os::Launcher::LaunchDetachedRequest request; SET_IPC_STRING(request.command, path.chars()); launcher_client->send_async(request); }); auto image = TRY(ui::ImageWidget::load(icon)); container->set_widget(*image); image.leak(); return {}; } Result luna_main(int, char**) { ui::App app; TRY(app.init("/tmp/wsys.sock")); TRY(os::EventLoop::the().register_signal_handler(SIGCHLD, sigchld_handler)); launcher_client = TRY(os::IPC::Client::connect("/tmp/launch.sock", false)); ui::Rect screen = app.screen_rect(); ui::Rect bar = ui::Rect { ui::Point { 0, screen.height - 50 }, screen.width, 50 }; auto window = TRY(ui::Window::create(bar, ui::WindowType::System)); app.set_main_window(window); window->set_background(TASKBAR_COLOR); window->set_special_attributes(ui::UNFOCUSEABLE); ui::HorizontalLayout layout(ui::Margins { 0, 0, 0, 0 }, ui::AdjustHeight::Yes, ui::AdjustWidth::No); window->set_main_widget(layout); TRY(create_widget_group_for_app(layout, "/usr/bin/terminal", "/usr/share/icons/32x32/app-terminal.tga")); TRY(create_widget_group_for_app(layout, "/usr/bin/about", "/usr/share/icons/32x32/app-about.tga")); TRY(create_widget_group_for_app(layout, "/usr/bin/gol", "/usr/share/icons/32x32/app-gol.tga")); TRY(create_widget_group_for_app(layout, "/usr/bin/clock", "/usr/share/icons/32x32/app-clock.tga")); return app.run(); }