#pragma once #include "Framebuffer.h" #include "Window.h" #include #include #include #include #include #include #include #include #include #include class WindowServer { public: struct ClientData { size_t packet_buffer_nread = 0; BAN::Vector packet_buffer; }; public: WindowServer(Framebuffer& framebuffer, int32_t corner_radius); BAN::ErrorOr set_background_image(BAN::UniqPtr); void on_window_create(int fd, const LibGUI::WindowPacket::WindowCreate&); void on_window_invalidate(int fd, const LibGUI::WindowPacket::WindowInvalidate&); void on_window_set_position(int fd, const LibGUI::WindowPacket::WindowSetPosition&); void on_window_set_attributes(int fd, const LibGUI::WindowPacket::WindowSetAttributes&); void on_window_set_mouse_capture(int fd, const LibGUI::WindowPacket::WindowSetMouseCapture&); void on_window_set_size(int fd, const LibGUI::WindowPacket::WindowSetSize&); void on_window_set_fullscreen(int fd, const LibGUI::WindowPacket::WindowSetFullscreen&); void on_key_event(LibInput::KeyEvent event); void on_mouse_button(LibInput::MouseButtonEvent event); void on_mouse_move(LibInput::MouseMoveEvent event); void on_mouse_scroll(LibInput::MouseScrollEvent event); void set_focused_window(BAN::RefPtr window); void invalidate(Rectangle area); void sync(); Rectangle cursor_area() const; void add_client_fd(int fd); void remove_client_fd(int fd); int get_client_fds(fd_set& fds) const; void for_each_client_fd(const BAN::Function& callback); bool is_stopped() const { return m_is_stopped; } private: void mark_pending_sync(Rectangle area); private: Framebuffer& m_framebuffer; BAN::Vector> m_client_windows; BAN::HashMap m_client_data; const int32_t m_corner_radius; BAN::Vector m_pages_to_sync_bitmap; BAN::UniqPtr m_background_image; bool m_is_mod_key_held { false }; bool m_is_moving_window { false }; bool m_is_fullscreen_window { false }; BAN::RefPtr m_focused_window; Position m_cursor; bool m_is_mouse_captured { false }; bool m_deleted_window { false }; bool m_is_stopped { false }; bool m_is_bouncing_window = false; LibFont::Font m_font; };