mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 23:57:25 +00:00
LibGUI: Make GAction scoped to its CObject parent (widget or window)
Unparented GActions are still parented to the application like before, making them globally available. This makes it possible to have actions that work whenever a specific window is active, no matter which widget is currently focused. :^)
This commit is contained in:
@@ -136,20 +136,20 @@ void GWindowServerConnection::handle(const WindowClient::KeyDown& message)
|
||||
key_event->m_text = String(&ch, 1);
|
||||
}
|
||||
|
||||
if (auto* focused_widget = window->focused_widget()) {
|
||||
if (auto* action = focused_widget->action_for_key_event(*key_event)) {
|
||||
if (action->is_enabled()) {
|
||||
action->activate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
GAction* action = nullptr;
|
||||
|
||||
if (auto* action = GApplication::the().action_for_key_event(*key_event)) {
|
||||
if (action->is_enabled()) {
|
||||
action->activate();
|
||||
return;
|
||||
}
|
||||
if (auto* focused_widget = window->focused_widget())
|
||||
action = focused_widget->action_for_key_event(*key_event);
|
||||
|
||||
if (!action)
|
||||
action = window->action_for_key_event(*key_event);
|
||||
|
||||
if (!action)
|
||||
action = GApplication::the().action_for_key_event(*key_event);
|
||||
|
||||
if (action && action->is_enabled()) {
|
||||
action->activate();
|
||||
return;
|
||||
}
|
||||
CEventLoop::current().post_event(*window, move(key_event));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user