summaryrefslogtreecommitdiff
path: root/Servers/WindowServer/WSEventLoop.h
blob: e2073f47afdc7e08d98e7162d760f34cb6a11255 (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
#pragma once

#include "WSEvent.h"
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
#include <AK/Function.h>
#include <AK/WeakPtr.h>
#include <LibCore/CEventLoop.h>

class CObject;
struct WSAPI_ClientMessage;
struct WSAPI_ServerMessage;

class WSEventLoop : public CEventLoop {
public:
    WSEventLoop();
    virtual ~WSEventLoop() override;

    static WSEventLoop& the();

    void on_receive_from_client(int client_id, const WSAPI_ClientMessage&);
    void notify_client_disconnected(int client_id);

private:
    virtual void add_file_descriptors_for_select(fd_set&, int& max_fd_added) override;
    virtual void process_file_descriptors_after_select(const fd_set&) override;
    virtual void do_processing() override { }

    void drain_server();
    void drain_mouse();
    void drain_keyboard();

    int m_keyboard_fd { -1 };
    int m_mouse_fd { -1 };
    int m_server_fd { -1 };
};