mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 19:05:59 +01:00
Added movetoworkspace
This commit is contained in:
parent
f82fdb012e
commit
f108ec78e2
4 changed files with 70 additions and 5 deletions
|
@ -34,4 +34,15 @@ bind=SUPER,6,workspace,6
|
||||||
bind=SUPER,7,workspace,7
|
bind=SUPER,7,workspace,7
|
||||||
bind=SUPER,8,workspace,8
|
bind=SUPER,8,workspace,8
|
||||||
bind=SUPER,9,workspace,9
|
bind=SUPER,9,workspace,9
|
||||||
bind=SUPER,0,workspace,10
|
bind=SUPER,0,workspace,10
|
||||||
|
|
||||||
|
bind=ALT,1,movetoworkspace,1
|
||||||
|
bind=ALT,2,movetoworkspace,2
|
||||||
|
bind=ALT,3,movetoworkspace,3
|
||||||
|
bind=ALT,4,movetoworkspace,4
|
||||||
|
bind=ALT,5,movetoworkspace,5
|
||||||
|
bind=ALT,6,movetoworkspace,6
|
||||||
|
bind=ALT,7,movetoworkspace,7
|
||||||
|
bind=ALT,8,movetoworkspace,8
|
||||||
|
bind=ALT,9,movetoworkspace,9
|
||||||
|
bind=ALT,0,movetoworkspace,10
|
|
@ -116,6 +116,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
|
if (pWindow->m_bIsFloating)
|
||||||
|
return;
|
||||||
|
|
||||||
m_lDwindleNodesData.push_back(SDwindleNodeData());
|
m_lDwindleNodesData.push_back(SDwindleNodeData());
|
||||||
const auto PNODE = &m_lDwindleNodesData.back();
|
const auto PNODE = &m_lDwindleNodesData.back();
|
||||||
|
|
||||||
|
@ -127,7 +130,13 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
PNODE->isNode = false;
|
PNODE->isNode = false;
|
||||||
PNODE->layout = this;
|
PNODE->layout = this;
|
||||||
|
|
||||||
SDwindleNodeData* OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
SDwindleNodeData* OPENINGON;
|
||||||
|
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
|
||||||
|
|
||||||
|
if (PMONITOR == MONFROMCURSOR)
|
||||||
|
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
||||||
|
else
|
||||||
|
OPENINGON = getFirstNodeOnWorkspace(MONFROMCURSOR->activeWorkspace);
|
||||||
|
|
||||||
// if it's the first, it's easy. Make it fullscreen.
|
// if it's the first, it's easy. Make it fullscreen.
|
||||||
if (!OPENINGON) {
|
if (!OPENINGON) {
|
||||||
|
|
|
@ -35,10 +35,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
// oMg such performance hit!!11!
|
// oMg such performance hit!!11!
|
||||||
// this little maneouver is gonna cost us 4µs
|
// this little maneouver is gonna cost us 4µs
|
||||||
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
// TODO: fix this with shift, shift makes all the keys uppercase
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
||||||
// if (shift) KBKEY -= someindex
|
|
||||||
|
|
||||||
if (key != KBKEY)
|
if (key != KBKEY && key != KBKEYUPPER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// yes.
|
// yes.
|
||||||
|
@ -47,6 +46,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
|
||||||
else if (k.handler == "togglefloating") { toggleActiveFloating(k.arg); }
|
else if (k.handler == "togglefloating") { toggleActiveFloating(k.arg); }
|
||||||
else if (k.handler == "workspace") { changeworkspace(k.arg); }
|
else if (k.handler == "workspace") { changeworkspace(k.arg); }
|
||||||
else if (k.handler == "fullscreen") { fullscreenActive(k.arg); }
|
else if (k.handler == "fullscreen") { fullscreenActive(k.arg); }
|
||||||
|
else if (k.handler == "movetoworkspace") { moveActiveToWorkspace(k.arg); }
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -155,4 +155,48 @@ void CKeybindManager::fullscreenActive(std::string args) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW);
|
g_pLayoutManager->getCurrentLayout()->fullscreenRequestForWindow(PWINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
|
const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus);
|
||||||
|
|
||||||
|
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int workspaceID;
|
||||||
|
try {
|
||||||
|
workspaceID = stoi(args);
|
||||||
|
} catch( ... ) {
|
||||||
|
Debug::log(ERR, "Invalid movetoworkspace: %s", args.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
||||||
|
|
||||||
|
const auto OLDWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID);
|
||||||
|
|
||||||
|
// hack
|
||||||
|
g_pKeybindManager->changeworkspace(std::to_string(workspaceID));
|
||||||
|
|
||||||
|
const auto NEWWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
||||||
|
|
||||||
|
OLDWORKSPACE->hasFullscreenWindow = false;
|
||||||
|
|
||||||
|
PWINDOW->m_iWorkspaceID = workspaceID;
|
||||||
|
PWINDOW->m_iMonitorID = NEWWORKSPACE->monitorID;
|
||||||
|
PWINDOW->m_bIsFullscreen = false;
|
||||||
|
|
||||||
|
if (NEWWORKSPACE->hasFullscreenWindow) {
|
||||||
|
g_pCompositor->getFullscreenWindowOnWorkspace(workspaceID)->m_bIsFullscreen = false;
|
||||||
|
NEWWORKSPACE->hasFullscreenWindow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hack: So that the layout doesnt find our window at the cursor
|
||||||
|
PWINDOW->m_vPosition = Vector2D(-42069, -42069);
|
||||||
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
||||||
|
|
||||||
|
if (PWINDOW->m_bIsFloating) {
|
||||||
|
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition - g_pCompositor->getMonitorFromID(OLDWORKSPACE->monitorID)->vecPosition;
|
||||||
|
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition + g_pCompositor->getMonitorFromID(NEWWORKSPACE->monitorID)->vecPosition;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,7 @@ private:
|
||||||
void toggleActiveFloating(std::string);
|
void toggleActiveFloating(std::string);
|
||||||
void changeworkspace(std::string);
|
void changeworkspace(std::string);
|
||||||
void fullscreenActive(std::string);
|
void fullscreenActive(std::string);
|
||||||
|
void moveActiveToWorkspace(std::string);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
Loading…
Reference in a new issue