mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-27 02:49:48 +01:00
Added layoutmsg and some master layout msgs
This commit is contained in:
parent
b6f2a4bc36
commit
3904351678
3 changed files with 111 additions and 1 deletions
|
@ -406,7 +406,110 @@ void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
|||
}
|
||||
|
||||
std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::string message) {
|
||||
return "";
|
||||
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO);
|
||||
Vector2D middle = PWINDOWTOCHANGETO->m_vRealPosition.goalv() + PWINDOWTOCHANGETO->m_vRealSize.goalv() / 2.f;
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, middle.x, middle.y);
|
||||
};
|
||||
|
||||
if (message == "swapwithmaster") {
|
||||
|
||||
const auto PWINDOW = header.pWindow;
|
||||
|
||||
if (!isWindowTiled(PWINDOW))
|
||||
return 0;
|
||||
|
||||
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
|
||||
|
||||
if (!PMASTER || PMASTER->pWindow == PWINDOW)
|
||||
return 0;
|
||||
|
||||
switchWindows(PWINDOW, PMASTER->pWindow);
|
||||
|
||||
switchToWindow(PWINDOW);
|
||||
|
||||
return 0;
|
||||
} else if (message == "cyclenext") {
|
||||
const auto PWINDOW = header.pWindow;
|
||||
|
||||
if (!isWindowTiled(PWINDOW))
|
||||
return 0;
|
||||
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
||||
if (PNODE->isMaster) {
|
||||
// focus the first non master
|
||||
for (auto n : m_lMasterNodesData) {
|
||||
if (n.pWindow != PWINDOW && n.workspaceID == PWINDOW->m_iWorkspaceID) {
|
||||
switchToWindow(n.pWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// focus next
|
||||
bool reached = false;
|
||||
bool found = false;
|
||||
for (auto n : m_lMasterNodesData) {
|
||||
if (n.pWindow == PWINDOW) {
|
||||
reached = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (n.workspaceID == PWINDOW->m_iWorkspaceID && reached) {
|
||||
switchToWindow(n.pWindow);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
|
||||
|
||||
if (PMASTER)
|
||||
switchToWindow(PMASTER->pWindow);
|
||||
}
|
||||
}
|
||||
} else if (message == "cycleprev") {
|
||||
const auto PWINDOW = header.pWindow;
|
||||
|
||||
if (!isWindowTiled(PWINDOW))
|
||||
return 0;
|
||||
|
||||
const auto PNODE = getNodeFromWindow(PWINDOW);
|
||||
|
||||
if (PNODE->isMaster) {
|
||||
// focus the first non master
|
||||
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
|
||||
if (it->pWindow != PWINDOW && it->workspaceID == PWINDOW->m_iWorkspaceID) {
|
||||
switchToWindow(it->pWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// focus next
|
||||
bool reached = false;
|
||||
bool found = false;
|
||||
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
|
||||
if (it->pWindow == PWINDOW) {
|
||||
reached = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (it->workspaceID == PWINDOW->m_iWorkspaceID && reached) {
|
||||
switchToWindow(it->pWindow);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
|
||||
|
||||
if (PMASTER)
|
||||
switchToWindow(PMASTER->pWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::onEnable() {
|
||||
|
|
|
@ -34,6 +34,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["focuswindow"] = focusWindow;
|
||||
m_mDispatchers["submap"] = setSubmap;
|
||||
m_mDispatchers["pass"] = pass;
|
||||
m_mDispatchers["layoutmsg"] = layoutmsg;
|
||||
|
||||
m_tScrollTimer.reset();
|
||||
}
|
||||
|
@ -1303,4 +1304,9 @@ void CKeybindManager::pass(std::string regexp) {
|
|||
wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, g_pKeybindManager->m_uTimeLastMs, g_pKeybindManager->m_uLastCode - 8, WLR_BUTTON_RELEASED);
|
||||
|
||||
wlr_seat_keyboard_notify_enter(g_pCompositor->m_sSeat.seat, PLASTSRF, KEYBOARD->keycodes, KEYBOARD->num_keycodes, &KEYBOARD->modifiers);
|
||||
}
|
||||
|
||||
void CKeybindManager::layoutmsg(std::string msg) {
|
||||
SLayoutMessageHeader hd = {g_pCompositor->m_pLastWindow};
|
||||
g_pLayoutManager->getCurrentLayout()->layoutMessage(hd, msg);
|
||||
}
|
|
@ -96,6 +96,7 @@ private:
|
|||
static void focusWindow(std::string);
|
||||
static void setSubmap(std::string);
|
||||
static void pass(std::string);
|
||||
static void layoutmsg(std::string);
|
||||
|
||||
friend class CCompositor;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue