#pragma once #include #include #include #include #include #include #include #include #include class WSWindow; class WSMenu; class WSMenuBar; class WSClientConnection final : public IClientConnection , public WindowServerEndpoint { C_OBJECT(WSClientConnection) public: ~WSClientConnection() override; virtual void die() override; void boost(); void deboost(); static WSClientConnection* from_client_id(int client_id); static void for_each_client(Function); WSMenuBar* app_menubar() { return m_app_menubar.ptr(); } bool is_showing_modal_window() const; void notify_about_new_screen_rect(const Rect&); void notify_about_clipboard_contents_changed(); void post_paint_message(WSWindow&); WSMenu* find_menu_by_id(int menu_id) { auto menu = m_menus.get(menu_id); if (!menu.has_value()) return nullptr; return const_cast(menu.value().ptr()); } private: explicit WSClientConnection(CLocalSocket&, int client_id); virtual OwnPtr handle(const WindowServer::Greet&) override; virtual OwnPtr handle(const WindowServer::CreateMenubar&) override; virtual OwnPtr handle(const WindowServer::DestroyMenubar&) override; virtual OwnPtr handle(const WindowServer::CreateMenu&) override; virtual OwnPtr handle(const WindowServer::DestroyMenu&) override; virtual OwnPtr handle(const WindowServer::AddMenuToMenubar&) override; virtual OwnPtr handle(const WindowServer::SetApplicationMenubar&) override; virtual OwnPtr handle(const WindowServer::AddMenuItem&) override; virtual OwnPtr handle(const WindowServer::AddMenuSeparator&) override; virtual OwnPtr handle(const WindowServer::UpdateMenuItem&) override; virtual OwnPtr handle(const WindowServer::CreateWindow&) override; virtual OwnPtr handle(const WindowServer::DestroyWindow&) override; virtual OwnPtr handle(const WindowServer::SetWindowTitle&) override; virtual OwnPtr handle(const WindowServer::GetWindowTitle&) override; virtual OwnPtr handle(const WindowServer::SetWindowRect&) override; virtual OwnPtr handle(const WindowServer::GetWindowRect&) override; virtual void handle(const WindowServer::InvalidateRect&) override; virtual void handle(const WindowServer::DidFinishPainting&) override; virtual OwnPtr handle(const WindowServer::SetGlobalCursorTracking&) override; virtual OwnPtr handle(const WindowServer::SetWindowOpacity&) override; virtual OwnPtr handle(const WindowServer::SetWindowBackingStore&) override; virtual OwnPtr handle(const WindowServer::GetClipboardContents&) override; virtual OwnPtr handle(const WindowServer::SetClipboardContents&) override; virtual void handle(const WindowServer::WM_SetActiveWindow&) override; virtual void handle(const WindowServer::WM_SetWindowMinimized&) override; virtual void handle(const WindowServer::WM_StartWindowResize&) override; virtual void handle(const WindowServer::WM_PopupWindowMenu&) override; virtual OwnPtr handle(const WindowServer::SetWindowHasAlphaChannel&) override; virtual OwnPtr handle(const WindowServer::MoveWindowToFront&) override; virtual OwnPtr handle(const WindowServer::SetFullscreen&) override; virtual void handle(const WindowServer::AsyncSetWallpaper&) override; virtual OwnPtr handle(const WindowServer::GetWallpaper&) override; virtual OwnPtr handle(const WindowServer::SetResolution&) override; virtual OwnPtr handle(const WindowServer::SetWindowOverrideCursor&) override; virtual OwnPtr handle(const WindowServer::PopupMenu&) override; virtual OwnPtr handle(const WindowServer::DismissMenu&) override; virtual OwnPtr handle(const WindowServer::SetWindowIconBitmap&) override; virtual void handle(const WindowServer::WM_SetWindowTaskbarRect&) override; virtual OwnPtr handle(const WindowServer::StartDrag&) override; HashMap> m_windows; HashMap> m_menubars; HashMap> m_menus; WeakPtr m_app_menubar; int m_next_menubar_id { 10000 }; int m_next_menu_id { 20000 }; int m_next_window_id { 1982 }; RefPtr m_last_sent_clipboard_content; };