1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00
serenity/WindowServer/WSWindowManager.h
Andreas Kling a2ec09bc20 Allow the scheduler to unblock the current process.
It's a bit confusing that the "current" process is not actually running
while we're inside the scheduler. Perhaps the scheduler should redirect
"current" to its own dummy Process. I'm not sure.

Regardless, this patch improves responsiveness by allowing the scheduler
to unblock a process right after it calls select() in case it already has
a pending wakeup request.
2019-01-16 17:47:18 +01:00

96 lines
2.2 KiB
C++

#pragma once
#include <Widgets/Rect.h>
#include <Widgets/Color.h>
#include <Widgets/Painter.h>
#include <AK/HashTable.h>
#include <AK/InlineLinkedList.h>
#include <AK/WeakPtr.h>
#include <AK/Lock.h>
#include "WSEventReceiver.h"
class WSFrameBuffer;
class MouseEvent;
class PaintEvent;
class WSWindow;
class CharacterBitmap;
class GraphicsBitmap;
class WSWindowManager : public WSEventReceiver {
public:
static WSWindowManager& the();
void addWindow(WSWindow&);
void removeWindow(WSWindow&);
void notifyTitleChanged(WSWindow&);
void notifyRectChanged(WSWindow&, const Rect& oldRect, const Rect& newRect);
WSWindow* activeWindow() { return m_activeWindow.ptr(); }
void move_to_front(WSWindow&);
static void initialize();
void draw_cursor();
void invalidate(const WSWindow&);
void invalidate(const Rect&);
void invalidate();
void flush(const Rect&);
private:
WSWindowManager();
virtual ~WSWindowManager() override;
void processMouseEvent(MouseEvent&);
void handleTitleBarMouseEvent(WSWindow&, MouseEvent&);
void setActiveWindow(WSWindow*);
virtual void event(WSEvent&) override;
void compose();
void paintWindowFrame(WSWindow&);
WSFrameBuffer& m_framebuffer;
Rect m_screen_rect;
Color m_activeWindowBorderColor;
Color m_activeWindowTitleColor;
Color m_inactiveWindowBorderColor;
Color m_inactiveWindowTitleColor;
HashTable<WSWindow*> m_windows;
InlineLinkedList<WSWindow> m_windows_in_order;
WeakPtr<WSWindow> m_activeWindow;
WeakPtr<WSWindow> m_dragWindow;
Point m_dragOrigin;
Point m_dragWindowOrigin;
Rect m_lastDragRect;
Rect m_dragStartRect;
Rect m_dragEndRect;
Rect m_last_cursor_rect;
unsigned m_recompose_count { 0 };
unsigned m_flush_count { 0 };
RetainPtr<GraphicsBitmap> m_front_bitmap;
RetainPtr<GraphicsBitmap> m_back_bitmap;
Vector<Rect> m_invalidated_rects;
bool m_pending_compose_event { false };
RetainPtr<CharacterBitmap> m_cursor_bitmap_inner;
RetainPtr<CharacterBitmap> m_cursor_bitmap_outer;
OwnPtr<Painter> m_back_painter;
OwnPtr<Painter> m_front_painter;
mutable SpinLock m_lock;
};