1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:08:12 +00:00

Rename GUI_Event to GUI_ServerMessage.

Now that communication is becoming bidirectional, "event" is no longer right.
This commit is contained in:
Andreas Kling 2019-02-13 17:59:38 +01:00
parent 4f98a35beb
commit fbbf57b61c
12 changed files with 92 additions and 92 deletions

View file

@ -23,13 +23,13 @@ bool GUIEventDevice::can_read(Process& process) const
ssize_t GUIEventDevice::read(Process& process, byte* buffer, size_t size) ssize_t GUIEventDevice::read(Process& process, byte* buffer, size_t size)
{ {
#ifdef GUIEVENTDEVICE_DEBUG #ifdef GUIEVENTDEVICE_DEBUG
dbgprintf("GUIEventDevice::read(): %s<%u>, size=%u, sizeof(GUI_Event)=%u\n", process.name().characters(), process.pid(), size, sizeof(GUI_Event)); dbgprintf("GUIEventDevice::read(): %s<%u>, size=%u, sizeof(GUI_ServerMessage)=%u\n", process.name().characters(), process.pid(), size, sizeof(GUI_ServerMessage));
#endif #endif
if (process.gui_events().is_empty()) if (process.gui_events().is_empty())
return 0; return 0;
LOCKER(process.gui_events_lock()); LOCKER(process.gui_events_lock());
ASSERT(size == sizeof(GUI_Event)); ASSERT(size == sizeof(GUI_ServerMessage));
*reinterpret_cast<GUI_Event*>(buffer) = process.gui_events().take_first(); *reinterpret_cast<GUI_ServerMessage*>(buffer) = process.gui_events().take_first();
return size; return size;
} }

View file

@ -55,7 +55,7 @@ struct GUI_KeyModifiers { enum {
}; }; }; };
struct GUI_Event { struct GUI_ServerMessage {
enum Type : unsigned { enum Type : unsigned {
Invalid, Invalid,
Paint, Paint,

View file

@ -301,7 +301,7 @@ public:
bool is_root() const { return m_euid == 0; } bool is_root() const { return m_euid == 0; }
Vector<GUI_Event>& gui_events() { return m_gui_events; } Vector<GUI_ServerMessage>& gui_events() { return m_gui_events; }
Lock& gui_events_lock() { return m_gui_events_lock; } Lock& gui_events_lock() { return m_gui_events_lock; }
bool wakeup_requested() { return m_wakeup_requested; } bool wakeup_requested() { return m_wakeup_requested; }
@ -417,7 +417,7 @@ private:
HashMap<int, OwnPtr<WSWindow>> m_windows; HashMap<int, OwnPtr<WSWindow>> m_windows;
Vector<RetainPtr<GraphicsBitmap>> m_retained_backing_stores; Vector<RetainPtr<GraphicsBitmap>> m_retained_backing_stores;
Vector<GUI_Event> m_gui_events; Vector<GUI_ServerMessage> m_gui_events;
Lock m_gui_events_lock; Lock m_gui_events_lock;
int m_next_window_id { 1 }; int m_next_window_id { 1 };

View file

@ -93,7 +93,7 @@ void GEventLoop::post_event(GObject* receiver, OwnPtr<GEvent>&& event)
m_queued_events.append({ receiver, move(event) }); m_queued_events.append({ receiver, move(event) });
} }
void GEventLoop::handle_paint_event(const GUI_Event& event, GWindow& window) void GEventLoop::handle_paint_event(const GUI_ServerMessage& event, GWindow& window)
{ {
#ifdef GEVENTLOOP_DEBUG #ifdef GEVENTLOOP_DEBUG
dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height); dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height);
@ -101,25 +101,25 @@ void GEventLoop::handle_paint_event(const GUI_Event& event, GWindow& window)
post_event(&window, make<GPaintEvent>(event.paint.rect)); post_event(&window, make<GPaintEvent>(event.paint.rect));
} }
void GEventLoop::handle_window_activation_event(const GUI_Event& event, GWindow& window) void GEventLoop::handle_window_activation_event(const GUI_ServerMessage& event, GWindow& window)
{ {
#ifdef GEVENTLOOP_DEBUG #ifdef GEVENTLOOP_DEBUG
dbgprintf("WID=%x WindowActivation\n", event.window_id); dbgprintf("WID=%x WindowActivation\n", event.window_id);
#endif #endif
post_event(&window, make<GEvent>(event.type == GUI_Event::Type::WindowActivated ? GEvent::WindowBecameActive : GEvent::WindowBecameInactive)); post_event(&window, make<GEvent>(event.type == GUI_ServerMessage::Type::WindowActivated ? GEvent::WindowBecameActive : GEvent::WindowBecameInactive));
} }
void GEventLoop::handle_window_close_request_event(const GUI_Event&, GWindow& window) void GEventLoop::handle_window_close_request_event(const GUI_ServerMessage&, GWindow& window)
{ {
post_event(&window, make<GEvent>(GEvent::WindowCloseRequest)); post_event(&window, make<GEvent>(GEvent::WindowCloseRequest));
} }
void GEventLoop::handle_key_event(const GUI_Event& event, GWindow& window) void GEventLoop::handle_key_event(const GUI_ServerMessage& event, GWindow& window)
{ {
#ifdef GEVENTLOOP_DEBUG #ifdef GEVENTLOOP_DEBUG
dbgprintf("WID=%x KeyEvent character=0x%b\n", event.window_id, event.key.character); dbgprintf("WID=%x KeyEvent character=0x%b\n", event.window_id, event.key.character);
#endif #endif
auto key_event = make<GKeyEvent>(event.type == GUI_Event::Type::KeyDown ? GEvent::KeyDown : GEvent::KeyUp, event.key.key); auto key_event = make<GKeyEvent>(event.type == GUI_ServerMessage::Type::KeyDown ? GEvent::KeyDown : GEvent::KeyUp, event.key.key);
key_event->m_alt = event.key.alt; key_event->m_alt = event.key.alt;
key_event->m_ctrl = event.key.ctrl; key_event->m_ctrl = event.key.ctrl;
key_event->m_shift = event.key.shift; key_event->m_shift = event.key.shift;
@ -128,16 +128,16 @@ void GEventLoop::handle_key_event(const GUI_Event& event, GWindow& window)
post_event(&window, move(key_event)); post_event(&window, move(key_event));
} }
void GEventLoop::handle_mouse_event(const GUI_Event& event, GWindow& window) void GEventLoop::handle_mouse_event(const GUI_ServerMessage& event, GWindow& window)
{ {
#ifdef GEVENTLOOP_DEBUG #ifdef GEVENTLOOP_DEBUG
dbgprintf("WID=%x MouseEvent %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); dbgprintf("WID=%x MouseEvent %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y);
#endif #endif
GMouseEvent::Type type; GMouseEvent::Type type;
switch (event.type) { switch (event.type) {
case GUI_Event::Type::MouseMove: type = GEvent::MouseMove; break; case GUI_ServerMessage::Type::MouseMove: type = GEvent::MouseMove; break;
case GUI_Event::Type::MouseUp: type = GEvent::MouseUp; break; case GUI_ServerMessage::Type::MouseUp: type = GEvent::MouseUp; break;
case GUI_Event::Type::MouseDown: type = GEvent::MouseDown; break; case GUI_ServerMessage::Type::MouseDown: type = GEvent::MouseDown; break;
default: ASSERT_NOT_REACHED(); break; default: ASSERT_NOT_REACHED(); break;
} }
GMouseButton button { GMouseButton::None }; GMouseButton button { GMouseButton::None };
@ -151,9 +151,9 @@ void GEventLoop::handle_mouse_event(const GUI_Event& event, GWindow& window)
post_event(&window, make<GMouseEvent>(type, event.mouse.position, event.mouse.buttons, button)); post_event(&window, make<GMouseEvent>(type, event.mouse.position, event.mouse.buttons, button));
} }
void GEventLoop::handle_menu_event(const GUI_Event& event) void GEventLoop::handle_menu_event(const GUI_ServerMessage& event)
{ {
if (event.type == GUI_Event::Type::MenuItemActivated) { if (event.type == GUI_ServerMessage::Type::MenuItemActivated) {
auto* menu = GMenu::from_menu_id(event.menu.menu_id); auto* menu = GMenu::from_menu_id(event.menu.menu_id);
if (!menu) { if (!menu) {
dbgprintf("GEventLoop received event for invalid window ID %d\n", event.window_id); dbgprintf("GEventLoop received event for invalid window ID %d\n", event.window_id);
@ -228,13 +228,13 @@ void GEventLoop::wait_for_event()
if (!FD_ISSET(m_event_fd, &rfds)) if (!FD_ISSET(m_event_fd, &rfds))
return; return;
bool success = drain_events_from_server(); bool success = drain_messages_from_server();
ASSERT(success); ASSERT(success);
auto unprocessed_events = move(m_unprocessed_events); auto unprocessed_events = move(m_unprocessed_messages);
for (auto& event : unprocessed_events) { for (auto& event : unprocessed_events) {
switch (event.type) { switch (event.type) {
case GUI_Event::MenuItemActivated: case GUI_ServerMessage::MenuItemActivated:
handle_menu_event(event); handle_menu_event(event);
continue; continue;
default: default:
@ -247,23 +247,23 @@ void GEventLoop::wait_for_event()
continue; continue;
} }
switch (event.type) { switch (event.type) {
case GUI_Event::Type::Paint: case GUI_ServerMessage::Type::Paint:
handle_paint_event(event, *window); handle_paint_event(event, *window);
break; break;
case GUI_Event::Type::MouseDown: case GUI_ServerMessage::Type::MouseDown:
case GUI_Event::Type::MouseUp: case GUI_ServerMessage::Type::MouseUp:
case GUI_Event::Type::MouseMove: case GUI_ServerMessage::Type::MouseMove:
handle_mouse_event(event, *window); handle_mouse_event(event, *window);
break; break;
case GUI_Event::Type::WindowActivated: case GUI_ServerMessage::Type::WindowActivated:
case GUI_Event::Type::WindowDeactivated: case GUI_ServerMessage::Type::WindowDeactivated:
handle_window_activation_event(event, *window); handle_window_activation_event(event, *window);
break; break;
case GUI_Event::Type::WindowCloseRequest: case GUI_ServerMessage::Type::WindowCloseRequest:
handle_window_close_request_event(event, *window); handle_window_close_request_event(event, *window);
break; break;
case GUI_Event::Type::KeyDown: case GUI_ServerMessage::Type::KeyDown:
case GUI_Event::Type::KeyUp: case GUI_ServerMessage::Type::KeyUp:
handle_key_event(event, *window); handle_key_event(event, *window);
break; break;
default: default:
@ -272,11 +272,11 @@ void GEventLoop::wait_for_event()
} }
} }
bool GEventLoop::drain_events_from_server() bool GEventLoop::drain_messages_from_server()
{ {
for (;;) { for (;;) {
GUI_Event event; GUI_ServerMessage message;
ssize_t nread = read(m_event_fd, &event, sizeof(GUI_Event)); ssize_t nread = read(m_event_fd, &message, sizeof(GUI_ServerMessage));
if (nread < 0) { if (nread < 0) {
perror("read"); perror("read");
exit(1); exit(1);
@ -284,8 +284,8 @@ bool GEventLoop::drain_events_from_server()
} }
if (nread == 0) if (nread == 0)
return true; return true;
assert(nread == sizeof(event)); assert(nread == sizeof(message));
m_unprocessed_events.append(move(event)); m_unprocessed_messages.append(move(message));
} }
} }
@ -355,28 +355,28 @@ bool GEventLoop::post_message_to_server(const GUI_ClientMessage& message)
return nwritten == sizeof(GUI_ClientMessage); return nwritten == sizeof(GUI_ClientMessage);
} }
bool GEventLoop::wait_for_specific_event(GUI_Event::Type type, GUI_Event& event) bool GEventLoop::wait_for_specific_event(GUI_ServerMessage::Type type, GUI_ServerMessage& event)
{ {
for (;;) { for (;;) {
bool success = drain_events_from_server(); bool success = drain_messages_from_server();
if (!success) if (!success)
return false; return false;
for (size_t i = 0; i < m_unprocessed_events.size(); ++i) { for (size_t i = 0; i < m_unprocessed_messages.size(); ++i) {
if (m_unprocessed_events[i].type == type) { if (m_unprocessed_messages[i].type == type) {
event = move(m_unprocessed_events[i]); event = move(m_unprocessed_messages[i]);
m_unprocessed_events.remove(i); m_unprocessed_messages.remove(i);
return true; return true;
} }
} }
} }
} }
GUI_Event GEventLoop::sync_request(const GUI_ClientMessage& request, GUI_Event::Type response_type) GUI_ServerMessage GEventLoop::sync_request(const GUI_ClientMessage& request, GUI_ServerMessage::Type response_type)
{ {
bool success = post_message_to_server(request); bool success = post_message_to_server(request);
ASSERT(success); ASSERT(success);
GUI_Event response; GUI_ServerMessage response;
success = GEventLoop::main().wait_for_specific_event(response_type, response); success = GEventLoop::main().wait_for_specific_event(response_type, response);
ASSERT(success); ASSERT(success);
return response; return response;

View file

@ -35,19 +35,19 @@ public:
void exit(int); void exit(int);
bool post_message_to_server(const GUI_ClientMessage&); bool post_message_to_server(const GUI_ClientMessage&);
bool wait_for_specific_event(GUI_Event::Type, GUI_Event&); bool wait_for_specific_event(GUI_ServerMessage::Type, GUI_ServerMessage&);
GUI_Event sync_request(const GUI_ClientMessage& request, GUI_Event::Type response_type); GUI_ServerMessage sync_request(const GUI_ClientMessage& request, GUI_ServerMessage::Type response_type);
private: private:
void wait_for_event(); void wait_for_event();
bool drain_events_from_server(); bool drain_messages_from_server();
void handle_paint_event(const GUI_Event&, GWindow&); void handle_paint_event(const GUI_ServerMessage&, GWindow&);
void handle_mouse_event(const GUI_Event&, GWindow&); void handle_mouse_event(const GUI_ServerMessage&, GWindow&);
void handle_key_event(const GUI_Event&, GWindow&); void handle_key_event(const GUI_ServerMessage&, GWindow&);
void handle_window_activation_event(const GUI_Event&, GWindow&); void handle_window_activation_event(const GUI_ServerMessage&, GWindow&);
void handle_window_close_request_event(const GUI_Event&, GWindow&); void handle_window_close_request_event(const GUI_ServerMessage&, GWindow&);
void handle_menu_event(const GUI_Event&); void handle_menu_event(const GUI_ServerMessage&);
void get_next_timer_expiration(timeval&); void get_next_timer_expiration(timeval&);
struct QueuedEvent { struct QueuedEvent {
@ -56,7 +56,7 @@ private:
}; };
Vector<QueuedEvent> m_queued_events; Vector<QueuedEvent> m_queued_events;
Vector<GUI_Event> m_unprocessed_events; Vector<GUI_ServerMessage> m_unprocessed_messages;
int m_event_fd { -1 }; int m_event_fd { -1 };
bool m_running { false }; bool m_running { false };

View file

@ -20,7 +20,7 @@ int GMenuBar::realize_menubar()
{ {
GUI_ClientMessage request; GUI_ClientMessage request;
request.type = GUI_ClientMessage::Type::CreateMenubar; request.type = GUI_ClientMessage::Type::CreateMenubar;
GUI_Event response = GEventLoop::main().sync_request(request, GUI_Event::Type::DidCreateMenubar); GUI_ServerMessage response = GEventLoop::main().sync_request(request, GUI_ServerMessage::Type::DidCreateMenubar);
return response.menu.menubar_id; return response.menu.menubar_id;
} }
@ -31,7 +31,7 @@ void GMenuBar::unrealize_menubar()
GUI_ClientMessage request; GUI_ClientMessage request;
request.type = GUI_ClientMessage::Type::DestroyMenubar; request.type = GUI_ClientMessage::Type::DestroyMenubar;
request.menu.menubar_id = m_menubar_id; request.menu.menubar_id = m_menubar_id;
GEventLoop::main().sync_request(request, GUI_Event::Type::DidDestroyMenubar); GEventLoop::main().sync_request(request, GUI_ServerMessage::Type::DidDestroyMenubar);
m_menubar_id = 0; m_menubar_id = 0;
} }

View file

@ -51,30 +51,30 @@ int main(int argc, char** argv)
} }
for (;;) { for (;;) {
GUI_Event event; GUI_ServerMessage message;
ssize_t nread = read(fd, &event, sizeof(event)); ssize_t nread = read(fd, &message, sizeof(message));
if (nread < 0) { if (nread < 0) {
perror("read"); perror("read");
return 1; return 1;
} }
dbgprintf("(%d) ", getpid()); dbgprintf("(%d) ", getpid());
assert(nread == sizeof(event)); assert(nread == sizeof(message));
switch (event.type) { switch (message.type) {
case GUI_Event::Type::Paint: dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height); break; case GUI_ServerMessage::Type::Paint: dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", message.window_id, message.paint.rect.location.x, message.paint.rect.location.y, message.paint.rect.size.width, message.paint.rect.size.height); break;
case GUI_Event::Type::MouseDown: dbgprintf("WID=%x MouseDown %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break; case GUI_ServerMessage::Type::MouseDown: dbgprintf("WID=%x MouseDown %d,%d\n", message.window_id, message.mouse.position.x, message.mouse.position.y); break;
case GUI_Event::Type::MouseUp: dbgprintf("WID=%x MouseUp %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break; case GUI_ServerMessage::Type::MouseUp: dbgprintf("WID=%x MouseUp %d,%d\n", message.window_id, message.mouse.position.x, message.mouse.position.y); break;
case GUI_Event::Type::MouseMove: dbgprintf("WID=%x MouseMove %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break; case GUI_ServerMessage::Type::MouseMove: dbgprintf("WID=%x MouseMove %d,%d\n", message.window_id, message.mouse.position.x, message.mouse.position.y); break;
case GUI_Event::Type::WindowActivated: dbgprintf("WID=%x WindowActivated\n", event.window_id); break; case GUI_ServerMessage::Type::WindowActivated: dbgprintf("WID=%x WindowActivated\n", message.window_id); break;
case GUI_Event::Type::WindowDeactivated: dbgprintf("WID=%x WindowDeactivated\n", event.window_id); break; case GUI_ServerMessage::Type::WindowDeactivated: dbgprintf("WID=%x WindowDeactivated\n", message.window_id); break;
case GUI_Event::Type::WindowCloseRequest: return 0; case GUI_ServerMessage::Type::WindowCloseRequest: return 0;
} }
if (event.type == GUI_Event::Type::Paint) { if (message.type == GUI_ServerMessage::Type::Paint) {
paint(*bitmap, backing.size.width, backing.size.height); paint(*bitmap, backing.size.width, backing.size.height);
gui_notify_paint_finished(window_id, nullptr); gui_notify_paint_finished(window_id, nullptr);
} }
if (event.type == GUI_Event::Type::MouseDown) { if (message.type == GUI_ServerMessage::Type::MouseDown) {
gui_invalidate_window(window_id, nullptr); gui_invalidate_window(window_id, nullptr);
} }

View file

@ -140,8 +140,8 @@ void WSMenu::did_activate(WSMenuItem& item)
close(); close();
GUI_Event gui_event; GUI_ServerMessage gui_event;
gui_event.type = GUI_Event::Type::MenuItemActivated; gui_event.type = GUI_ServerMessage::Type::MenuItemActivated;
gui_event.menu.menu_id = m_menu_id; gui_event.menu.menu_id = m_menu_id;
gui_event.menu.identifier = item.identifier(); gui_event.menu.identifier = item.identifier();

View file

@ -73,7 +73,7 @@ Process* WSMessageLoop::process_from_client_id(int client_id)
return (Process*)client_id; return (Process*)client_id;
} }
void WSMessageLoop::post_message_to_client(int client_id, const GUI_Event& message) void WSMessageLoop::post_message_to_client(int client_id, const GUI_ServerMessage& message)
{ {
auto* process = process_from_client_id(client_id); auto* process = process_from_client_id(client_id);
if (!process) if (!process)

View file

@ -9,7 +9,7 @@
class WSMessageReceiver; class WSMessageReceiver;
class Process; class Process;
struct GUI_Event; struct GUI_ServerMessage;
class WSMessageLoop { class WSMessageLoop {
public: public:
@ -30,7 +30,7 @@ public:
int start_timer(int ms, Function<void()>&&); int start_timer(int ms, Function<void()>&&);
int stop_timer(int timer_id); int stop_timer(int timer_id);
void post_message_to_client(int client_id, const GUI_Event&); void post_message_to_client(int client_id, const GUI_ServerMessage&);
ssize_t on_receive_from_client(int client_id, const byte*, size_t); ssize_t on_receive_from_client(int client_id, const byte*, size_t);
static Process* process_from_client_id(int client_id); static Process* process_from_client_id(int client_id);

View file

@ -79,34 +79,34 @@ void WSWindow::on_message(WSMessage& message)
return; return;
} }
GUI_Event gui_event; GUI_ServerMessage gui_event;
gui_event.window_id = window_id(); gui_event.window_id = window_id();
switch (message.type()) { switch (message.type()) {
case WSMessage::WM_ClientWantsToPaint: case WSMessage::WM_ClientWantsToPaint:
gui_event.type = GUI_Event::Type::Paint; gui_event.type = GUI_ServerMessage::Type::Paint;
gui_event.paint.rect = static_cast<WSClientWantsToPaintMessage&>(message).rect(); gui_event.paint.rect = static_cast<WSClientWantsToPaintMessage&>(message).rect();
break; break;
case WSMessage::MouseMove: case WSMessage::MouseMove:
gui_event.type = GUI_Event::Type::MouseMove; gui_event.type = GUI_ServerMessage::Type::MouseMove;
gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position(); gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position();
gui_event.mouse.button = GUI_MouseButton::NoButton; gui_event.mouse.button = GUI_MouseButton::NoButton;
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons(); gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons();
break; break;
case WSMessage::MouseDown: case WSMessage::MouseDown:
gui_event.type = GUI_Event::Type::MouseDown; gui_event.type = GUI_ServerMessage::Type::MouseDown;
gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position(); gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position();
gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(message).button()); gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(message).button());
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons(); gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons();
break; break;
case WSMessage::MouseUp: case WSMessage::MouseUp:
gui_event.type = GUI_Event::Type::MouseUp; gui_event.type = GUI_ServerMessage::Type::MouseUp;
gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position(); gui_event.mouse.position = static_cast<WSMouseEvent&>(message).position();
gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(message).button()); gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(message).button());
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons(); gui_event.mouse.buttons = static_cast<WSMouseEvent&>(message).buttons();
break; break;
case WSMessage::KeyDown: case WSMessage::KeyDown:
gui_event.type = GUI_Event::Type::KeyDown; gui_event.type = GUI_ServerMessage::Type::KeyDown;
gui_event.key.character = static_cast<WSKeyEvent&>(message).character(); gui_event.key.character = static_cast<WSKeyEvent&>(message).character();
gui_event.key.key = static_cast<WSKeyEvent&>(message).key(); gui_event.key.key = static_cast<WSKeyEvent&>(message).key();
gui_event.key.alt = static_cast<WSKeyEvent&>(message).alt(); gui_event.key.alt = static_cast<WSKeyEvent&>(message).alt();
@ -114,7 +114,7 @@ void WSWindow::on_message(WSMessage& message)
gui_event.key.shift = static_cast<WSKeyEvent&>(message).shift(); gui_event.key.shift = static_cast<WSKeyEvent&>(message).shift();
break; break;
case WSMessage::KeyUp: case WSMessage::KeyUp:
gui_event.type = GUI_Event::Type::KeyUp; gui_event.type = GUI_ServerMessage::Type::KeyUp;
gui_event.key.character = static_cast<WSKeyEvent&>(message).character(); gui_event.key.character = static_cast<WSKeyEvent&>(message).character();
gui_event.key.key = static_cast<WSKeyEvent&>(message).key(); gui_event.key.key = static_cast<WSKeyEvent&>(message).key();
gui_event.key.alt = static_cast<WSKeyEvent&>(message).alt(); gui_event.key.alt = static_cast<WSKeyEvent&>(message).alt();
@ -134,19 +134,19 @@ void WSWindow::on_message(WSMessage& message)
delete this; delete this;
return; return;
case WSMessage::WindowActivated: case WSMessage::WindowActivated:
gui_event.type = GUI_Event::Type::WindowActivated; gui_event.type = GUI_ServerMessage::Type::WindowActivated;
break; break;
case WSMessage::WindowDeactivated: case WSMessage::WindowDeactivated:
gui_event.type = GUI_Event::Type::WindowDeactivated; gui_event.type = GUI_ServerMessage::Type::WindowDeactivated;
break; break;
case WSMessage::WindowCloseRequest: case WSMessage::WindowCloseRequest:
gui_event.type = GUI_Event::Type::WindowCloseRequest; gui_event.type = GUI_ServerMessage::Type::WindowCloseRequest;
break; break;
default: default:
break; break;
} }
if (gui_event.type == GUI_Event::Type::Invalid) if (gui_event.type == GUI_ServerMessage::Type::Invalid)
return; return;
{ {

View file

@ -741,10 +741,10 @@ void WSWindowManager::on_message(WSMessage& message)
int menubar_id = m_next_menubar_id++; int menubar_id = m_next_menubar_id++;
auto menubar = make<WSMenuBar>(menubar_id, *WSMessageLoop::process_from_client_id(request.client_id())); auto menubar = make<WSMenuBar>(menubar_id, *WSMessageLoop::process_from_client_id(request.client_id()));
m_menubars.set(menubar_id, move(menubar)); m_menubars.set(menubar_id, move(menubar));
GUI_Event event; GUI_ServerMessage response;
event.type = GUI_Event::Type::DidCreateMenubar; response.type = GUI_ServerMessage::Type::DidCreateMenubar;
event.menu.menubar_id = menubar_id; response.menu.menubar_id = menubar_id;
WSMessageLoop::the().post_message_to_client(request.client_id(), event); WSMessageLoop::the().post_message_to_client(request.client_id(), response);
break; break;
} }
case WSMessage::APIDestroyMenubarRequest: { case WSMessage::APIDestroyMenubarRequest: {
@ -759,10 +759,10 @@ void WSWindowManager::on_message(WSMessage& message)
if (&menubar == m_current_menubar) if (&menubar == m_current_menubar)
set_current_menubar(nullptr); set_current_menubar(nullptr);
m_menubars.remove(it); m_menubars.remove(it);
GUI_Event event; GUI_ServerMessage response;
event.type = GUI_Event::Type::DidDestroyMenubar; response.type = GUI_ServerMessage::Type::DidDestroyMenubar;
event.menu.menubar_id = menubar_id; response.menu.menubar_id = menubar_id;
WSMessageLoop::the().post_message_to_client(request.client_id(), event); WSMessageLoop::the().post_message_to_client(request.client_id(), response);
} }
default: default:
break; break;