ladybird/WindowServer/WSMessageLoop.h
Andreas Kling 26230c0647 WindowServer: Remove "unsafe" flag in WSMessageLoop::post_event().
This hack is no longer needed now that we have a Finalizer process that can
take locks without having to worry about the interrupt flag.
2019-02-11 13:05:51 +01:00

46 lines
939 B
C++

#pragma once
#include "WSMessage.h"
#include <AK/Lock.h>
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
class WSMessageReceiver;
class Process;
class WSMessageLoop {
public:
WSMessageLoop();
~WSMessageLoop();
int exec();
void post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&&);
static WSMessageLoop& the();
bool running() const { return m_running; }
Process& server_process() { return *m_server_process; }
void set_server_process(Process& process) { m_server_process = &process; }
private:
void wait_for_message();
void drain_mouse();
void drain_keyboard();
Lock m_lock;
struct QueuedMessage {
WSMessageReceiver* receiver { nullptr };
OwnPtr<WSMessage> message;
};
Vector<QueuedMessage> m_queued_messages;
Process* m_server_process { nullptr };
bool m_running { false };
int m_keyboard_fd { -1 };
int m_mouse_fd { -1 };
};