#pragma once #include "GEvent.h" #include #include class GObject; class GWindow; struct GUI_Event; class GEventLoop { public: GEventLoop(); ~GEventLoop(); int exec(); void post_event(GObject* receiver, OwnPtr&&); static GEventLoop& main(); static void initialize(); bool running() const { return m_running; } private: void wait_for_event(); void handle_paint_event(const GUI_Event&, GWindow&); void handle_mouse_event(const GUI_Event&, GWindow&); struct QueuedEvent { GObject* receiver { nullptr }; OwnPtr event; }; Vector m_queued_events; int m_event_fd { -1 }; bool m_running { false }; };