diff --git a/libui/include/ui/ipc/Server.h b/libui/include/ui/ipc/Server.h index 3f5af6f3..8c1cc278 100644 --- a/libui/include/ui/ipc/Server.h +++ b/libui/include/ui/ipc/Server.h @@ -24,7 +24,7 @@ namespace ui INVALIDATE_ID, CLOSE_WINDOW_ID, GET_SCREEN_RECT_ID, - SET_TITLEBAR_RECT_ID, + SET_TITLEBAR_HEIGHT_ID, }; enum class WindowType : u8 @@ -80,11 +80,11 @@ namespace ui int _shadow; // Unused. }; - struct SetTitlebarRectRequest + struct SetTitlebarHeightRequest { - static constexpr u8 ID = SET_TITLEBAR_RECT_ID; + static constexpr u8 ID = SET_TITLEBAR_HEIGHT_ID; int window; - ui::Rect titlebar_rect; + int height; }; } diff --git a/libui/src/Window.cpp b/libui/src/Window.cpp index 77670a46..18af4f3b 100644 --- a/libui/src/Window.cpp +++ b/libui/src/Window.cpp @@ -59,8 +59,8 @@ namespace ui window->m_titlebar_canvas = canvas.subcanvas(ui::Rect { 0, 0, canvas.width, height }); window->m_window_canvas = canvas.subcanvas(ui::Rect { 0, height, canvas.width, canvas.height - height }); - ui::SetTitlebarRectRequest titlebar_request; - titlebar_request.titlebar_rect = window->m_titlebar_canvas.rect(); + ui::SetTitlebarHeightRequest titlebar_request; + titlebar_request.height = height; titlebar_request.window = response.window; App::the().client().send_async(titlebar_request); } diff --git a/wind/IPC.cpp b/wind/IPC.cpp index 39bc978d..142d582a 100644 --- a/wind/IPC.cpp +++ b/wind/IPC.cpp @@ -139,25 +139,24 @@ static Result handle_get_screen_rect_message(Client& client) return {}; } -static Result handle_set_titlebar_rect_message(Client& client) +static Result handle_set_titlebar_height_message(Client& client) { - ui::SetTitlebarRectRequest request; + ui::SetTitlebarHeightRequest request; if (!TRY(client.conn->read_message(request))) return {}; - request.titlebar_rect = request.titlebar_rect.normalized(); + if (request.height < 0) request.height = 0; CHECK_WINDOW_ID(request); auto* window = client.windows[request.window]; - ui::Rect titlebar_rect = window->surface.absolute(request.titlebar_rect); - if (!window->surface.contains(titlebar_rect)) + if (request.height > window->surface.height) { - os::eprintln("wind: SetTitlebarRect: titlebar rect outside window!"); + os::eprintln("wind: SetTitlebarHeight: titlebar height bigger than window!"); return {}; } - window->titlebar = request.titlebar_rect; + window->titlebar = ui::Rect { 0, 0, window->surface.width, request.height }; return {}; } @@ -174,7 +173,7 @@ namespace wind case ui::INVALIDATE_ID: handle_invalidate_message(client); break; case ui::CLOSE_WINDOW_ID: handle_close_window_message(client); break; case ui::GET_SCREEN_RECT_ID: handle_get_screen_rect_message(client); break; - case ui::SET_TITLEBAR_RECT_ID: handle_set_titlebar_rect_message(client); break; + case ui::SET_TITLEBAR_HEIGHT_ID: handle_set_titlebar_height_message(client); break; default: os::eprintln("wind: Invalid IPC message from client!"); return; } }