2019-01-20 06:49:48 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-10 18:30:34 +03:00
|
|
|
#include <LibCore/CEventLoop.h>
|
2019-02-15 11:14:21 +03:00
|
|
|
#include <WindowServer/WSAPITypes.h>
|
2019-03-02 12:04:49 +03:00
|
|
|
#include <LibGUI/GEvent.h>
|
2019-01-20 06:49:48 +03:00
|
|
|
|
2019-03-02 12:04:49 +03:00
|
|
|
class GAction;
|
2019-04-10 18:01:54 +03:00
|
|
|
class CObject;
|
2019-04-10 18:35:43 +03:00
|
|
|
class CNotifier;
|
2019-01-20 07:48:43 +03:00
|
|
|
class GWindow;
|
2019-01-20 06:49:48 +03:00
|
|
|
|
2019-04-10 18:30:34 +03:00
|
|
|
class GEventLoop final : public CEventLoop {
|
2019-01-20 06:49:48 +03:00
|
|
|
public:
|
|
|
|
GEventLoop();
|
2019-04-10 18:30:34 +03:00
|
|
|
virtual ~GEventLoop() override;
|
2019-01-20 06:49:48 +03:00
|
|
|
|
2019-04-10 18:30:34 +03:00
|
|
|
static GEventLoop& current() { return static_cast<GEventLoop&>(CEventLoop::current()); }
|
2019-02-05 12:31:37 +03:00
|
|
|
|
2019-03-21 17:54:19 +03:00
|
|
|
static bool post_message_to_server(const WSAPI_ClientMessage&);
|
2019-02-15 11:17:18 +03:00
|
|
|
bool wait_for_specific_event(WSAPI_ServerMessage::Type, WSAPI_ServerMessage&);
|
|
|
|
WSAPI_ServerMessage sync_request(const WSAPI_ClientMessage& request, WSAPI_ServerMessage::Type response_type);
|
2019-02-13 19:54:30 +03:00
|
|
|
|
2019-03-17 06:23:54 +03:00
|
|
|
static pid_t server_pid() { return s_server_pid; }
|
2019-02-20 23:59:13 +03:00
|
|
|
|
2019-04-10 18:30:34 +03:00
|
|
|
virtual void take_pending_events_from(CEventLoop& other) override
|
2019-03-19 02:01:02 +03:00
|
|
|
{
|
2019-04-10 18:30:34 +03:00
|
|
|
CEventLoop::take_pending_events_from(other);
|
|
|
|
m_unprocessed_messages.append(move(static_cast<GEventLoop&>(other).m_unprocessed_messages));
|
2019-03-19 02:01:02 +03:00
|
|
|
}
|
|
|
|
|
2019-01-20 06:49:48 +03:00
|
|
|
private:
|
2019-04-10 18:30:34 +03:00
|
|
|
virtual void add_file_descriptors_for_select(fd_set& fds, int& max_fd_added) override
|
|
|
|
{
|
|
|
|
FD_SET(s_event_fd, &fds);
|
|
|
|
max_fd_added = s_event_fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void process_file_descriptors_after_select(const fd_set& fds) override
|
|
|
|
{
|
|
|
|
if (FD_ISSET(s_event_fd, &fds))
|
|
|
|
drain_messages_from_server();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void do_processing() override
|
|
|
|
{
|
|
|
|
process_unprocessed_messages();
|
|
|
|
}
|
|
|
|
|
2019-01-20 07:48:43 +03:00
|
|
|
void wait_for_event();
|
2019-02-13 19:59:38 +03:00
|
|
|
bool drain_messages_from_server();
|
2019-02-20 23:59:13 +03:00
|
|
|
void process_unprocessed_messages();
|
2019-02-15 11:17:18 +03:00
|
|
|
void handle_paint_event(const WSAPI_ServerMessage&, GWindow&);
|
2019-02-20 17:34:55 +03:00
|
|
|
void handle_resize_event(const WSAPI_ServerMessage&, GWindow&);
|
2019-02-15 11:17:18 +03:00
|
|
|
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&);
|
2019-02-20 12:12:19 +03:00
|
|
|
void handle_window_entered_or_left_event(const WSAPI_ServerMessage&, GWindow&);
|
2019-04-04 02:44:35 +03:00
|
|
|
void handle_wm_event(const WSAPI_ServerMessage&, GWindow&);
|
2019-03-09 19:34:09 +03:00
|
|
|
void connect_to_server();
|
2019-02-01 05:50:06 +03:00
|
|
|
|
2019-02-15 11:17:18 +03:00
|
|
|
Vector<WSAPI_ServerMessage> m_unprocessed_messages;
|
2019-03-09 19:34:09 +03:00
|
|
|
static pid_t s_server_pid;
|
|
|
|
static pid_t s_event_fd;
|
2019-01-20 06:49:48 +03:00
|
|
|
};
|