mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 19:05:58 +01:00
keybindmgr: add optional silent
suffix to movewindow
. (#5597)
With the `silent` suffix, the focus remains on the current position in the layout or the current monitor, instead of following the moved window. When combined with `movewindow mon:X`, this this allows you to get the same behavior as xmonad's `windowToScreen` command.
This commit is contained in:
parent
e8e02e81e8
commit
e57a2d7ec8
6 changed files with 36 additions and 15 deletions
|
@ -897,11 +897,13 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
|
||||||
return hints;
|
return hints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) {
|
void CHyprDwindleLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, bool silent) {
|
||||||
if (!isDirection(dir))
|
if (!isDirection(dir))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto PNODE = getNodeFromWindow(pWindow);
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
|
const int originalWorkspaceID = pWindow->workspaceID();
|
||||||
|
const Vector2D originalPos = pWindow->middle();
|
||||||
|
|
||||||
if (!PNODE)
|
if (!PNODE)
|
||||||
return;
|
return;
|
||||||
|
@ -934,6 +936,13 @@ void CHyprDwindleLayout::moveWindowTo(CWindow* pWindow, const std::string& dir)
|
||||||
onWindowCreatedTiling(pWindow);
|
onWindowCreatedTiling(pWindow);
|
||||||
|
|
||||||
m_vOverrideFocalPoint.reset();
|
m_vOverrideFocalPoint.reset();
|
||||||
|
|
||||||
|
// restore focus to the previous position
|
||||||
|
if (silent) {
|
||||||
|
const auto PNODETOFOCUS = getClosestNodeOnWorkspace(originalWorkspaceID, originalPos);
|
||||||
|
if (PNODETOFOCUS && PNODETOFOCUS->pWindow)
|
||||||
|
g_pCompositor->focusWindow(PNODETOFOCUS->pWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ class CHyprDwindleLayout : public IHyprLayout {
|
||||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||||
virtual void switchWindows(CWindow*, CWindow*);
|
virtual void switchWindows(CWindow*, CWindow*);
|
||||||
virtual void moveWindowTo(CWindow*, const std::string& dir);
|
virtual void moveWindowTo(CWindow*, const std::string& dir, bool silent);
|
||||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||||
virtual std::string getLayoutName();
|
virtual std::string getLayoutName();
|
||||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
||||||
|
|
|
@ -136,7 +136,7 @@ class IHyprLayout {
|
||||||
Called when the user requests a window move in a direction.
|
Called when the user requests a window move in a direction.
|
||||||
The layout is free to ignore.
|
The layout is free to ignore.
|
||||||
*/
|
*/
|
||||||
virtual void moveWindowTo(CWindow*, const std::string& direction) = 0;
|
virtual void moveWindowTo(CWindow*, const std::string& direction, bool silent = false) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when the user requests to change the splitratio by or to X
|
Called when the user requests to change the splitratio by or to X
|
||||||
|
|
|
@ -949,7 +949,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow)
|
||||||
return hints; // master doesnt have any hints
|
return hints; // master doesnt have any hints
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) {
|
void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir, bool silent) {
|
||||||
if (!isDirection(dir))
|
if (!isDirection(dir))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -965,12 +965,16 @@ void CHyprMasterLayout::moveWindowTo(CWindow* pWindow, const std::string& dir) {
|
||||||
onWindowRemovedTiling(pWindow);
|
onWindowRemovedTiling(pWindow);
|
||||||
pWindow->moveToWorkspace(PWINDOW2->m_pWorkspace);
|
pWindow->moveToWorkspace(PWINDOW2->m_pWorkspace);
|
||||||
pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID;
|
pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID;
|
||||||
|
if (!silent) {
|
||||||
const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
g_pCompositor->setActiveMonitor(pMonitor);
|
g_pCompositor->setActiveMonitor(pMonitor);
|
||||||
|
}
|
||||||
onWindowCreatedTiling(pWindow);
|
onWindowCreatedTiling(pWindow);
|
||||||
} else {
|
} else {
|
||||||
// if same monitor, switch windows
|
// if same monitor, switch windows
|
||||||
switchWindows(pWindow, PWINDOW2);
|
switchWindows(pWindow, PWINDOW2);
|
||||||
|
if (silent)
|
||||||
|
g_pCompositor->focusWindow(PWINDOW2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class CHyprMasterLayout : public IHyprLayout {
|
||||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||||
virtual void switchWindows(CWindow*, CWindow*);
|
virtual void switchWindows(CWindow*, CWindow*);
|
||||||
virtual void moveWindowTo(CWindow*, const std::string& dir);
|
virtual void moveWindowTo(CWindow*, const std::string& dir, bool silent);
|
||||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||||
virtual std::string getLayoutName();
|
virtual std::string getLayoutName();
|
||||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to);
|
||||||
|
|
|
@ -1217,14 +1217,19 @@ void CKeybindManager::swapActive(std::string args) {
|
||||||
|
|
||||||
void CKeybindManager::moveActiveTo(std::string args) {
|
void CKeybindManager::moveActiveTo(std::string args) {
|
||||||
char arg = args[0];
|
char arg = args[0];
|
||||||
|
bool silent = args.ends_with(" silent");
|
||||||
|
if (silent)
|
||||||
|
args = args.substr(0, args.length() - 7);
|
||||||
|
|
||||||
if (args.starts_with("mon:")) {
|
if (args.starts_with("mon:")) {
|
||||||
const auto PNEWMONITOR = g_pCompositor->getMonitorFromString(args.substr(4));
|
const auto PNEWMONITOR = g_pCompositor->getMonitorFromString(args.substr(4));
|
||||||
if (!PNEWMONITOR)
|
if (!PNEWMONITOR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (silent)
|
||||||
|
moveActiveToWorkspaceSilent(PNEWMONITOR->activeWorkspace->getConfigName());
|
||||||
|
else
|
||||||
moveActiveToWorkspace(PNEWMONITOR->activeWorkspace->getConfigName());
|
moveActiveToWorkspace(PNEWMONITOR->activeWorkspace->getConfigName());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDirection(args)) {
|
if (!isDirection(args)) {
|
||||||
|
@ -1258,7 +1263,8 @@ void CKeybindManager::moveActiveTo(std::string args) {
|
||||||
// If the window to change to is on the same workspace, switch them
|
// If the window to change to is on the same workspace, switch them
|
||||||
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
||||||
if (PWINDOWTOCHANGETO) {
|
if (PWINDOWTOCHANGETO) {
|
||||||
g_pLayoutManager->getCurrentLayout()->moveWindowTo(PLASTWINDOW, args);
|
g_pLayoutManager->getCurrentLayout()->moveWindowTo(PLASTWINDOW, args, silent);
|
||||||
|
if (!silent)
|
||||||
g_pCompositor->warpCursorTo(PLASTWINDOW->middle());
|
g_pCompositor->warpCursorTo(PLASTWINDOW->middle());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1275,9 @@ void CKeybindManager::moveActiveTo(std::string args) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto PWORKSPACE = PMONITORTOCHANGETO->activeWorkspace;
|
const auto PWORKSPACE = PMONITORTOCHANGETO->activeWorkspace;
|
||||||
|
if (silent)
|
||||||
|
moveActiveToWorkspaceSilent(PWORKSPACE->getConfigName());
|
||||||
|
else
|
||||||
moveActiveToWorkspace(PWORKSPACE->getConfigName());
|
moveActiveToWorkspace(PWORKSPACE->getConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue