summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-11 19:51:37 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-11 19:51:37 +0200
commita8e872923045eddd314bc26553401a6eb17c57cc (patch)
treee8fa6a207b485cebd78f752e7683452000f0be48 /src/helpers
parentb56343133d21622a6187bb1ef8906023ecbc09ef (diff)
Added zext_workspace protocol support 🎉
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/Monitor.hpp4
-rw-r--r--src/helpers/Workspace.cpp29
-rw-r--r--src/helpers/Workspace.hpp16
3 files changed, 45 insertions, 4 deletions
diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp
index b3f10893..3f88bed1 100644
--- a/src/helpers/Monitor.hpp
+++ b/src/helpers/Monitor.hpp
@@ -33,6 +33,10 @@ struct SMonitor {
DYNLISTENER(monitorFrame);
DYNLISTENER(monitorDestroy);
+ // hack: a group = workspaces on a monitor.
+ // I don't really care lol :P
+ wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
+
// For the list lookup
diff --git a/src/helpers/Workspace.cpp b/src/helpers/Workspace.cpp
new file mode 100644
index 00000000..8c535941
--- /dev/null
+++ b/src/helpers/Workspace.cpp
@@ -0,0 +1,29 @@
+#include "Workspace.hpp"
+#include "../Compositor.hpp"
+
+CWorkspace::CWorkspace(int monitorID) {
+ const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
+
+ if (!PMONITOR) {
+ Debug::log(ERR, "Attempted a creation of CWorkspace with an invalid monitor?");
+ return;
+ }
+
+ m_iMonitorID = monitorID;
+
+ m_pWlrHandle = wlr_ext_workspace_handle_v1_create(PMONITOR->pWLRWorkspaceGroupHandle);
+
+ // set geometry here cuz we can
+ wl_array_init(&m_wlrCoordinateArr);
+ *reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.x;
+ *reinterpret_cast<int*>(wl_array_add(&m_wlrCoordinateArr, sizeof(int))) = (int)PMONITOR->vecPosition.y;
+ wlr_ext_workspace_handle_v1_set_coordinates(m_pWlrHandle, &m_wlrCoordinateArr);
+}
+
+CWorkspace::~CWorkspace() {
+ if (m_pWlrHandle) {
+ wlr_ext_workspace_handle_v1_set_active(m_pWlrHandle, false);
+ wlr_ext_workspace_handle_v1_destroy(m_pWlrHandle);
+ m_pWlrHandle = nullptr;
+ }
+} \ No newline at end of file
diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp
index d4ec5b05..465c385b 100644
--- a/src/helpers/Workspace.hpp
+++ b/src/helpers/Workspace.hpp
@@ -2,8 +2,16 @@
#include "../defines.hpp"
-struct SWorkspace {
- int ID = -1;
- uint64_t monitorID = -1;
- bool hasFullscreenWindow = false;
+class CWorkspace {
+public:
+ CWorkspace(int monitorID);
+ ~CWorkspace();
+
+ int m_iID = -1;
+ uint64_t m_iMonitorID = -1;
+ bool m_bHasFullscreenWindow = false;
+
+ wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
+
+ wl_array m_wlrCoordinateArr;
}; \ No newline at end of file