summaryrefslogtreecommitdiff
path: root/src/protocols/ForeignToplevelWlr.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-25 00:58:40 +0100
committerVaxry <vaxry@vaxry.net>2024-04-25 01:10:43 +0100
commitecf282d331a8aa19c0fe10c739cd31d3b3ab64a2 (patch)
tree8e2e83df8613f5a18e0a584911004b47ff688bf0 /src/protocols/ForeignToplevelWlr.hpp
parent72e31d3335982382c289302a41f7144009c5c82f (diff)
wlr-foreign-toplevel: move to new impl
Diffstat (limited to 'src/protocols/ForeignToplevelWlr.hpp')
-rw-r--r--src/protocols/ForeignToplevelWlr.hpp77
1 files changed, 77 insertions, 0 deletions
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 <memory>
+#include <vector>
+#include "WaylandProtocol.hpp"
+#include "wlr-foreign-toplevel-management-unstable-v1.hpp"
+
+class CWindow;
+class CMonitor;
+
+class CForeignToplevelHandleWlr {
+ public:
+ CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHandleV1> resource_, CWindow* pWindow);
+
+ bool good();
+ CWindow* window();
+ wl_resource* res();
+
+ private:
+ SP<CZwlrForeignToplevelHandleV1> 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<CZwlrForeignToplevelManagerV1> 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<CZwlrForeignToplevelManagerV1> resource;
+ bool finished = false;
+ CWindow* lastFocus = nullptr; // READ-ONLY
+
+ SP<CForeignToplevelHandleWlr> handleForWindow(CWindow* pWindow);
+
+ std::vector<WP<CForeignToplevelHandleWlr>> 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<UP<CForeignToplevelWlrManager>> m_vManagers;
+ std::vector<SP<CForeignToplevelHandleWlr>> m_vHandles;
+
+ friend class CForeignToplevelWlrManager;
+ friend class CForeignToplevelHandleWlr;
+};
+
+namespace PROTO {
+ inline UP<CForeignToplevelWlrProtocol> foreignToplevelWlr;
+};