summaryrefslogtreecommitdiff
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-04-14 15:03:53 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-04-14 15:03:53 +0100
commit287e6c4ede30c8e5e85863cd85f157e17e24879c (patch)
tree68d6ece9e46bb81bfbc15610b2043494c66f4624 /src/helpers/Monitor.cpp
parent011600ac6e7f6d52f69d0890bffba519a9d81e3f (diff)
internal: workspace manip handling rework
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index cae76e8b..08883ba4 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -475,3 +475,81 @@ float CMonitor::getDefaultScale() {
return 1.5;
return 1;
}
+
+void CMonitor::changeWorkspace(CWorkspace* const pWorkspace, bool internal) {
+ if (!pWorkspace || pWorkspace->m_iID == activeWorkspace)
+ return;
+
+ if (pWorkspace->m_bIsSpecialWorkspace) {
+ Debug::log(ERR, "BUG THIS: Attempted to changeWorkspace to special!");
+ return;
+ }
+
+ const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(activeWorkspace);
+
+ activeWorkspace = pWorkspace->m_iID;
+
+ if (!internal) {
+ const auto ANIMTOLEFT = pWorkspace->m_iID > POLDWORKSPACE->m_iID;
+ POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
+ pWorkspace->startAnim(true, ANIMTOLEFT);
+
+ // move pinned windows
+ for (auto& w : g_pCompositor->m_vWindows) {
+ if (w->m_iWorkspaceID == POLDWORKSPACE->m_iID && w->m_bPinned) {
+ w->m_iWorkspaceID = pWorkspace->m_iID;
+ }
+ }
+
+ if (const auto PLASTWINDOW = pWorkspace->getLastFocusedWindow(); PLASTWINDOW)
+ g_pCompositor->focusWindow(PLASTWINDOW);
+ else {
+ g_pCompositor->focusWindow(nullptr);
+ g_pInputManager->refocus();
+ }
+
+ // set some flags and fire event
+ POLDWORKSPACE->setActive(false);
+ pWorkspace->setActive(true);
+ g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_szName});
+ EMIT_HOOK_EVENT("workspace", pWorkspace);
+ }
+}
+
+void CMonitor::changeWorkspace(const int& id, bool internal) {
+ changeWorkspace(g_pCompositor->getWorkspaceByID(id), internal);
+}
+
+void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) {
+ if (!pWorkspace) {
+ // remove special if exists
+ if (const auto EXISTINGSPECIAL = g_pCompositor->getWorkspaceByID(specialWorkspaceID); EXISTINGSPECIAL)
+ EXISTINGSPECIAL->startAnim(false, false);
+ specialWorkspaceID = 0;
+
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
+
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(activeWorkspace);
+ if (const auto PLAST = PWORKSPACE->getLastFocusedWindow(); PLAST)
+ g_pCompositor->focusWindow(PLAST);
+ else
+ g_pInputManager->refocus();
+
+ return;
+ }
+
+ // open special
+ specialWorkspaceID = pWorkspace->m_iID;
+ pWorkspace->startAnim(true, true);
+
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
+
+ if (const auto PLAST = pWorkspace->getLastFocusedWindow(); PLAST)
+ g_pCompositor->focusWindow(PLAST);
+ else
+ g_pInputManager->refocus();
+}
+
+void CMonitor::setSpecialWorkspace(const int& id) {
+ setSpecialWorkspace(g_pCompositor->getWorkspaceByID(id));
+}