2019-01-20 04:49:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GEvent.h"
|
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
class GObject;
|
2019-01-20 05:48:43 +01:00
|
|
|
class GWindow;
|
|
|
|
struct GUI_Event;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
|
|
|
class GEventLoop {
|
|
|
|
public:
|
|
|
|
GEventLoop();
|
|
|
|
~GEventLoop();
|
|
|
|
|
|
|
|
int exec();
|
|
|
|
|
2019-01-20 05:48:43 +01:00
|
|
|
void post_event(GObject* receiver, OwnPtr<GEvent>&&);
|
2019-01-20 04:49:48 +01:00
|
|
|
|
|
|
|
static GEventLoop& main();
|
|
|
|
|
|
|
|
static void initialize();
|
|
|
|
|
|
|
|
bool running() const { return m_running; }
|
|
|
|
|
|
|
|
private:
|
2019-01-20 05:48:43 +01:00
|
|
|
void wait_for_event();
|
|
|
|
void handle_paint_event(const GUI_Event&, GWindow&);
|
|
|
|
void handle_mouse_event(const GUI_Event&, GWindow&);
|
2019-01-26 06:39:13 +01:00
|
|
|
void handle_key_event(const GUI_Event&, GWindow&);
|
2019-01-26 21:58:43 +01:00
|
|
|
void handle_window_activation_event(const GUI_Event&, GWindow&);
|
2019-01-20 04:49:48 +01:00
|
|
|
|
|
|
|
struct QueuedEvent {
|
|
|
|
GObject* receiver { nullptr };
|
|
|
|
OwnPtr<GEvent> event;
|
|
|
|
};
|
2019-01-20 05:48:43 +01:00
|
|
|
Vector<QueuedEvent> m_queued_events;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2019-01-20 05:48:43 +01:00
|
|
|
int m_event_fd { -1 };
|
2019-01-20 04:49:48 +01:00
|
|
|
bool m_running { false };
|
|
|
|
};
|