mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:15:07 +00:00
Tear out or duplicate what's unique for WindowServer from Widgets.
This turned into a huge refactoring that somehow also includes making locks recursive/reentrant.
This commit is contained in:
parent
e655aebd70
commit
f7ca6d254d
30 changed files with 757 additions and 308 deletions
38
Kernel/GUIEventDevice.cpp
Normal file
38
Kernel/GUIEventDevice.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include "GUIEventDevice.h"
|
||||
#include <Kernel/Process.h>
|
||||
#include <AK/Lock.h>
|
||||
#include <LibC/errno_numbers.h>
|
||||
|
||||
//#define GUIEVENTDEVICE_DEBUG
|
||||
|
||||
GUIEventDevice::GUIEventDevice()
|
||||
: CharacterDevice(66, 1)
|
||||
{
|
||||
}
|
||||
|
||||
GUIEventDevice::~GUIEventDevice()
|
||||
{
|
||||
}
|
||||
|
||||
bool GUIEventDevice::can_read(Process& process) const
|
||||
{
|
||||
return !process.gui_events().is_empty();
|
||||
}
|
||||
|
||||
ssize_t GUIEventDevice::read(Process& process, byte* buffer, size_t size)
|
||||
{
|
||||
#ifdef GUIEVENTDEVICE_DEBUG
|
||||
dbgprintf("GUIEventDevice::read(): %s<%u>, size=%u, sizeof(GUI_Event)=%u\n", process.name().characters(), process.pid(), size, sizeof(GUI_Event));
|
||||
#endif
|
||||
if (process.gui_events().is_empty())
|
||||
return 0;
|
||||
LOCKER(process.gui_events_lock());
|
||||
ASSERT(size == sizeof(GUI_Event));
|
||||
*reinterpret_cast<GUI_Event*>(buffer) = process.gui_events().take_first();
|
||||
return size;
|
||||
}
|
||||
|
||||
ssize_t GUIEventDevice::write(Process&, const byte*, size_t)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue