1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 14:25:08 +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:
Andreas Kling 2019-04-12 17:10:30 +02:00
parent 8feecf6c77
commit c06a3bdeb4
12 changed files with 102 additions and 8 deletions

View file

@ -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;