mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-14 04:45:58 +01:00
Added workspaceopt dispatcher
This commit is contained in:
parent
6751ec6f54
commit
795504dad0
5 changed files with 77 additions and 1 deletions
|
@ -54,6 +54,8 @@ public:
|
||||||
|
|
||||||
bool m_bIsMapped = false;
|
bool m_bIsMapped = false;
|
||||||
|
|
||||||
|
bool m_bRequestsFloat = false;
|
||||||
|
|
||||||
// This is for fullscreen apps
|
// This is for fullscreen apps
|
||||||
bool m_bCreatedOverFullscreen = false;
|
bool m_bCreatedOverFullscreen = false;
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,20 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_pXWaylandManager->shouldBeFloated(PWINDOW))
|
if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) {
|
||||||
PWINDOW->m_bIsFloating = true;
|
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) {
|
if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) {
|
||||||
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||||
|
|
|
@ -23,6 +23,10 @@ public:
|
||||||
CAnimatedVariable m_vRenderOffset;
|
CAnimatedVariable m_vRenderOffset;
|
||||||
CAnimatedVariable m_fAlpha;
|
CAnimatedVariable m_fAlpha;
|
||||||
|
|
||||||
|
// user-set
|
||||||
|
bool m_bDefaultFloating = false;
|
||||||
|
bool m_bDefaultPseudo = false;
|
||||||
|
|
||||||
void startAnim(bool in, bool left);
|
void startAnim(bool in, bool left);
|
||||||
void setActive(bool on);
|
void setActive(bool on);
|
||||||
};
|
};
|
|
@ -19,6 +19,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||||
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
||||||
|
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::addKeybind(SKeybind kb) {
|
void CKeybindManager::addKeybind(SKeybind kb) {
|
||||||
|
@ -609,3 +610,59 @@ void CKeybindManager::moveCursorToCorner(std::string arg) {
|
||||||
break;
|
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);
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ private:
|
||||||
static void focusMonitor(std::string);
|
static void focusMonitor(std::string);
|
||||||
static void toggleSplit(std::string);
|
static void toggleSplit(std::string);
|
||||||
static void moveCursorToCorner(std::string);
|
static void moveCursorToCorner(std::string);
|
||||||
|
static void workspaceOpt(std::string);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
Loading…
Reference in a new issue