mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +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;
|
||||
}
|
16
Kernel/GUIEventDevice.h
Normal file
16
Kernel/GUIEventDevice.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <VirtualFileSystem/CharacterDevice.h>
|
||||
|
||||
class GUIEventDevice final : public CharacterDevice {
|
||||
public:
|
||||
GUIEventDevice();
|
||||
virtual ~GUIEventDevice() override;
|
||||
|
||||
private:
|
||||
// ^CharacterDevice
|
||||
virtual ssize_t read(Process&, byte* buffer, size_t bufferSize) override;
|
||||
virtual ssize_t write(Process&, const byte* buffer, size_t bufferSize) override;
|
||||
virtual bool can_read(Process&) const override;
|
||||
virtual bool can_write(Process&) const override { return true; }
|
||||
};
|
|
@ -30,7 +30,7 @@ KERNEL_OBJS = \
|
|||
ELFLoader.o \
|
||||
KSyms.o \
|
||||
PS2MouseDevice.o \
|
||||
WindowServer.o
|
||||
GUIEventDevice.o
|
||||
|
||||
VFS_OBJS = \
|
||||
../VirtualFileSystem/DiskDevice.o \
|
||||
|
@ -46,21 +46,20 @@ VFS_OBJS = \
|
|||
../VirtualFileSystem/FileDescriptor.o \
|
||||
../VirtualFileSystem/SyntheticFileSystem.o
|
||||
|
||||
WIDGETS_OBJS = \
|
||||
../Widgets/Window.o \
|
||||
../Widgets/Painter.o \
|
||||
../Widgets/WindowManager.o \
|
||||
../Widgets/FrameBuffer.o \
|
||||
../Widgets/GraphicsBitmap.o \
|
||||
../Widgets/Object.o \
|
||||
WINDOWSERVER_OBJS = \
|
||||
../Widgets/Rect.o \
|
||||
../Widgets/Widget.o \
|
||||
../Widgets/Painter.o \
|
||||
../Widgets/Font.o \
|
||||
../Widgets/Color.o \
|
||||
../Widgets/CharacterBitmap.o \
|
||||
../Widgets/EventLoop.o \
|
||||
../Widgets/AbstractScreen.o \
|
||||
../Widgets/GUIEventDevice.o \
|
||||
../Widgets/GraphicsBitmap.o \
|
||||
../WindowServer/WSEventReceiver.o \
|
||||
../WindowServer/WSEventLoop.o \
|
||||
../WindowServer/WSWindow.o \
|
||||
../WindowServer/WSWindowManager.o \
|
||||
../WindowServer/WSFrameBuffer.o \
|
||||
../WindowServer/WSScreen.o \
|
||||
../WindowServer/main.o
|
||||
|
||||
AK_OBJS = \
|
||||
../AK/String.o \
|
||||
|
@ -68,7 +67,7 @@ AK_OBJS = \
|
|||
../AK/StringBuilder.o \
|
||||
../AK/FileSystemPath.o
|
||||
|
||||
OBJS = $(KERNEL_OBJS) $(VFS_OBJS) $(AK_OBJS) $(WIDGETS_OBJS)
|
||||
OBJS = $(KERNEL_OBJS) $(VFS_OBJS) $(AK_OBJS) $(WINDOWSERVER_OBJS)
|
||||
|
||||
NASM = nasm
|
||||
KERNEL = kernel
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "Scheduler.h"
|
||||
#include "FIFO.h"
|
||||
#include "KSyms.h"
|
||||
#include <Widgets/Window.h>
|
||||
#include <WindowServer/WSWindow.h>
|
||||
#include "MasterPTY.h"
|
||||
|
||||
//#define DEBUG_IO
|
||||
|
|
|
@ -19,8 +19,7 @@ class PageDirectory;
|
|||
class Region;
|
||||
class VMObject;
|
||||
class Zone;
|
||||
class Window;
|
||||
class Widget;
|
||||
class WSWindow;
|
||||
|
||||
#define COOL_GLOBALS
|
||||
#ifdef COOL_GLOBALS
|
||||
|
@ -47,7 +46,7 @@ struct DisplayInfo {
|
|||
|
||||
class Process : public InlineLinkedListNode<Process> {
|
||||
friend class InlineLinkedListNode<Process>;
|
||||
friend class WindowManager; // FIXME: Make a better API for allocate_region().
|
||||
friend class WSWindowManager; // FIXME: Make a better API for allocate_region().
|
||||
friend class GraphicsBitmap; // FIXME: Make a better API for allocate_region().
|
||||
public:
|
||||
static Process* create_kernel_process(String&& name, void (*entry)());
|
||||
|
@ -353,7 +352,7 @@ private:
|
|||
|
||||
RetainPtr<Region> m_display_framebuffer_region;
|
||||
|
||||
HashMap<int, OwnPtr<Window>> m_windows;
|
||||
HashMap<int, OwnPtr<WSWindow>> m_windows;
|
||||
|
||||
Vector<GUI_Event> m_gui_events;
|
||||
SpinLock m_gui_events_lock;
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
#include "Process.h"
|
||||
#include "MemoryManager.h"
|
||||
#include <LibC/errno_numbers.h>
|
||||
#include <Widgets/AbstractScreen.h>
|
||||
#include <Widgets/FrameBuffer.h>
|
||||
#include <Widgets/EventLoop.h>
|
||||
#include <Widgets/Font.h>
|
||||
#include <Widgets/Button.h>
|
||||
#include <Widgets/Label.h>
|
||||
#include <Widgets/Widget.h>
|
||||
#include <Widgets/Window.h>
|
||||
#include <Widgets/WindowManager.h>
|
||||
#include <WindowServer/WSScreen.h>
|
||||
#include <WindowServer/WSFrameBuffer.h>
|
||||
#include <WindowServer/WSEventLoop.h>
|
||||
#include <WindowServer/WSWindow.h>
|
||||
#include <WindowServer/WSWindowManager.h>
|
||||
|
||||
void Process::initialize_gui_statics()
|
||||
{
|
||||
Font::initialize();
|
||||
FrameBuffer::initialize();
|
||||
EventLoop::initialize();
|
||||
WindowManager::initialize();
|
||||
AbstractScreen::initialize();
|
||||
WSFrameBuffer::initialize();
|
||||
WSEventLoop::initialize();
|
||||
WSWindowManager::initialize();
|
||||
WSScreen::initialize();
|
||||
|
||||
new EventLoop;
|
||||
new WSEventLoop;
|
||||
}
|
||||
|
||||
int Process::make_window_id()
|
||||
|
@ -36,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 (!EventLoop::main().running())
|
||||
while (!WSEventLoop::the().running())
|
||||
sleep(10);
|
||||
}
|
||||
|
||||
|
@ -53,13 +50,13 @@ int Process::gui$create_window(const GUI_CreateWindowParameters* user_params)
|
|||
if (rect.is_empty())
|
||||
return -EINVAL;
|
||||
|
||||
ProcessPagingScope scope(EventLoop::main().server_process());
|
||||
ProcessPagingScope scope(WSEventLoop::the().server_process());
|
||||
|
||||
int window_id = make_window_id();
|
||||
if (!window_id)
|
||||
return -ENOMEM;
|
||||
|
||||
auto window = make<Window>(*this, window_id);
|
||||
auto window = make<WSWindow>(*this, window_id);
|
||||
if (!window)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -113,7 +110,6 @@ int Process::gui$invalidate_window(int window_id)
|
|||
auto& window = *(*it).value;
|
||||
// FIXME: This should queue up a message that the window server process can read.
|
||||
// Poking into its data structures is not good.
|
||||
InterruptDisabler disabler;
|
||||
WindowManager::the().invalidate(window);
|
||||
WSEventLoop::the().post_event(&window, make<WSEvent>(WSEvent::WM_Invalidate));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ bool Scheduler::pick_next()
|
|||
for (auto* process = g_processes->head(); process; process = process->next()) {
|
||||
//if (process->state() == Process::BlockedWait || process->state() == Process::BlockedSleep)
|
||||
// continue;
|
||||
dbgprintf("% 12s %s(%u) @ %w:%x\n", toString(process->state()), process->name().characters(), process->pid(), process->tss().cs, process->tss().eip);
|
||||
dbgprintf("[K%x] % 12s %s(%u) @ %w:%x\n", process, toString(process->state()), process->name().characters(), process->pid(), process->tss().cs, process->tss().eip);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include "Process.h"
|
||||
#include <Widgets/Font.h>
|
||||
#include <Widgets/FrameBuffer.h>
|
||||
#include <Widgets/WindowManager.h>
|
||||
#include <Widgets/EventLoop.h>
|
||||
#include <Widgets/Window.h>
|
||||
|
||||
void WindowServer_main()
|
||||
{
|
||||
auto info = current->get_display_info();
|
||||
|
||||
dbgprintf("Screen is %ux%ux%ubpp\n", info.width, info.height, info.bpp);
|
||||
|
||||
FrameBuffer framebuffer((dword*)info.framebuffer, info.width, info.height);
|
||||
|
||||
WindowManager::the();
|
||||
|
||||
dbgprintf("Entering WindowServer main loop.\n");
|
||||
EventLoop::main().exec();
|
||||
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
|
@ -81,6 +81,7 @@ void write_gdt_entry(word selector, Descriptor&);
|
|||
|
||||
#define cli() asm volatile("cli")
|
||||
#define sti() asm volatile("sti")
|
||||
#define memory_barrier() asm volatile ("" ::: "memory")
|
||||
|
||||
static inline dword cpu_flags()
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <VirtualFileSystem/RandomDevice.h>
|
||||
#include <VirtualFileSystem/Ext2FileSystem.h>
|
||||
#include <VirtualFileSystem/VirtualFileSystem.h>
|
||||
#include <Widgets/GUIEventDevice.h>
|
||||
#include "GUIEventDevice.h"
|
||||
#include "MemoryManager.h"
|
||||
#include "ProcFileSystem.h"
|
||||
#include "RTC.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue