From bba21adae377c2b1f1876adb0f877f62cdb075e9 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 26 Jan 2019 05:28:02 +0100 Subject: [PATCH] WindowServer: Rename WSEvent to WSMessage. Also do the same for WSMessageLoop and WSMessageReceiver. More to come. --- Kernel/Makefile | 4 +- Kernel/ProcessGUI.cpp | 26 ++++----- SharedGraphics/GraphicsBitmap.cpp | 6 +- WindowServer/WSEventReceiver.cpp | 10 ---- WindowServer/WSEventReceiver.h | 13 ----- WindowServer/{WSEvent.h => WSMessage.h} | 56 ++++++------------- .../{WSEventLoop.cpp => WSMessageLoop.cpp} | 40 ++++++------- .../{WSEventLoop.h => WSMessageLoop.h} | 18 +++--- WindowServer/WSMessageReceiver.cpp | 10 ++++ WindowServer/WSMessageReceiver.h | 13 +++++ WindowServer/WSScreen.cpp | 20 +++---- WindowServer/WSWindow.cpp | 26 ++++----- WindowServer/WSWindow.h | 6 +- WindowServer/WSWindowManager.cpp | 22 ++++---- WindowServer/WSWindowManager.h | 6 +- WindowServer/main.cpp | 4 +- 16 files changed, 129 insertions(+), 151 deletions(-) delete mode 100644 WindowServer/WSEventReceiver.cpp delete mode 100644 WindowServer/WSEventReceiver.h rename WindowServer/{WSEvent.h => WSMessage.h} (72%) rename WindowServer/{WSEventLoop.cpp => WSMessageLoop.cpp} (82%) rename WindowServer/{WSEventLoop.h => WSMessageLoop.h} (65%) create mode 100644 WindowServer/WSMessageReceiver.cpp create mode 100644 WindowServer/WSMessageReceiver.h diff --git a/Kernel/Makefile b/Kernel/Makefile index c27dce62b07..e253c5b7c70 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -55,8 +55,8 @@ SHAREDGRAPHICS_OBJS = \ ../SharedGraphics/GraphicsBitmap.o WINDOWSERVER_OBJS = \ - ../WindowServer/WSEventReceiver.o \ - ../WindowServer/WSEventLoop.o \ + ../WindowServer/WSMessageReceiver.o \ + ../WindowServer/WSMessageLoop.o \ ../WindowServer/WSWindow.o \ ../WindowServer/WSWindowManager.o \ ../WindowServer/WSScreen.o \ diff --git a/Kernel/ProcessGUI.cpp b/Kernel/ProcessGUI.cpp index 45214106d6b..5b8e4928489 100644 --- a/Kernel/ProcessGUI.cpp +++ b/Kernel/ProcessGUI.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -12,11 +12,11 @@ void Process::initialize_gui_statics() { Font::initialize(); - WSEventLoop::initialize(); + WSMessageLoop::initialize(); WSWindowManager::initialize(); WSScreen::initialize(); - new WSEventLoop; + new WSMessageLoop; } int Process::make_window_id() @@ -33,7 +33,7 @@ int Process::make_window_id() static void wait_for_gui_server() { // FIXME: Time out after a while and return an error. - while (!WSEventLoop::the().running()) + while (!WSMessageLoop::the().running()) sleep(10); } @@ -50,7 +50,7 @@ int Process::gui$create_window(const GUI_WindowParameters* user_params) if (rect.is_empty()) return -EINVAL; - ProcessPagingScope scope(WSEventLoop::the().server_process()); + ProcessPagingScope scope(WSMessageLoop::the().server_process()); int window_id = make_window_id(); if (!window_id) @@ -145,8 +145,8 @@ int Process::gui$invalidate_window(int window_id, const GUI_Rect* a_rect) Rect rect; if (a_rect) rect = *a_rect; - WSEventLoop::the().post_event(&window, make(rect)); - WSEventLoop::the().server_process().request_wakeup(); + WSMessageLoop::the().post_event(&window, make(rect)); + WSMessageLoop::the().server_process().request_wakeup(); return 0; } @@ -169,8 +169,8 @@ int Process::gui$notify_paint_finished(int window_id, const GUI_Rect* a_rect) Rect rect; if (a_rect) rect = *a_rect; - WSEventLoop::the().post_event(&window, make(rect)); - WSEventLoop::the().server_process().request_wakeup(); + WSMessageLoop::the().post_event(&window, make(rect)); + WSMessageLoop::the().server_process().request_wakeup(); return 0; } @@ -207,8 +207,8 @@ int Process::gui$set_window_title(int window_id, const char* title, size_t size) return -EBADWINDOW; auto& window = *(*it).value; String new_title(title, size); - WSEventLoop::the().post_event(&window, make(move(new_title))); - WSEventLoop::the().server_process().request_wakeup(); + WSMessageLoop::the().post_event(&window, make(move(new_title))); + WSMessageLoop::the().server_process().request_wakeup(); return 0; } @@ -240,7 +240,7 @@ int Process::gui$set_window_rect(int window_id, const GUI_Rect* rect) return -EBADWINDOW; auto& window = *(*it).value; Rect new_rect = *rect; - WSEventLoop::the().post_event(&window, make(new_rect)); - WSEventLoop::the().server_process().request_wakeup(); + WSMessageLoop::the().post_event(&window, make(new_rect)); + WSMessageLoop::the().server_process().request_wakeup(); return 0; } diff --git a/SharedGraphics/GraphicsBitmap.cpp b/SharedGraphics/GraphicsBitmap.cpp index c6a1177ba86..7121161ce1d 100644 --- a/SharedGraphics/GraphicsBitmap.cpp +++ b/SharedGraphics/GraphicsBitmap.cpp @@ -4,7 +4,7 @@ #ifdef KERNEL #include #include -#include +#include #endif #ifdef KERNEL @@ -24,7 +24,7 @@ GraphicsBitmap::GraphicsBitmap(Process& process, const Size& size) m_client_region = process.allocate_region_with_vmo(LinearAddress(), size_in_bytes, vmo.copyRef(), 0, "GraphicsBitmap (client)", true, true); m_client_region->set_shared(true); m_client_region->commit(); - auto& server = WSEventLoop::the().server_process(); + auto& server = WSMessageLoop::the().server_process(); m_server_region = server.allocate_region_with_vmo(LinearAddress(), size_in_bytes, move(vmo), 0, "GraphicsBitmap (server)", true, false); m_server_region->set_shared(true); @@ -50,7 +50,7 @@ GraphicsBitmap::~GraphicsBitmap() if (m_client_region) m_client_process->deallocate_region(*m_client_region); if (m_server_region) - WSEventLoop::the().server_process().deallocate_region(*m_server_region); + WSMessageLoop::the().server_process().deallocate_region(*m_server_region); #endif m_data = nullptr; } diff --git a/WindowServer/WSEventReceiver.cpp b/WindowServer/WSEventReceiver.cpp deleted file mode 100644 index 74e31e89064..00000000000 --- a/WindowServer/WSEventReceiver.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "WSEventReceiver.h" -#include - -WSEventReceiver::WSEventReceiver() -{ -} - -WSEventReceiver::~WSEventReceiver() -{ -} diff --git a/WindowServer/WSEventReceiver.h b/WindowServer/WSEventReceiver.h deleted file mode 100644 index 1b81da7c2a7..00000000000 --- a/WindowServer/WSEventReceiver.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -class WSEvent; - -class WSEventReceiver : public Weakable { -public: - WSEventReceiver(); - virtual ~WSEventReceiver(); - - virtual void event(WSEvent&) = 0; -}; diff --git a/WindowServer/WSEvent.h b/WindowServer/WSMessage.h similarity index 72% rename from WindowServer/WSEvent.h rename to WindowServer/WSMessage.h index ea262f50c3a..906706a6b35 100644 --- a/WindowServer/WSEvent.h +++ b/WindowServer/WSMessage.h @@ -5,36 +5,16 @@ #include #include -static const char* WSEvent_names[] = { - "Invalid", - "Show", - "Hide", - "Paint", - "MouseMove", - "MouseDown", - "MouseUp", - "KeyDown", - "KeyUp", - "Timer", - "WM_Compose", - "WM_Invalidate", - "WindowActivated", - "WindowDeactivated", -}; - -class WSEvent { +class WSMessage { public: enum Type { Invalid = 0, - Show, - Hide, Paint, MouseMove, MouseDown, MouseUp, KeyDown, KeyUp, - Timer, WM_Compose, WM_Invalidate, WindowActivated, @@ -43,14 +23,12 @@ public: WM_SetWindowRect, }; - WSEvent() { } - explicit WSEvent(Type type) : m_type(type) { } - virtual ~WSEvent() { } + WSMessage() { } + explicit WSMessage(Type type) : m_type(type) { } + virtual ~WSMessage() { } Type type() const { return m_type; } - const char* name() const { return WSEvent_names[(unsigned)m_type]; } - bool is_mouse_event() const { return m_type == MouseMove || m_type == MouseDown || m_type == MouseUp; } bool is_key_event() const { return m_type == KeyUp || m_type == KeyDown; } bool is_paint_event() const { return m_type == Paint; } @@ -59,10 +37,10 @@ private: Type m_type { Invalid }; }; -class WSWindowInvalidationEvent final : public WSEvent { +class WSWindowInvalidationEvent final : public WSMessage { public: explicit WSWindowInvalidationEvent(const Rect& rect = Rect()) - : WSEvent(WSEvent::WM_Invalidate) + : WSMessage(WSMessage::WM_Invalidate) , m_rect(rect) { } @@ -72,10 +50,10 @@ private: Rect m_rect; }; -class WSSetWindowTitle final : public WSEvent { +class WSSetWindowTitle final : public WSMessage { public: explicit WSSetWindowTitle(String&& title) - : WSEvent(WSEvent::WM_SetWindowTitle) + : WSMessage(WSMessage::WM_SetWindowTitle) , m_title(move(title)) { } @@ -86,10 +64,10 @@ private: String m_title; }; -class WSSetWindowRect final : public WSEvent { +class WSSetWindowRect final : public WSMessage { public: explicit WSSetWindowRect(const Rect& rect) - : WSEvent(WSEvent::WM_SetWindowRect) + : WSMessage(WSMessage::WM_SetWindowRect) , m_rect(rect) { } @@ -100,10 +78,10 @@ private: Rect m_rect; }; -class WSPaintEvent final : public WSEvent { +class WSPaintEvent final : public WSMessage { public: explicit WSPaintEvent(const Rect& rect = Rect()) - : WSEvent(WSEvent::Paint) + : WSMessage(WSMessage::Paint) , m_rect(rect) { } @@ -121,10 +99,10 @@ enum class MouseButton : byte { Middle = 4, }; -class WSKeyEvent final : public WSEvent { +class WSKeyEvent final : public WSMessage { public: WSKeyEvent(Type type, int key, char character) - : WSEvent(type) + : WSMessage(type) , m_key(key) , m_character(character) { @@ -137,7 +115,7 @@ public: char character() const { return m_character; } private: - friend class WSEventLoop; + friend class WSMessageLoop; friend class WSScreen; int m_key { 0 }; bool m_ctrl { false }; @@ -146,10 +124,10 @@ private: char m_character { 0 }; }; -class WSMouseEvent final : public WSEvent { +class WSMouseEvent final : public WSMessage { public: WSMouseEvent(Type type, const Point& position, unsigned buttons, MouseButton button = MouseButton::None) - : WSEvent(type) + : WSMessage(type) , m_position(position) , m_buttons(buttons) , m_button(button) diff --git a/WindowServer/WSEventLoop.cpp b/WindowServer/WSMessageLoop.cpp similarity index 82% rename from WindowServer/WSEventLoop.cpp rename to WindowServer/WSMessageLoop.cpp index 29aa34b9cad..16ebd8668d5 100644 --- a/WindowServer/WSEventLoop.cpp +++ b/WindowServer/WSMessageLoop.cpp @@ -1,6 +1,6 @@ -#include "WSEventLoop.h" -#include "WSEvent.h" -#include "WSEventReceiver.h" +#include "WSMessageLoop.h" +#include "WSMessage.h" +#include "WSMessageReceiver.h" #include "WSWindowManager.h" #include "WSScreen.h" #include "PS2MouseDevice.h" @@ -10,30 +10,30 @@ //#define WSEVENTLOOP_DEBUG -static WSEventLoop* s_the; +static WSMessageLoop* s_the; -void WSEventLoop::initialize() +void WSMessageLoop::initialize() { s_the = nullptr; } -WSEventLoop::WSEventLoop() +WSMessageLoop::WSMessageLoop() { if (!s_the) s_the = this; } -WSEventLoop::~WSEventLoop() +WSMessageLoop::~WSMessageLoop() { } -WSEventLoop& WSEventLoop::the() +WSMessageLoop& WSMessageLoop::the() { ASSERT(s_the); return *s_the; } -int WSEventLoop::exec() +int WSMessageLoop::exec() { m_server_process = current; @@ -58,10 +58,10 @@ int WSEventLoop::exec() auto* receiver = queued_event.receiver; auto& event = *queued_event.event; #ifdef WSEVENTLOOP_DEBUG - dbgprintf("WSEventLoop: receiver{%p} event %u (%s)\n", receiver, (unsigned)event.type(), event.name()); + dbgprintf("WSMessageLoop: receiver{%p} event %u (%s)\n", receiver, (unsigned)event.type(), event.name()); #endif if (!receiver) { - dbgprintf("WSEvent type %u with no receiver :(\n", event.type()); + dbgprintf("WSMessage type %u with no receiver :(\n", event.type()); ASSERT_NOT_REACHED(); return 1; } else { @@ -71,18 +71,18 @@ int WSEventLoop::exec() } } -void WSEventLoop::post_event(WSEventReceiver* receiver, OwnPtr&& event) +void WSMessageLoop::post_event(WSMessageReceiver* receiver, OwnPtr&& event) { ASSERT_INTERRUPTS_ENABLED(); LOCKER(m_lock); #ifdef WSEVENTLOOP_DEBUG - dbgprintf("WSEventLoop::post_event: {%u} << receiver=%p, event=%p\n", m_queued_events.size(), receiver, event.ptr()); + dbgprintf("WSMessageLoop::post_event: {%u} << receiver=%p, event=%p\n", m_queued_events.size(), receiver, event.ptr()); #endif - if (event->type() == WSEvent::WM_Invalidate) { + if (event->type() == WSMessage::WM_Invalidate) { auto& invalidation_event = static_cast(*event); for (auto& queued_event : m_queued_events) { - if (receiver == queued_event.receiver && queued_event.event->type() == WSEvent::WM_Invalidate) { + if (receiver == queued_event.receiver && queued_event.event->type() == WSMessage::WM_Invalidate) { auto& queued_invalidation_event = static_cast(*queued_event.event); if (queued_invalidation_event.rect().is_empty() || queued_invalidation_event.rect().contains(invalidation_event.rect())) { #ifdef WSEVENTLOOP_DEBUG @@ -94,10 +94,10 @@ void WSEventLoop::post_event(WSEventReceiver* receiver, OwnPtr&& event) } } - if (event->type() == WSEvent::Paint) { + if (event->type() == WSMessage::Paint) { auto& invalidation_event = static_cast(*event); for (auto& queued_event : m_queued_events) { - if (receiver == queued_event.receiver && queued_event.event->type() == WSEvent::Paint) { + if (receiver == queued_event.receiver && queued_event.event->type() == WSMessage::Paint) { auto& queued_invalidation_event = static_cast(*queued_event.event); if (queued_invalidation_event.rect().is_empty() || queued_invalidation_event.rect().contains(invalidation_event.rect())) { #ifdef WSEVENTLOOP_DEBUG @@ -115,7 +115,7 @@ void WSEventLoop::post_event(WSEventReceiver* receiver, OwnPtr&& event) m_server_process->request_wakeup(); } -void WSEventLoop::wait_for_event() +void WSMessageLoop::wait_for_event() { fd_set rfds; memset(&rfds, 0, sizeof(rfds)); @@ -144,7 +144,7 @@ void WSEventLoop::wait_for_event() drain_mouse(); } -void WSEventLoop::drain_mouse() +void WSMessageLoop::drain_mouse() { auto& screen = WSScreen::the(); auto& mouse = PS2MouseDevice::the(); @@ -170,7 +170,7 @@ void WSEventLoop::drain_mouse() } } -void WSEventLoop::drain_keyboard() +void WSMessageLoop::drain_keyboard() { auto& screen = WSScreen::the(); auto& keyboard = Keyboard::the(); diff --git a/WindowServer/WSEventLoop.h b/WindowServer/WSMessageLoop.h similarity index 65% rename from WindowServer/WSEventLoop.h rename to WindowServer/WSMessageLoop.h index c4e914df49b..1559f959f16 100644 --- a/WindowServer/WSEventLoop.h +++ b/WindowServer/WSMessageLoop.h @@ -1,23 +1,23 @@ #pragma once -#include "WSEvent.h" +#include "WSMessage.h" #include #include #include -class WSEventReceiver; +class WSMessageReceiver; class Process; -class WSEventLoop { +class WSMessageLoop { public: - WSEventLoop(); - ~WSEventLoop(); + WSMessageLoop(); + ~WSMessageLoop(); int exec(); - void post_event(WSEventReceiver* receiver, OwnPtr&&); + void post_event(WSMessageReceiver* receiver, OwnPtr&&); - static WSEventLoop& the(); + static WSMessageLoop& the(); static void initialize(); @@ -32,8 +32,8 @@ private: Lock m_lock; struct QueuedEvent { - WSEventReceiver* receiver { nullptr }; - OwnPtr event; + WSMessageReceiver* receiver { nullptr }; + OwnPtr event; }; Vector m_queued_events; diff --git a/WindowServer/WSMessageReceiver.cpp b/WindowServer/WSMessageReceiver.cpp new file mode 100644 index 00000000000..62f1342d43a --- /dev/null +++ b/WindowServer/WSMessageReceiver.cpp @@ -0,0 +1,10 @@ +#include "WSMessageReceiver.h" +#include + +WSMessageReceiver::WSMessageReceiver() +{ +} + +WSMessageReceiver::~WSMessageReceiver() +{ +} diff --git a/WindowServer/WSMessageReceiver.h b/WindowServer/WSMessageReceiver.h new file mode 100644 index 00000000000..7be42a5503d --- /dev/null +++ b/WindowServer/WSMessageReceiver.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class WSMessage; + +class WSMessageReceiver : public Weakable { +public: + WSMessageReceiver(); + virtual ~WSMessageReceiver(); + + virtual void event(WSMessage&) = 0; +}; diff --git a/WindowServer/WSScreen.cpp b/WindowServer/WSScreen.cpp index 2634f2b0188..483396dda21 100644 --- a/WindowServer/WSScreen.cpp +++ b/WindowServer/WSScreen.cpp @@ -1,6 +1,6 @@ #include "WSScreen.h" -#include "WSEventLoop.h" -#include "WSEvent.h" +#include "WSMessageLoop.h" +#include "WSMessage.h" #include "WSWindowManager.h" #include @@ -47,20 +47,20 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, bool left_button, bool righ if (right_button) buttons |= (unsigned)MouseButton::Right; if (m_cursor_location != prev_location) { - auto event = make(WSEvent::MouseMove, m_cursor_location, buttons); - WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); + auto event = make(WSMessage::MouseMove, m_cursor_location, buttons); + WSMessageLoop::the().post_event(&WSWindowManager::the(), move(event)); } bool prev_left_button = m_left_mouse_button_pressed; bool prev_right_button = m_right_mouse_button_pressed; m_left_mouse_button_pressed = left_button; m_right_mouse_button_pressed = right_button; if (prev_left_button != left_button) { - auto event = make(left_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Left); - WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); + auto event = make(left_button ? WSMessage::MouseDown : WSMessage::MouseUp, m_cursor_location, buttons, MouseButton::Left); + WSMessageLoop::the().post_event(&WSWindowManager::the(), move(event)); } if (prev_right_button != right_button) { - auto event = make(right_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Right); - WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); + auto event = make(right_button ? WSMessage::MouseDown : WSMessage::MouseUp, m_cursor_location, buttons, MouseButton::Right); + WSMessageLoop::the().post_event(&WSWindowManager::the(), move(event)); } if (m_cursor_location != prev_location || prev_left_button != left_button) WSWindowManager::the().draw_cursor(); @@ -68,9 +68,9 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, bool left_button, bool righ void WSScreen::on_receive_keyboard_data(Keyboard::Event kernel_event) { - auto event = make(kernel_event.is_press() ? WSEvent::KeyDown : WSEvent::KeyUp, kernel_event.key, kernel_event.character); + auto event = make(kernel_event.is_press() ? WSMessage::KeyDown : WSMessage::KeyUp, kernel_event.key, kernel_event.character); event->m_shift = kernel_event.shift(); event->m_ctrl = kernel_event.ctrl(); event->m_alt = kernel_event.alt(); - WSEventLoop::the().post_event(&WSWindowManager::the(), move(event)); + WSMessageLoop::the().post_event(&WSWindowManager::the(), move(event)); } diff --git a/WindowServer/WSWindow.cpp b/WindowServer/WSWindow.cpp index a0cae6e7b31..b1c7d0d5f32 100644 --- a/WindowServer/WSWindow.cpp +++ b/WindowServer/WSWindow.cpp @@ -1,7 +1,7 @@ #include "WSWindow.h" #include "WSWindowManager.h" -#include "WSEvent.h" -#include "WSEventLoop.h" +#include "WSMessage.h" +#include "WSMessageLoop.h" #include "Process.h" WSWindow::WSWindow(Process& process, int window_id) @@ -54,35 +54,35 @@ static GUI_MouseButton to_api(MouseButton button) } } -void WSWindow::event(WSEvent& event) +void WSWindow::event(WSMessage& event) { GUI_Event gui_event; gui_event.window_id = window_id(); switch (event.type()) { - case WSEvent::Paint: + case WSMessage::Paint: gui_event.type = GUI_Event::Type::Paint; gui_event.paint.rect = static_cast(event).rect(); break; - case WSEvent::MouseMove: + case WSMessage::MouseMove: gui_event.type = GUI_Event::Type::MouseMove; gui_event.mouse.position = static_cast(event).position(); gui_event.mouse.button = GUI_MouseButton::NoButton; gui_event.mouse.buttons = static_cast(event).buttons(); break; - case WSEvent::MouseDown: + case WSMessage::MouseDown: gui_event.type = GUI_Event::Type::MouseDown; gui_event.mouse.position = static_cast(event).position(); gui_event.mouse.button = to_api(static_cast(event).button()); gui_event.mouse.buttons = static_cast(event).buttons(); break; - case WSEvent::MouseUp: + case WSMessage::MouseUp: gui_event.type = GUI_Event::Type::MouseUp; gui_event.mouse.position = static_cast(event).position(); gui_event.mouse.button = to_api(static_cast(event).button()); gui_event.mouse.buttons = static_cast(event).buttons(); break; - case WSEvent::KeyDown: + case WSMessage::KeyDown: gui_event.type = GUI_Event::Type::KeyDown; gui_event.key.character = static_cast(event).character(); gui_event.key.key = static_cast(event).key(); @@ -90,19 +90,19 @@ void WSWindow::event(WSEvent& event) gui_event.key.ctrl = static_cast(event).ctrl(); gui_event.key.shift = static_cast(event).shift(); break; - case WSEvent::WM_Invalidate: + case WSMessage::WM_Invalidate: WSWindowManager::the().invalidate(*this, static_cast(event).rect()); return; - case WSEvent::WM_SetWindowRect: + case WSMessage::WM_SetWindowRect: set_rect(static_cast(event).rect()); return; - case WSEvent::WM_SetWindowTitle: + case WSMessage::WM_SetWindowTitle: set_title(static_cast(event).title()); return; - case WSEvent::WindowActivated: + case WSMessage::WindowActivated: gui_event.type = GUI_Event::Type::WindowActivated; break; - case WSEvent::WindowDeactivated: + case WSMessage::WindowDeactivated: gui_event.type = GUI_Event::Type::WindowDeactivated; break; } diff --git a/WindowServer/WSWindow.h b/WindowServer/WSWindow.h index 4e5bc77616f..38178b3bb59 100644 --- a/WindowServer/WSWindow.h +++ b/WindowServer/WSWindow.h @@ -5,11 +5,11 @@ #include #include #include -#include "WSEventReceiver.h" +#include "WSMessageReceiver.h" class Process; -class WSWindow final : public WSEventReceiver, public InlineLinkedListNode { +class WSWindow final : public WSMessageReceiver, public InlineLinkedListNode { friend class WSWindowLocker; public: WSWindow(Process&, int window_id); @@ -33,7 +33,7 @@ public: void set_position(const Point& position) { set_rect({ position.x(), position.y(), width(), height() }); } void set_position_without_repaint(const Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); } - virtual void event(WSEvent&) override; + virtual void event(WSMessage&) override; bool is_being_dragged() const { return m_is_being_dragged; } void set_is_being_dragged(bool b) { m_is_being_dragged = b; } diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 15c1941775b..f685d197fc3 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -1,7 +1,7 @@ #include "WSWindowManager.h" #include "WSWindow.h" #include "WSScreen.h" -#include "WSEventLoop.h" +#include "WSMessageLoop.h" #include "Process.h" #include "MemoryManager.h" #include @@ -243,7 +243,7 @@ void WSWindowManager::notify_rect_changed(WSWindow& window, const Rect& old_rect void WSWindowManager::handle_titlebar_mouse_event(WSWindow& window, WSMouseEvent& event) { - if (event.type() == WSEvent::MouseDown && event.button() == MouseButton::Left) { + if (event.type() == WSMessage::MouseDown && event.button() == MouseButton::Left) { #ifdef DRAG_DEBUG printf("[WM] Begin dragging WSWindow{%p}\n", &window); #endif @@ -259,7 +259,7 @@ void WSWindowManager::handle_titlebar_mouse_event(WSWindow& window, WSMouseEvent void WSWindowManager::process_mouse_event(WSMouseEvent& event) { - if (event.type() == WSEvent::MouseUp && event.button() == MouseButton::Left) { + if (event.type() == WSMessage::MouseUp && event.button() == MouseButton::Left) { if (m_drag_window) { #ifdef DRAG_DEBUG printf("[WM] Finish dragging WSWindow{%p}\n", m_dragWindow.ptr()); @@ -272,7 +272,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event) } } - if (event.type() == WSEvent::MouseMove) { + if (event.type() == WSMessage::MouseMove) { if (m_drag_window) { auto old_window_rect = m_drag_window->rect(); Point pos = m_drag_window_origin; @@ -289,7 +289,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event) for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) { if (title_bar_rect(window->rect()).contains(event.position())) { - if (event.type() == WSEvent::MouseDown) { + if (event.type() == WSMessage::MouseDown) { move_to_front(*window); set_active_window(window); } @@ -298,7 +298,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event) } if (window->rect().contains(event.position())) { - if (event.type() == WSEvent::MouseDown) { + if (event.type() == WSMessage::MouseDown) { move_to_front(*window); set_active_window(window); } @@ -387,7 +387,7 @@ void WSWindowManager::draw_cursor() m_last_cursor_rect = cursor_rect; } -void WSWindowManager::event(WSEvent& event) +void WSWindowManager::event(WSMessage& event) { ASSERT_INTERRUPTS_ENABLED(); LOCKER(m_lock); @@ -401,7 +401,7 @@ void WSWindowManager::event(WSEvent& event) return; } - if (event.type() == WSEvent::WM_Compose) { + if (event.type() == WSMessage::WM_Compose) { m_pending_compose_event = false; compose(); return; @@ -415,12 +415,12 @@ void WSWindowManager::set_active_window(WSWindow* window) return; if (auto* previously_active_window = m_active_window.ptr()) { - WSEventLoop::the().post_event(previously_active_window, make(WSEvent::WindowDeactivated)); + WSMessageLoop::the().post_event(previously_active_window, make(WSMessage::WindowDeactivated)); invalidate(*previously_active_window); } m_active_window = window->makeWeakPtr(); if (m_active_window) { - WSEventLoop::the().post_event(m_active_window.ptr(), make(WSEvent::WindowActivated)); + WSMessageLoop::the().post_event(m_active_window.ptr(), make(WSMessage::WindowActivated)); invalidate(*m_active_window); } } @@ -454,7 +454,7 @@ void WSWindowManager::invalidate(const Rect& a_rect) if (!m_pending_compose_event) { ASSERT_INTERRUPTS_ENABLED(); - WSEventLoop::the().post_event(this, make(WSEvent::WM_Compose)); + WSMessageLoop::the().post_event(this, make(WSMessage::WM_Compose)); m_pending_compose_event = true; } } diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index 8af6937f923..1e42f443375 100644 --- a/WindowServer/WSWindowManager.h +++ b/WindowServer/WSWindowManager.h @@ -7,7 +7,7 @@ #include #include #include -#include "WSEventReceiver.h" +#include "WSMessageReceiver.h" class WSScreen; class WSMouseEvent; @@ -16,7 +16,7 @@ class WSWindow; class CharacterBitmap; class GraphicsBitmap; -class WSWindowManager : public WSEventReceiver { +class WSWindowManager : public WSMessageReceiver { public: static WSWindowManager& the(); void add_window(WSWindow&); @@ -48,7 +48,7 @@ private: void set_active_window(WSWindow*); - virtual void event(WSEvent&) override; + virtual void event(WSMessage&) override; void compose(); void paint_window_frame(WSWindow&); diff --git a/WindowServer/main.cpp b/WindowServer/main.cpp index 6497c895e60..61da8ead624 100644 --- a/WindowServer/main.cpp +++ b/WindowServer/main.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include // NOTE: This actually runs as a kernel process. @@ -19,7 +19,7 @@ void WindowServer_main() WSWindowManager::the(); dbgprintf("Entering WindowServer main loop.\n"); - WSEventLoop::the().exec(); + WSMessageLoop::the().exec(); ASSERT_NOT_REACHED(); }