Skip to content

Commit

Permalink
keybinds: movewindow to screen edge for floating windows (#3245)
Browse files Browse the repository at this point in the history
* movewindow to screen edge for floating windows

* review changes

* constify vars

---------

Co-authored-by: Leeman <lstrout@enlj.com>
Co-authored-by: vaxerski <vaxry@vaxry.net>
  • Loading branch information
3 people committed Sep 11, 2023
1 parent e96e0dc commit 99fac59
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,24 @@ void CKeybindManager::moveActiveTo(std::string args) {
if (!PLASTWINDOW || PLASTWINDOW->m_bIsFullscreen)
return;

if (PLASTWINDOW->m_bIsFloating) {
auto vPos = PLASTWINDOW->m_vRealPosition.goalv();
const auto PMONITOR = g_pCompositor->getMonitorFromID(PLASTWINDOW->m_iMonitorID);
const auto BORDERSIZE = PLASTWINDOW->getRealBorderSize();

switch (arg) {
case 'l': vPos.x = PMONITOR->vecReservedTopLeft.x + BORDERSIZE; break;
case 'r': vPos.x = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PLASTWINDOW->m_vRealSize.goalv().x - BORDERSIZE; break;
case 't':
case 'u': vPos.y = PMONITOR->vecReservedTopLeft.y + BORDERSIZE; break;
case 'b':
case 'd': vPos.y = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PLASTWINDOW->m_vRealSize.goalv().y - BORDERSIZE; break;
}

PLASTWINDOW->m_vRealPosition = vPos + PMONITOR->vecPosition;
return;
}

// If the window to change to is on the same workspace, switch them
const auto PWINDOWTOCHANGETO = g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
if (PWINDOWTOCHANGETO) {
Expand Down

0 comments on commit 99fac59

Please sign in to comment.