1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +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:
Andreas Kling 2021-01-05 15:43:59 +01:00
parent 8b90e8d08b
commit 1c8eaf28cd
4 changed files with 31 additions and 3 deletions

View file

@ -29,6 +29,7 @@
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/String.h>
#include <AK/WeakPtr.h>
#include <LibCore/Object.h>
#include <LibGUI/Forward.h>
#include <LibGUI/Shortcut.h>
@ -76,6 +77,12 @@ public:
Core::EventLoop& event_loop() { return *m_event_loop; }
Window* active_window() { return m_active_window; }
const Window* active_window() const { return m_active_window; }
void window_did_become_active(Badge<Window>, Window&);
void window_did_become_inactive(Badge<Window>, Window&);
private:
Application(int argc, char** argv);
@ -92,6 +99,7 @@ private:
RefPtr<Core::Timer> m_tooltip_hide_timer;
RefPtr<TooltipWindow> m_tooltip_window;
RefPtr<Widget> m_tooltip_source_widget;
WeakPtr<Window> m_active_window;
bool m_quit_when_last_window_deleted { true };
bool m_focus_debugging_enabled { false };
String m_invoked_as;