wind+libui: Rename SetTitlebarRect to SetTitlebarHeight
We only need the height to be customizable.
This commit is contained in:
parent
b8470f753b
commit
b9ccda132a
@ -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;
|
||||
};
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
15
wind/IPC.cpp
15
wind/IPC.cpp
@ -139,25 +139,24 @@ static Result<void> handle_get_screen_rect_message(Client& client)
|
||||
return {};
|
||||
}
|
||||
|
||||
static Result<void> handle_set_titlebar_rect_message(Client& client)
|
||||
static Result<void> 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user