|
| 1 | +#ifndef __C_WINDOW_XCB_H_INCLUDED__ |
| 2 | +#define __C_WINDOW_XCB_H_INCLUDED__ |
| 3 | + |
| 4 | +#include <cstdlib> |
| 5 | + |
| 6 | +#include "nbl/core/decl/smart_refctd_ptr.h" |
| 7 | +#include "nbl/ui/CClipboardManagerXcb.h" |
| 8 | +#include "nbl/ui/IWindowXcb.h" |
| 9 | +#include "nbl/ui/XcbConnection.h" |
| 10 | + |
| 11 | +namespace nbl::ui |
| 12 | +{ |
| 13 | + |
| 14 | +class CCursorControlXcb; |
| 15 | +class CWindowManagerXcb; |
| 16 | +class CClipboardManagerXcb; |
| 17 | + |
| 18 | +class NBL_API2 CWindowXcb final : public IWindowXcb |
| 19 | +{ |
| 20 | + |
| 21 | +public: |
| 22 | + CWindowXcb(core::smart_refctd_ptr<CWindowManagerXcb>&& winManager, SCreationParams&& params); |
| 23 | + ~CWindowXcb(); |
| 24 | + |
| 25 | + // Display* getDisplay() const override { return m_dpy; } |
| 26 | + xcb_window_t getXcbWindow() const override { return m_xcbWindow; } |
| 27 | + xcb_connection_t* getXcbConnection() const override { |
| 28 | + return m_xcbConnection->getRawConnection(); |
| 29 | + } |
| 30 | + |
| 31 | + virtual IClipboardManager* getClipboardManager() override; |
| 32 | + virtual ICursorControl* getCursorControl() override; |
| 33 | + virtual IWindowManager* getManager() override; |
| 34 | + |
| 35 | + virtual bool setWindowSize_impl(uint32_t width, uint32_t height) override; |
| 36 | + virtual bool setWindowPosition_impl(int32_t x, int32_t y) override; |
| 37 | + virtual bool setWindowRotation_impl(bool landscape) override; |
| 38 | + virtual bool setWindowVisible_impl(bool visible) override; |
| 39 | + virtual bool setWindowMaximized_impl(bool maximized) override; |
| 40 | + |
| 41 | + virtual void setCaption(const std::string_view& caption) override; |
| 42 | + |
| 43 | +private: |
| 44 | + CWindowXcb(core::smart_refctd_ptr<system::ISystem>&& sys, uint32_t _w, uint32_t _h, E_CREATE_FLAGS _flags); |
| 45 | + |
| 46 | + core::smart_refctd_ptr<CWindowManagerXcb> m_windowManager; |
| 47 | + core::smart_refctd_ptr<XcbConnection> m_xcbConnection; |
| 48 | + core::smart_refctd_ptr<CCursorControlXcb> m_cursorControl; |
| 49 | + core::smart_refctd_ptr<CClipboardManagerXcb> m_clipboardManager; |
| 50 | + |
| 51 | + class CDispatchThread final : public system::IThreadHandler<CDispatchThread> |
| 52 | + { |
| 53 | + public: |
| 54 | + |
| 55 | + inline CDispatchThread(CWindowXcb& window); |
| 56 | + inline ~CDispatchThread() { |
| 57 | + } |
| 58 | + |
| 59 | + void init(); |
| 60 | + void exit(); |
| 61 | + void work(lock_t& lock); |
| 62 | + |
| 63 | + inline bool wakeupPredicate() const { return true; } |
| 64 | + inline bool continuePredicate() const { return true; } |
| 65 | + private: |
| 66 | + CWindowXcb& m_window; |
| 67 | + // xcb_connection_t* m_connection = nullptr; |
| 68 | + friend class CWindowXcb; |
| 69 | + } m_dispatcher; |
| 70 | + |
| 71 | + xcb_window_t m_xcbWindow = 0; |
| 72 | + |
| 73 | + XcbConnection::XCBAtomToken<core::StringLiteral("WM_DELETE_WINDOW")> m_WM_DELETE_WINDOW; |
| 74 | + XcbConnection::XCBAtomToken<core::StringLiteral("WM_PROTOCOLS")> m_WM_PROTOCOLS; |
| 75 | + XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_PING")> m_NET_WM_PING; |
| 76 | + |
| 77 | + XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_VERT")> m_NET_WM_STATE_MAXIMIZED_VERT; |
| 78 | + XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_MAXIMIZED_HORZ")> m_NET_WM_STATE_MAXIMIZED_HORZ; |
| 79 | + XcbConnection::XCBAtomToken<core::StringLiteral("_NET_WM_STATE_FULLSCREEN")> m_NET_WM_STATE_FULLSCREEN; |
| 80 | + |
| 81 | +}; |
| 82 | + |
| 83 | +} |
| 84 | + |
| 85 | +#endif |
0 commit comments