keybinds: Added toggleswallow dispatcher (#5548)
* Added `toggleswallow` dispatcher * clang-format * Removed brackets for 1-line if
This commit is contained in:
parent
3b99e906df
commit
84c9baecc6
5 changed files with 38 additions and 7 deletions
|
|
@ -452,9 +452,11 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto SWALLOWED = m_pSwallowed.lock()) {
|
if (const auto SWALLOWED = m_pSwallowed.lock()) {
|
||||||
|
if (SWALLOWED->m_bCurrentlySwallowed) {
|
||||||
SWALLOWED->moveToWorkspace(pWorkspace);
|
SWALLOWED->moveToWorkspace(pWorkspace);
|
||||||
SWALLOWED->m_pMonitor = m_pMonitor;
|
SWALLOWED->m_pMonitor = m_pMonitor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update xwayland coords
|
// update xwayland coords
|
||||||
sendWindowSize(m_vRealSize->goal());
|
sendWindowSize(m_vRealSize->goal());
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,7 @@ class CWindow {
|
||||||
|
|
||||||
// swallowing
|
// swallowing
|
||||||
PHLWINDOWREF m_pSwallowed;
|
PHLWINDOWREF m_pSwallowed;
|
||||||
|
bool m_bCurrentlySwallowed = false;
|
||||||
bool m_bGroupSwallowed = false;
|
bool m_bGroupSwallowed = false;
|
||||||
|
|
||||||
// focus stuff
|
// focus stuff
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
// Verify window swallowing. Get the swallower before calling onWindowCreated(PWINDOW) because getSwallower() wouldn't get it after if PWINDOW gets auto grouped.
|
// Verify window swallowing. Get the swallower before calling onWindowCreated(PWINDOW) because getSwallower() wouldn't get it after if PWINDOW gets auto grouped.
|
||||||
const auto SWALLOWER = PWINDOW->getSwallower();
|
const auto SWALLOWER = PWINDOW->getSwallower();
|
||||||
PWINDOW->m_pSwallowed = SWALLOWER;
|
PWINDOW->m_pSwallowed = SWALLOWER;
|
||||||
|
if (PWINDOW->m_pSwallowed)
|
||||||
|
PWINDOW->m_pSwallowed->m_bCurrentlySwallowed = true;
|
||||||
|
|
||||||
if (PWINDOW->m_bIsFloating) {
|
if (PWINDOW->m_bIsFloating) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
||||||
|
|
@ -731,12 +733,15 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
// swallowing
|
// swallowing
|
||||||
if (valid(PWINDOW->m_pSwallowed)) {
|
if (valid(PWINDOW->m_pSwallowed)) {
|
||||||
|
if (PWINDOW->m_pSwallowed->m_bCurrentlySwallowed) {
|
||||||
|
PWINDOW->m_pSwallowed->m_bCurrentlySwallowed = false;
|
||||||
PWINDOW->m_pSwallowed->setHidden(false);
|
PWINDOW->m_pSwallowed->setHidden(false);
|
||||||
|
|
||||||
if (PWINDOW->m_sGroupData.pNextWindow.lock())
|
if (PWINDOW->m_sGroupData.pNextWindow.lock())
|
||||||
PWINDOW->m_pSwallowed->m_bGroupSwallowed = true; // flag for the swallowed window to be created into the group where it belongs when auto_group = false.
|
PWINDOW->m_pSwallowed->m_bGroupSwallowed = true; // flag for the swallowed window to be created into the group where it belongs when auto_group = false.
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed.lock());
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW->m_pSwallowed.lock());
|
||||||
|
}
|
||||||
|
|
||||||
PWINDOW->m_pSwallowed->m_bGroupSwallowed = false;
|
PWINDOW->m_pSwallowed->m_bGroupSwallowed = false;
|
||||||
PWINDOW->m_pSwallowed.reset();
|
PWINDOW->m_pSwallowed.reset();
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||||
m_mDispatchers["focuswindow"] = focusWindow;
|
m_mDispatchers["focuswindow"] = focusWindow;
|
||||||
m_mDispatchers["tagwindow"] = tagWindow;
|
m_mDispatchers["tagwindow"] = tagWindow;
|
||||||
|
m_mDispatchers["toggleswallow"] = toggleSwallow;
|
||||||
m_mDispatchers["submap"] = setSubmap;
|
m_mDispatchers["submap"] = setSubmap;
|
||||||
m_mDispatchers["pass"] = pass;
|
m_mDispatchers["pass"] = pass;
|
||||||
m_mDispatchers["sendshortcut"] = sendshortcut;
|
m_mDispatchers["sendshortcut"] = sendshortcut;
|
||||||
|
|
@ -2306,6 +2307,27 @@ SDispatchResult CKeybindManager::tagWindow(std::string args) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDispatchResult CKeybindManager::toggleSwallow(std::string args) {
|
||||||
|
PHLWINDOWREF pWindow = g_pCompositor->m_pLastWindow;
|
||||||
|
|
||||||
|
if (!valid(pWindow) || !valid(pWindow->m_pSwallowed))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
if (pWindow->m_pSwallowed->m_bCurrentlySwallowed) {
|
||||||
|
// Unswallow
|
||||||
|
pWindow->m_pSwallowed->m_bCurrentlySwallowed = false;
|
||||||
|
pWindow->m_pSwallowed->setHidden(false);
|
||||||
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(pWindow->m_pSwallowed.lock());
|
||||||
|
} else {
|
||||||
|
// Reswallow
|
||||||
|
pWindow->m_pSwallowed->m_bCurrentlySwallowed = true;
|
||||||
|
pWindow->m_pSwallowed->setHidden(true);
|
||||||
|
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow->m_pSwallowed.lock());
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::setSubmap(std::string submap) {
|
SDispatchResult CKeybindManager::setSubmap(std::string submap) {
|
||||||
if (submap == "reset" || submap == "") {
|
if (submap == "reset" || submap == "") {
|
||||||
m_szCurrentSelectedSubmap = "";
|
m_szCurrentSelectedSubmap = "";
|
||||||
|
|
|
||||||
|
|
@ -199,6 +199,7 @@ class CKeybindManager {
|
||||||
static SDispatchResult circleNext(std::string);
|
static SDispatchResult circleNext(std::string);
|
||||||
static SDispatchResult focusWindow(std::string);
|
static SDispatchResult focusWindow(std::string);
|
||||||
static SDispatchResult tagWindow(std::string);
|
static SDispatchResult tagWindow(std::string);
|
||||||
|
static SDispatchResult toggleSwallow(std::string);
|
||||||
static SDispatchResult setSubmap(std::string);
|
static SDispatchResult setSubmap(std::string);
|
||||||
static SDispatchResult pass(std::string);
|
static SDispatchResult pass(std::string);
|
||||||
static SDispatchResult sendshortcut(std::string);
|
static SDispatchResult sendshortcut(std::string);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue