mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
WindowServer: Begin refactoring towards a fully asynchronous protocol.
In order to move the WindowServer to userspace, I have to eliminate its dependence on system call facilities. The communication channel with each client needs to be message-based in both directions.
This commit is contained in:
parent
96352ab735
commit
4f98a35beb
18 changed files with 242 additions and 91 deletions
|
@ -67,6 +67,21 @@ int WSMessageLoop::exec()
|
|||
}
|
||||
}
|
||||
|
||||
Process* WSMessageLoop::process_from_client_id(int client_id)
|
||||
{
|
||||
// FIXME: This shouldn't work this way lol.
|
||||
return (Process*)client_id;
|
||||
}
|
||||
|
||||
void WSMessageLoop::post_message_to_client(int client_id, const GUI_Event& message)
|
||||
{
|
||||
auto* process = process_from_client_id(client_id);
|
||||
if (!process)
|
||||
return;
|
||||
LOCKER(process->gui_events_lock());
|
||||
process->gui_events().append(move(message));
|
||||
}
|
||||
|
||||
void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&& message)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
|
@ -246,3 +261,19 @@ void WSMessageLoop::drain_keyboard()
|
|||
screen.on_receive_keyboard_data(event);
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t WSMessageLoop::on_receive_from_client(int client_id, const byte* data, size_t size)
|
||||
{
|
||||
LOCKER(m_lock);
|
||||
ASSERT(size == sizeof(GUI_ClientMessage));
|
||||
auto& message = *reinterpret_cast<const GUI_ClientMessage*>(data);
|
||||
switch (message.type) {
|
||||
case GUI_ClientMessage::Type::CreateMenubar:
|
||||
post_message(&WSWindowManager::the(), make<WSAPICreateMenubarRequest>(client_id));
|
||||
break;
|
||||
case GUI_ClientMessage::Type::DestroyMenubar:
|
||||
post_message(&WSWindowManager::the(), make<WSAPIDestroyMenubarRequest>(client_id, message.menu.menubar_id));
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue