#pragma once #include #include #include #include #include #include #include #include "WSEventReceiver.h" class WSScreen; class WSMouseEvent; class WSPaintEvent; class WSWindow; class CharacterBitmap; class GraphicsBitmap; class WSWindowManager : public WSEventReceiver { public: static WSWindowManager& the(); void add_window(WSWindow&); void remove_window(WSWindow&); void notify_title_changed(WSWindow&); void notify_rect_changed(WSWindow&, const Rect& oldRect, const Rect& newRect); WSWindow* active_window() { return m_active_window.ptr(); } void move_to_front(WSWindow&); static void initialize(); void draw_cursor(); void invalidate(const WSWindow&); void invalidate(const WSWindow&, const Rect&); void invalidate(const Rect&); void invalidate(); void flush(const Rect&); private: WSWindowManager(); virtual ~WSWindowManager() override; void process_mouse_event(WSMouseEvent&); void handle_titlebar_mouse_event(WSWindow&, WSMouseEvent&); void set_active_window(WSWindow*); virtual void event(WSEvent&) override; void compose(); void paint_window_frame(WSWindow&); WSScreen& m_screen; Rect m_screen_rect; Color m_background_color; Color m_active_window_border_color; Color m_active_window_border_color2; Color m_active_window_title_color; Color m_inactive_window_border_color; Color m_inactive_window_border_color2; Color m_inactive_window_title_color; Color m_dragging_window_border_color; Color m_dragging_window_border_color2; Color m_dragging_window_title_color; HashTable m_windows; InlineLinkedList m_windows_in_order; WeakPtr m_active_window; WeakPtr m_drag_window; Point m_drag_origin; Point m_drag_window_origin; Rect m_last_drag_rect; Rect m_drag_start_rect; Rect m_drag_end_rect; Rect m_last_cursor_rect; unsigned m_compose_count { 0 }; unsigned m_flush_count { 0 }; RetainPtr m_front_bitmap; RetainPtr m_back_bitmap; Vector m_dirty_rects; bool m_pending_compose_event { false }; RetainPtr m_cursor_bitmap_inner; RetainPtr m_cursor_bitmap_outer; OwnPtr m_back_painter; OwnPtr m_front_painter; mutable Lock m_lock; bool m_flash_flush { false }; };