WindowServer: Rename WSEvent to WSMessage.

Also do the same for WSMessageLoop and WSMessageReceiver. More to come.
This commit is contained in:
Andreas Kling 2019-01-26 05:28:02 +01:00
parent 7cf3c7461c
commit bba21adae3
Notes: sideshowbarker 2024-07-19 15:56:36 +09:00
16 changed files with 129 additions and 151 deletions

View file

@ -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 \

View file

@ -3,7 +3,7 @@
#include <LibC/errno_numbers.h>
#include <SharedGraphics/Font.h>
#include <WindowServer/WSScreen.h>
#include <WindowServer/WSEventLoop.h>
#include <WindowServer/WSMessageLoop.h>
#include <WindowServer/WSWindow.h>
#include <WindowServer/WSWindowManager.h>
@ -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<WSPaintEvent>(rect));
WSEventLoop::the().server_process().request_wakeup();
WSMessageLoop::the().post_event(&window, make<WSPaintEvent>(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<WSWindowInvalidationEvent>(rect));
WSEventLoop::the().server_process().request_wakeup();
WSMessageLoop::the().post_event(&window, make<WSWindowInvalidationEvent>(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<WSSetWindowTitle>(move(new_title)));
WSEventLoop::the().server_process().request_wakeup();
WSMessageLoop::the().post_event(&window, make<WSSetWindowTitle>(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<WSSetWindowRect>(new_rect));
WSEventLoop::the().server_process().request_wakeup();
WSMessageLoop::the().post_event(&window, make<WSSetWindowRect>(new_rect));
WSMessageLoop::the().server_process().request_wakeup();
return 0;
}

View file

@ -4,7 +4,7 @@
#ifdef KERNEL
#include <Kernel/Process.h>
#include <Kernel/MemoryManager.h>
#include <WindowServer/WSEventLoop.h>
#include <WindowServer/WSMessageLoop.h>
#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;
}

View file

@ -1,10 +0,0 @@
#include "WSEventReceiver.h"
#include <AK/Assertions.h>
WSEventReceiver::WSEventReceiver()
{
}
WSEventReceiver::~WSEventReceiver()
{
}

View file

@ -1,13 +0,0 @@
#pragma once
#include <AK/Weakable.h>
class WSEvent;
class WSEventReceiver : public Weakable<WSEventReceiver> {
public:
WSEventReceiver();
virtual ~WSEventReceiver();
virtual void event(WSEvent&) = 0;
};

View file

@ -5,36 +5,16 @@
#include <AK/AKString.h>
#include <AK/Types.h>
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)

View file

@ -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<WSEvent>&& event)
void WSMessageLoop::post_event(WSMessageReceiver* receiver, OwnPtr<WSMessage>&& 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<WSWindowInvalidationEvent&>(*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<WSWindowInvalidationEvent&>(*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<WSEvent>&& event)
}
}
if (event->type() == WSEvent::Paint) {
if (event->type() == WSMessage::Paint) {
auto& invalidation_event = static_cast<WSPaintEvent&>(*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<WSPaintEvent&>(*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<WSEvent>&& 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();

View file

@ -1,23 +1,23 @@
#pragma once
#include "WSEvent.h"
#include "WSMessage.h"
#include <AK/Lock.h>
#include <AK/OwnPtr.h>
#include <AK/Vector.h>
class WSEventReceiver;
class WSMessageReceiver;
class Process;
class WSEventLoop {
class WSMessageLoop {
public:
WSEventLoop();
~WSEventLoop();
WSMessageLoop();
~WSMessageLoop();
int exec();
void post_event(WSEventReceiver* receiver, OwnPtr<WSEvent>&&);
void post_event(WSMessageReceiver* receiver, OwnPtr<WSMessage>&&);
static WSEventLoop& the();
static WSMessageLoop& the();
static void initialize();
@ -32,8 +32,8 @@ private:
Lock m_lock;
struct QueuedEvent {
WSEventReceiver* receiver { nullptr };
OwnPtr<WSEvent> event;
WSMessageReceiver* receiver { nullptr };
OwnPtr<WSMessage> event;
};
Vector<QueuedEvent> m_queued_events;

View file

@ -0,0 +1,10 @@
#include "WSMessageReceiver.h"
#include <AK/Assertions.h>
WSMessageReceiver::WSMessageReceiver()
{
}
WSMessageReceiver::~WSMessageReceiver()
{
}

View file

@ -0,0 +1,13 @@
#pragma once
#include <AK/Weakable.h>
class WSMessage;
class WSMessageReceiver : public Weakable<WSMessageReceiver> {
public:
WSMessageReceiver();
virtual ~WSMessageReceiver();
virtual void event(WSMessage&) = 0;
};

View file

@ -1,6 +1,6 @@
#include "WSScreen.h"
#include "WSEventLoop.h"
#include "WSEvent.h"
#include "WSMessageLoop.h"
#include "WSMessage.h"
#include "WSWindowManager.h"
#include <AK/Assertions.h>
@ -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<WSMouseEvent>(WSEvent::MouseMove, m_cursor_location, buttons);
WSEventLoop::the().post_event(&WSWindowManager::the(), move(event));
auto event = make<WSMouseEvent>(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<WSMouseEvent>(left_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Left);
WSEventLoop::the().post_event(&WSWindowManager::the(), move(event));
auto event = make<WSMouseEvent>(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<WSMouseEvent>(right_button ? WSEvent::MouseDown : WSEvent::MouseUp, m_cursor_location, buttons, MouseButton::Right);
WSEventLoop::the().post_event(&WSWindowManager::the(), move(event));
auto event = make<WSMouseEvent>(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<WSKeyEvent>(kernel_event.is_press() ? WSEvent::KeyDown : WSEvent::KeyUp, kernel_event.key, kernel_event.character);
auto event = make<WSKeyEvent>(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));
}

View file

@ -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<WSPaintEvent&>(event).rect();
break;
case WSEvent::MouseMove:
case WSMessage::MouseMove:
gui_event.type = GUI_Event::Type::MouseMove;
gui_event.mouse.position = static_cast<WSMouseEvent&>(event).position();
gui_event.mouse.button = GUI_MouseButton::NoButton;
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(event).buttons();
break;
case WSEvent::MouseDown:
case WSMessage::MouseDown:
gui_event.type = GUI_Event::Type::MouseDown;
gui_event.mouse.position = static_cast<WSMouseEvent&>(event).position();
gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(event).button());
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(event).buttons();
break;
case WSEvent::MouseUp:
case WSMessage::MouseUp:
gui_event.type = GUI_Event::Type::MouseUp;
gui_event.mouse.position = static_cast<WSMouseEvent&>(event).position();
gui_event.mouse.button = to_api(static_cast<WSMouseEvent&>(event).button());
gui_event.mouse.buttons = static_cast<WSMouseEvent&>(event).buttons();
break;
case WSEvent::KeyDown:
case WSMessage::KeyDown:
gui_event.type = GUI_Event::Type::KeyDown;
gui_event.key.character = static_cast<WSKeyEvent&>(event).character();
gui_event.key.key = static_cast<WSKeyEvent&>(event).key();
@ -90,19 +90,19 @@ void WSWindow::event(WSEvent& event)
gui_event.key.ctrl = static_cast<WSKeyEvent&>(event).ctrl();
gui_event.key.shift = static_cast<WSKeyEvent&>(event).shift();
break;
case WSEvent::WM_Invalidate:
case WSMessage::WM_Invalidate:
WSWindowManager::the().invalidate(*this, static_cast<WSWindowInvalidationEvent&>(event).rect());
return;
case WSEvent::WM_SetWindowRect:
case WSMessage::WM_SetWindowRect:
set_rect(static_cast<WSSetWindowRect&>(event).rect());
return;
case WSEvent::WM_SetWindowTitle:
case WSMessage::WM_SetWindowTitle:
set_title(static_cast<WSSetWindowTitle&>(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;
}

View file

@ -5,11 +5,11 @@
#include <AK/AKString.h>
#include <AK/InlineLinkedList.h>
#include <AK/Lock.h>
#include "WSEventReceiver.h"
#include "WSMessageReceiver.h"
class Process;
class WSWindow final : public WSEventReceiver, public InlineLinkedListNode<WSWindow> {
class WSWindow final : public WSMessageReceiver, public InlineLinkedListNode<WSWindow> {
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; }

View file

@ -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 <Kernel/ProcFileSystem.h>
@ -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>(WSEvent::WindowDeactivated));
WSMessageLoop::the().post_event(previously_active_window, make<WSMessage>(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>(WSEvent::WindowActivated));
WSMessageLoop::the().post_event(m_active_window.ptr(), make<WSMessage>(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>(WSEvent::WM_Compose));
WSMessageLoop::the().post_event(this, make<WSMessage>(WSMessage::WM_Compose));
m_pending_compose_event = true;
}
}

View file

@ -7,7 +7,7 @@
#include <AK/InlineLinkedList.h>
#include <AK/WeakPtr.h>
#include <AK/Lock.h>
#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&);

View file

@ -2,7 +2,7 @@
#include <SharedGraphics/Font.h>
#include <WindowServer/WSScreen.h>
#include <WindowServer/WSWindowManager.h>
#include <WindowServer/WSEventLoop.h>
#include <WindowServer/WSMessageLoop.h>
#include <WindowServer/WSWindow.h>
// 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();
}