diff options
author | vaxerski <[email protected]> | 2022-05-26 19:05:32 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-26 19:05:32 +0200 |
commit | 795504dad01e7d738f768315767523270e59ab54 (patch) | |
tree | f6038f349d9d66dd3e11af1f3aae67b690ca4ff1 | |
parent | 6751ec6f546a552d33931dee94b1a67907bee283 (diff) | |
download | Hyprland-795504dad01e7d738f768315767523270e59ab54.tar.gz Hyprland-795504dad01e7d738f768315767523270e59ab54.zip |
Added workspaceopt dispatcher
-rw-r--r-- | src/Window.hpp | 2 | ||||
-rw-r--r-- | src/events/Windows.cpp | 14 | ||||
-rw-r--r-- | src/helpers/Workspace.hpp | 4 | ||||
-rw-r--r-- | src/managers/KeybindManager.cpp | 57 | ||||
-rw-r--r-- | src/managers/KeybindManager.hpp | 1 |
5 files changed, 77 insertions, 1 deletions
diff --git a/src/Window.hpp b/src/Window.hpp index f68a5686..c7b711c2 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -54,6 +54,8 @@ public: bool m_bIsMapped = false; + bool m_bRequestsFloat = false; + // This is for fullscreen apps bool m_bCreatedOverFullscreen = false; diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 67425de4..6e18fdf3 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -45,8 +45,20 @@ void Events::listener_mapWindow(void* owner, void* data) { return; } - if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) + if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) { PWINDOW->m_bIsFloating = true; + PWINDOW->m_bRequestsFloat = true; + } + + if (PWORKSPACE->m_bDefaultFloating) + PWINDOW->m_bIsFloating = true; + + if (PWORKSPACE->m_bDefaultPseudo) { + PWINDOW->m_bIsPseudotiled = true; + wlr_box desiredGeometry = {0}; + g_pXWaylandManager->getGeometryForWindow(PWINDOW, &desiredGeometry); + PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height); + } if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) { const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 6347a63b..683f03ae 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -23,6 +23,10 @@ public: CAnimatedVariable m_vRenderOffset; CAnimatedVariable m_fAlpha; + // user-set + bool m_bDefaultFloating = false; + bool m_bDefaultPseudo = false; + void startAnim(bool in, bool left); void setActive(bool on); };
\ No newline at end of file diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index f6e4f037..10d47849 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -19,6 +19,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["splitratio"] = alterSplitRatio; m_mDispatchers["focusmonitor"] = focusMonitor; m_mDispatchers["movecursortocorner"] = moveCursorToCorner; + m_mDispatchers["workspaceopt"] = workspaceOpt; } void CKeybindManager::addKeybind(SKeybind kb) { @@ -608,4 +609,60 @@ void CKeybindManager::moveCursorToCorner(std::string arg) { wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y); break; } +} + +void CKeybindManager::workspaceOpt(std::string args) { + + // current workspace + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); + + if (!PWORKSPACE) + return; // ???? + + if (args == "allpseudo") { + PWORKSPACE->m_bDefaultPseudo = !PWORKSPACE->m_bDefaultPseudo; + + // apply + for (auto& w : g_pCompositor->m_lWindows) { + if (!w.m_bIsMapped || w.m_iWorkspaceID != PWORKSPACE->m_iID) + continue; + + w.m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo; + } + } else if (args == "allfloat") { + PWORKSPACE->m_bDefaultFloating = !PWORKSPACE->m_bDefaultFloating; + // apply + + // we make a copy because changeWindowFloatingMode might invalidate the iterator + std::deque<CWindow*> ptrs; + for (auto& w : g_pCompositor->m_lWindows) + ptrs.push_back(&w); + + for (auto& w : ptrs) { + if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID) + continue; + + if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) { + const auto SAVEDPOS = w->m_vRealPosition.vec(); + const auto SAVEDSIZE = w->m_vRealSize.vec(); + + w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating; + g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(w); + + if (PWORKSPACE->m_bDefaultFloating) { + w->m_vRealPosition.setValueAndWarp(SAVEDPOS); + w->m_vRealSize.setValueAndWarp(SAVEDSIZE); + g_pXWaylandManager->setWindowSize(w, SAVEDSIZE); + w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4,4); + w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2,2); + } + } + } + } else { + Debug::log(ERR, "Invalid arg in workspaceOpt, opt \"%s\" doesn't exist.", args.c_str()); + return; + } + + // recalc mon + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); }
\ No newline at end of file diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index b07510d0..cf028111 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -49,6 +49,7 @@ private: static void focusMonitor(std::string); static void toggleSplit(std::string); static void moveCursorToCorner(std::string); + static void workspaceOpt(std::string); }; inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
\ No newline at end of file |