summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GEventLoop.h
blob: 3358f30207a4b2aaded8809bd4d86529befa9b6b (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 <LibCore/CEventLoop.h>
#include <LibCore/CoreIPCClient.h>
#include <LibGUI/GEvent.h>
#include <WindowServer/WSAPITypes.h>

class GAction;
class CObject;
class CNotifier;
class GWindow;

class GWindowServerConnection : public IPC::Client::Connection<WSAPI_ServerMessage, WSAPI_ClientMessage> {
public:
    GWindowServerConnection()
        : Connection("/tmp/wsportal")
    {}

    void handshake() override;
    static GWindowServerConnection& the();

private:
    void postprocess_bundles(Vector<IncomingMessageBundle>& m_unprocessed_bundles) override;
    void handle_paint_event(const WSAPI_ServerMessage&, GWindow&, const ByteBuffer& extra_data);
    void handle_resize_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_mouse_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_key_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_window_activation_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_window_close_request_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_menu_event(const WSAPI_ServerMessage&);
    void handle_window_entered_or_left_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_wm_event(const WSAPI_ServerMessage&, GWindow&);
    void handle_greeting(WSAPI_ServerMessage&);
};

class GEventLoop final : public CEventLoop {
public:
    GEventLoop();
    virtual ~GEventLoop() override;

    static GEventLoop& current() { return static_cast<GEventLoop&>(CEventLoop::current()); }

private:
    void process_unprocessed_bundles();
};