blob: e7695d8070aa7ec1ffc303d3e5239e45b7fcddc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#pragma once
#include "WSEvent.h"
#include <AK/Lock.h>
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
class WSEventReceiver;
class Process;
class WSEventLoop {
public:
WSEventLoop();
~WSEventLoop();
int exec();
void post_event(WSEventReceiver* receiver, OwnPtr<WSEvent>&&);
static WSEventLoop& the();
static void initialize();
bool running() const { return m_running; }
Process& server_process() { return *m_server_process; }
private:
void wait_for_event();
void drain_mouse();
void drain_keyboard();
SpinLock m_lock;
struct QueuedEvent {
WSEventReceiver* receiver { nullptr };
OwnPtr<WSEvent> event;
};
Vector<QueuedEvent> m_queued_events;
Process* m_server_process { nullptr };
bool m_running { false };
int m_keyboard_fd { -1 };
int m_mouse_fd { -1 };
};
|