WSClientConnection.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <AK/HashMap.h>
  3. #include <AK/OwnPtr.h>
  4. #include <AK/WeakPtr.h>
  5. #include <AK/Function.h>
  6. #include <SharedGraphics/GraphicsBitmap.h>
  7. #include <WindowServer/WSMessageReceiver.h>
  8. #include <WindowServer/WSMessage.h>
  9. class WSWindow;
  10. class WSMenu;
  11. class WSMenuBar;
  12. struct WSAPI_ServerMessage;
  13. class WSClientConnection final : public WSMessageReceiver {
  14. public:
  15. explicit WSClientConnection(int fd);
  16. virtual ~WSClientConnection() override;
  17. static WSClientConnection* from_client_id(int client_id);
  18. static void for_each_client(Function<void(WSClientConnection&)>);
  19. void post_message(const WSAPI_ServerMessage&);
  20. RetainPtr<GraphicsBitmap> create_shared_bitmap(GraphicsBitmap::Format, const Size&);
  21. int client_id() const { return m_client_id; }
  22. WSMenuBar* app_menubar() { return m_app_menubar.ptr(); }
  23. int fd() const { return m_fd; }
  24. pid_t pid() const { return m_pid; }
  25. private:
  26. virtual void on_message(WSMessage&) override;
  27. void on_request(WSAPIClientRequest&);
  28. void handle_request(WSAPICreateMenubarRequest&);
  29. void handle_request(WSAPIDestroyMenubarRequest&);
  30. void handle_request(WSAPICreateMenuRequest&);
  31. void handle_request(WSAPIDestroyMenuRequest&);
  32. void handle_request(WSAPISetApplicationMenubarRequest&);
  33. void handle_request(WSAPIAddMenuToMenubarRequest&);
  34. void handle_request(WSAPIAddMenuItemRequest&);
  35. void handle_request(WSAPIAddMenuSeparatorRequest&);
  36. void handle_request(WSAPISetWindowTitleRequest&);
  37. void handle_request(WSAPIGetWindowTitleRequest&);
  38. void handle_request(WSAPISetWindowRectRequest&);
  39. void handle_request(WSAPIGetWindowRectRequest&);
  40. void handle_request(WSAPISetClipboardContentsRequest&);
  41. void handle_request(WSAPIGetClipboardContentsRequest&);
  42. void handle_request(WSAPICreateWindowRequest&);
  43. void handle_request(WSAPIDestroyWindowRequest&);
  44. void handle_request(WSAPIInvalidateRectRequest&);
  45. void handle_request(WSAPIDidFinishPaintingNotification&);
  46. void handle_request(WSAPIGetWindowBackingStoreRequest&);
  47. void handle_request(WSAPISetWindowBackingStoreRequest&);
  48. void handle_request(WSAPISetGlobalCursorTrackingRequest&);
  49. void handle_request(WSAPISetWindowOpacityRequest&);
  50. void post_error(const String&);
  51. int m_client_id { 0 };
  52. int m_fd { -1 };
  53. pid_t m_pid { 0 };
  54. HashMap<int, OwnPtr<WSWindow>> m_windows;
  55. HashMap<int, OwnPtr<WSMenuBar>> m_menubars;
  56. HashMap<int, OwnPtr<WSMenu>> m_menus;
  57. WeakPtr<WSMenuBar> m_app_menubar;
  58. int m_next_menubar_id { 10000 };
  59. int m_next_menu_id { 20000 };
  60. int m_next_window_id { 1982 };
  61. RetainPtr<SharedBuffer> m_last_sent_clipboard_content;
  62. };