From ecf282d331a8aa19c0fe10c739cd31d3b3ab64a2 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 25 Apr 2024 00:58:40 +0100 Subject: wlr-foreign-toplevel: move to new impl --- src/protocols/ForeignToplevelWlr.hpp | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/protocols/ForeignToplevelWlr.hpp (limited to 'src/protocols/ForeignToplevelWlr.hpp') diff --git a/src/protocols/ForeignToplevelWlr.hpp b/src/protocols/ForeignToplevelWlr.hpp new file mode 100644 index 00000000..c22a71cd --- /dev/null +++ b/src/protocols/ForeignToplevelWlr.hpp @@ -0,0 +1,77 @@ +#pragma once + +#include +#include +#include "WaylandProtocol.hpp" +#include "wlr-foreign-toplevel-management-unstable-v1.hpp" + +class CWindow; +class CMonitor; + +class CForeignToplevelHandleWlr { + public: + CForeignToplevelHandleWlr(SP resource_, CWindow* pWindow); + + bool good(); + CWindow* window(); + wl_resource* res(); + + private: + SP resource; + CWindow* pWindow = nullptr; + bool closed = false; + int64_t lastMonitorID = -1; + + void sendMonitor(CMonitor* pMonitor); + void sendState(); + + friend class CForeignToplevelWlrManager; +}; + +class CForeignToplevelWlrManager { + public: + CForeignToplevelWlrManager(SP resource_); + + void onMap(CWindow* pWindow); + void onTitle(CWindow* pWindow); + void onClass(CWindow* pWindow); + void onMoveMonitor(CWindow* pWindow); + void onFullscreen(CWindow* pWindow); + void onNewFocus(CWindow* pWindow); + void onUnmap(CWindow* pWindow); + + bool good(); + + private: + SP resource; + bool finished = false; + CWindow* lastFocus = nullptr; // READ-ONLY + + SP handleForWindow(CWindow* pWindow); + + std::vector> handles; +}; + +class CForeignToplevelWlrProtocol : public IWaylandProtocol { + public: + CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name); + + virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); + + CWindow* windowFromHandleResource(wl_resource* res); + + private: + void onManagerResourceDestroy(CForeignToplevelWlrManager* mgr); + void destroyHandle(CForeignToplevelHandleWlr* handle); + + // + std::vector> m_vManagers; + std::vector> m_vHandles; + + friend class CForeignToplevelWlrManager; + friend class CForeignToplevelHandleWlr; +}; + +namespace PROTO { + inline UP foreignToplevelWlr; +}; -- cgit v1.2.3