1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:17:36 +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:
Andreas Kling 2020-02-02 01:57:57 +01:00
parent 6ab9dc4ff4
commit 5b47b0d867
8 changed files with 130 additions and 109 deletions

View file

@ -35,6 +35,8 @@
#include <LibDraw/Rect.h>
#include <LibGUI/GWindowType.h>
class GAction;
class GKeyEvent;
class GWMEvent;
class GWidget;
class GWindowServerConnection;
@ -170,6 +172,8 @@ public:
virtual bool is_visible_for_timer_purposes() const override { return m_visible_for_timer_purposes; }
GAction* action_for_key_event(const GKeyEvent&);
protected:
GWindow(CObject* parent = nullptr);
virtual void wm_event(GWMEvent&);
@ -210,3 +214,9 @@ private:
bool m_layout_pending { false };
bool m_visible_for_timer_purposes { true };
};
template<>
inline bool is<GWindow>(const CObject& object)
{
return object.is_window();
}