mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibGUI+WindowServer: Add support for per-GWidget context menus.
You can now simply assign a GMenu as a GWidget's context menu and it will automagically pop up on right click. :^)
This commit is contained in:
@@ -39,6 +39,17 @@ void GMenu::add_separator()
|
||||
m_items.append(make<GMenuItem>(m_menu_id, GMenuItem::Separator));
|
||||
}
|
||||
|
||||
void GMenu::popup(const Point& screen_position)
|
||||
{
|
||||
if (!m_menu_id)
|
||||
realize_menu();
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::PopupMenu;
|
||||
request.menu.menu_id = m_menu_id;
|
||||
request.menu.position = screen_position;
|
||||
GEventLoop::post_message_to_server(request);
|
||||
}
|
||||
|
||||
int GMenu::realize_menu()
|
||||
{
|
||||
WSAPI_ClientMessage request;
|
||||
|
||||
Reference in New Issue
Block a user