diff --git a/apps/taskbar.cpp b/apps/taskbar.cpp index e179f5fa..5e39803f 100644 --- a/apps/taskbar.cpp +++ b/apps/taskbar.cpp @@ -26,7 +26,7 @@ Result luna_main(int argc, char** argv) ui::Rect bar = ui::Rect { ui::Point { 0, screen.height - 50 }, screen.width, 50 }; - auto window = TRY(ui::Window::create(bar, false)); + auto window = TRY(ui::Window::create(bar, ui::WindowType::System)); app.set_main_window(window); window->set_background(TASKBAR_COLOR); diff --git a/libui/include/ui/Window.h b/libui/include/ui/Window.h index 3e121a8f..189f52c6 100644 --- a/libui/include/ui/Window.h +++ b/libui/include/ui/Window.h @@ -14,13 +14,14 @@ #include #include #include +#include namespace ui { class Window { public: - static Result create(Rect rect, bool decorated = true); + static Result create(Rect rect, WindowType type = WindowType::Normal); void set_title(StringView title); diff --git a/libui/include/ui/ipc/Server.h b/libui/include/ui/ipc/Server.h index 7e675c53..dac9cd21 100644 --- a/libui/include/ui/ipc/Server.h +++ b/libui/include/ui/ipc/Server.h @@ -25,13 +25,20 @@ namespace ui GET_SCREEN_RECT_ID, }; + enum class WindowType : u8 + { + Normal, + NotDecorated, + System, + }; + struct CreateWindowRequest { using ResponseType = CreateWindowResponse; static constexpr u8 ID = CREATE_WINDOW_ID; ui::Rect rect; - bool decorated; + WindowType type; }; struct SetWindowTitleRequest diff --git a/libui/src/Window.cpp b/libui/src/Window.cpp index 298a4499..0acb267d 100644 --- a/libui/src/Window.cpp +++ b/libui/src/Window.cpp @@ -16,13 +16,13 @@ namespace ui { - Result Window::create(Rect rect, bool decorated) + Result Window::create(Rect rect, WindowType type) { auto window = TRY(make_owned()); ui::CreateWindowRequest request; request.rect = rect; - request.decorated = decorated; + request.type = type; auto response = TRY(os::IPC::send_sync(App::the().client(), request)); auto path = COPY_IPC_STRING(response.shm_path); diff --git a/wind/IPC.cpp b/wind/IPC.cpp index e04d0300..b251ae3f 100644 --- a/wind/IPC.cpp +++ b/wind/IPC.cpp @@ -56,7 +56,7 @@ static Result handle_create_window_message(Client& client) ui::CreateWindowRequest request; READ_MESSAGE(request); - if (request.decorated) + if (request.type == ui::WindowType::Normal) { request.rect.height += Window::titlebar_height(); // Make sure we provide the full contents rect that was asked for. @@ -69,7 +69,7 @@ static Result handle_create_window_message(Client& client) auto shm_path = TRY(String::format("/wind-shm-%d-%lu"_sv, client.conn.fd(), time(NULL))); - auto* window = new (std::nothrow) Window(request.rect, move(name), request.decorated); + auto* window = new (std::nothrow) Window(request.rect, move(name), request.type); if (!window) { os::IPC::send_error(client.conn, ENOMEM); diff --git a/wind/Mouse.cpp b/wind/Mouse.cpp index 125a37a7..070c633c 100644 --- a/wind/Mouse.cpp +++ b/wind/Mouse.cpp @@ -82,7 +82,7 @@ void Mouse::update(const moon::MousePacket& packet) } else if (window->surface.absolute(window->contents).contains(m_position)) { - window->focus(); + if (window->type != ui::WindowType::System) window->focus(); break; // We don't want to continue iterating, otherwise this would take into account windows whose // titlebar is underneath another window's contents! } diff --git a/wind/Window.cpp b/wind/Window.cpp index 4bee2242..b9b7b769 100644 --- a/wind/Window.cpp +++ b/wind/Window.cpp @@ -43,9 +43,10 @@ void Window::focus() g_windows.append(this); } -Window::Window(ui::Rect r, String&& n, bool d) : surface(r), name(move(n)), decorated(d) +Window::Window(ui::Rect r, String&& n, ui::WindowType t) : surface(r), name(move(n)), type(t) { auto font = ui::Font::default_font(); + bool decorated { type == ui::WindowType::Normal }; if (decorated && surface.width < 36) surface.width = 36; if (decorated && surface.height < (font->height() + 20)) surface.height = font->height() + 20; titlebar = decorated ? ui::Rect { 0, 0, surface.width, font->height() + 20 } : ui::Rect { 0, 0, 0, 0 }; diff --git a/wind/Window.h b/wind/Window.h index 9fcf33b2..f87d5526 100644 --- a/wind/Window.h +++ b/wind/Window.h @@ -4,6 +4,7 @@ #include #include #include +#include struct Client; @@ -18,11 +19,11 @@ struct Window : public LinkedListNode bool dirty { false }; Client* client; int id; - bool decorated; + ui::WindowType type; static int titlebar_height(); - Window(ui::Rect, String&&, bool); + Window(ui::Rect, String&&, ui::WindowType); ~Window(); void focus(); diff --git a/wind/main.cpp b/wind/main.cpp index aa8d9cd7..6b0a8e32 100644 --- a/wind/main.cpp +++ b/wind/main.cpp @@ -36,9 +36,9 @@ static void debug(const Vector>& clients) for (const auto& window : g_windows) { os::println("Window of client (fd %d), id %d, %sdecorated, %sdirty (\"%s\") (%d,%d,%d,%d)", - window->client->conn.fd(), window->id, window->decorated ? "" : "not ", window->dirty ? "" : "not ", - window->name.chars(), window->surface.pos.x, window->surface.pos.y, window->surface.width, - window->surface.height); + window->client->conn.fd(), window->id, window->type == ui::WindowType::Normal ? "" : "not ", + window->dirty ? "" : "not ", window->name.chars(), window->surface.pos.x, window->surface.pos.y, + window->surface.width, window->surface.height); } os::println("-- wind: Listing processes --");