mirror of
https://github.com/RGBCube/serenity
synced 2025-07-14 14:17:36 +00:00
LibGUI: Add GUI::Application::active_window()
Instead of each window having a bool flag that says whether that window is currently active, have a pointer to the active window on the app object instead.
This commit is contained in:
parent
8b90e8d08b
commit
1c8eaf28cd
4 changed files with 31 additions and 3 deletions
|
@ -405,7 +405,10 @@ void Window::handle_input_entered_or_left_event(Core::Event& event)
|
|||
|
||||
void Window::handle_became_active_or_inactive_event(Core::Event& event)
|
||||
{
|
||||
m_is_active = event.type() == Event::WindowBecameActive;
|
||||
if (event.type() == Event::WindowBecameActive)
|
||||
Application::the()->window_did_become_active({}, *this);
|
||||
else
|
||||
Application::the()->window_did_become_inactive({}, *this);
|
||||
if (m_main_widget)
|
||||
m_main_widget->dispatch_event(event, this);
|
||||
if (m_focused_widget)
|
||||
|
@ -941,4 +944,10 @@ void Window::did_disable_focused_widget(Badge<Widget>)
|
|||
focus_a_widget_if_possible(FocusSource::Mouse);
|
||||
}
|
||||
|
||||
bool Window::is_active() const
|
||||
{
|
||||
ASSERT(Application::the());
|
||||
return this == Application::the()->active_window();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue