mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +00:00
WindowServer+LibGUI: Notify GUI clients about menu item enter/leave
We now send out MenuItemEntered and MenuItemLeft messages to the client when the user hovers/unhovers menu items. On the client side, these become GUI::ActionEvent, with one of two types: ActionEnter or ActionLeave. They are sent to the Application. This will allow GUI applications to react to these events.
This commit is contained in:
parent
f8c2beec7c
commit
ba7e1ca2fb
7 changed files with 91 additions and 19 deletions
|
@ -273,6 +273,38 @@ void WindowServerConnection::handle(const Messages::WindowClient::MenuItemActiva
|
|||
action->activate(menu);
|
||||
}
|
||||
|
||||
void WindowServerConnection::handle(Messages::WindowClient::MenuItemEntered const& message)
|
||||
{
|
||||
auto* menu = Menu::from_menu_id(message.menu_id());
|
||||
if (!menu) {
|
||||
dbgln("WindowServerConnection received MenuItemEntered for invalid menu ID {}", message.menu_id());
|
||||
return;
|
||||
}
|
||||
auto* action = menu->action_at(message.identifier());
|
||||
if (!action)
|
||||
return;
|
||||
auto* app = Application::the();
|
||||
if (!app)
|
||||
return;
|
||||
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionEnter, *action));
|
||||
}
|
||||
|
||||
void WindowServerConnection::handle(Messages::WindowClient::MenuItemLeft const& message)
|
||||
{
|
||||
auto* menu = Menu::from_menu_id(message.menu_id());
|
||||
if (!menu) {
|
||||
dbgln("WindowServerConnection received MenuItemLeft for invalid menu ID {}", message.menu_id());
|
||||
return;
|
||||
}
|
||||
auto* action = menu->action_at(message.identifier());
|
||||
if (!action)
|
||||
return;
|
||||
auto* app = Application::the();
|
||||
if (!app)
|
||||
return;
|
||||
Core::EventLoop::current().post_event(*app, make<ActionEvent>(GUI::Event::ActionLeave, *action));
|
||||
}
|
||||
|
||||
void WindowServerConnection::handle(const Messages::WindowClient::ScreenRectChanged& message)
|
||||
{
|
||||
Desktop::the().did_receive_screen_rect({}, message.rect());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue