1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +00:00
serenity/WindowServer/WSEventLoop.h
Andreas Kling 4fef895eda Rework WindowServer to use select() in its main event loop.
The system can finally idle without burning CPU. :^)

There are some issues with scheduling making the mouse cursor sloppy
and unresponsive that need to be dealt with.
2019-01-16 17:20:58 +01:00

45 lines
862 B
C++

#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 };
};