mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-26 23:49:49 +01:00
keybinds: implement pushactivetobottom dispacher (#3217)
Co-authored-by: Leeman <lstrout@enlj.com>
This commit is contained in:
parent
d41a91e050
commit
e4ddfcfa0c
9 changed files with 79 additions and 36 deletions
|
@ -1240,15 +1240,24 @@ bool CCompositor::isWindowActive(CWindow* pWindow) {
|
|||
return PSURFACE == m_pLastFocus || pWindow == m_pLastWindow;
|
||||
}
|
||||
|
||||
void CCompositor::moveWindowToTop(CWindow* pWindow) {
|
||||
void CCompositor::changeWindowZOrder(CWindow* pWindow, bool top) {
|
||||
if (!windowValidMapped(pWindow))
|
||||
return;
|
||||
|
||||
auto moveToTop = [&](CWindow* pw) -> void {
|
||||
for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
|
||||
if (it->get() == pw) {
|
||||
std::rotate(it, it + 1, m_vWindows.end());
|
||||
break;
|
||||
auto moveToZ = [&](CWindow* pw, bool top) -> void {
|
||||
if (top) {
|
||||
for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
|
||||
if (it->get() == pw) {
|
||||
std::rotate(it, it + 1, m_vWindows.end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); ++it) {
|
||||
if (it->get() == pw) {
|
||||
std::rotate(it, it + 1, m_vWindows.rend());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1256,28 +1265,36 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
|
|||
g_pHyprRenderer->damageMonitor(getMonitorFromID(pw->m_iMonitorID));
|
||||
};
|
||||
|
||||
moveToTop(pWindow);
|
||||
if (top)
|
||||
pWindow->m_bCreatedOverFullscreen = true;
|
||||
|
||||
pWindow->m_bCreatedOverFullscreen = true;
|
||||
|
||||
if (!pWindow->m_bIsX11)
|
||||
if (!pWindow->m_bIsX11) {
|
||||
moveToZ(pWindow, top);
|
||||
return;
|
||||
} else {
|
||||
// move X11 window stack
|
||||
|
||||
// move all children
|
||||
std::deque<CWindow*> toMove;
|
||||
|
||||
std::deque<CWindow*> toMove;
|
||||
auto x11Stack = [&](CWindow* pw, bool top, auto&& x11Stack) -> void {
|
||||
if (top)
|
||||
toMove.emplace_back(pw);
|
||||
else
|
||||
toMove.emplace_front(pw);
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_bIsMapped && w->m_bMappedX11 && !w->isHidden() && w->m_bIsX11 && w->X11TransientFor() == pWindow) {
|
||||
toMove.emplace_back(w.get());
|
||||
for (auto& w : m_vWindows) {
|
||||
if (w->m_bIsMapped && w->m_bMappedX11 && !w->isHidden() && w->m_bIsX11 && w->X11TransientFor() == pw) {
|
||||
x11Stack(w.get(), top, x11Stack);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
x11Stack(pWindow, top, x11Stack);
|
||||
|
||||
for (auto it : toMove) {
|
||||
moveToZ(it, top);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& pw : toMove) {
|
||||
moveToTop(pw);
|
||||
|
||||
moveWindowToTop(pw);
|
||||
}
|
||||
}
|
||||
|
||||
void CCompositor::cleanupFadingOut(const int& monid) {
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
#include "hyprerror/HyprError.hpp"
|
||||
#include "plugins/PluginSystem.hpp"
|
||||
|
||||
enum eManagersInitStage
|
||||
{
|
||||
enum eManagersInitStage {
|
||||
STAGE_PRIORITY = 0,
|
||||
STAGE_LATE
|
||||
};
|
||||
|
@ -160,7 +159,7 @@ class CCompositor {
|
|||
CWindow* getFullscreenWindowOnWorkspace(const int&);
|
||||
bool doesSeatAcceptInput(wlr_surface*);
|
||||
bool isWindowActive(CWindow*);
|
||||
void moveWindowToTop(CWindow*);
|
||||
void changeWindowZOrder(CWindow*, bool);
|
||||
void cleanupFadingOut(const int& monid);
|
||||
CWindow* getWindowInDirection(CWindow*, char);
|
||||
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||
|
|
|
@ -406,7 +406,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
// because the windows are animated on RealSize
|
||||
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv();
|
||||
|
||||
g_pCompositor->moveWindowToTop(PWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
} else {
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
||||
|
||||
|
@ -903,7 +903,7 @@ void Events::listener_activateXDG(wl_listener* listener, void* data) {
|
|||
return;
|
||||
|
||||
if (PWINDOW->m_bIsFloating)
|
||||
g_pCompositor->moveWindowToTop(PWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
g_pCompositor->warpCursorTo(PWINDOW->middle());
|
||||
|
@ -937,7 +937,7 @@ void Events::listener_activateX11(void* owner, void* data) {
|
|||
return;
|
||||
|
||||
if (PWINDOW->m_bIsFloating)
|
||||
g_pCompositor->moveWindowToTop(PWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
g_pCompositor->warpCursorTo(PWINDOW->middle());
|
||||
|
@ -985,7 +985,7 @@ void Events::listener_configureX11(void* owner, void* data) {
|
|||
|
||||
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace;
|
||||
|
||||
g_pCompositor->moveWindowToTop(PWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
|
||||
PWINDOW->m_bCreatedOverFullscreen = true;
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
|
|||
|
||||
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromVector(PWINDOW->m_vRealPosition.vec() + PWINDOW->m_vRealSize.vec() / 2.f)->activeWorkspace;
|
||||
|
||||
g_pCompositor->moveWindowToTop(PWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
PWINDOW->updateWindowDecos();
|
||||
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||
}
|
||||
|
|
|
@ -851,7 +851,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
|||
|
||||
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
|
||||
|
||||
g_pCompositor->moveWindowToTop(pWindow);
|
||||
g_pCompositor->changeWindowZOrder(pWindow, true);
|
||||
|
||||
recalculateMonitor(PMONITOR->ID);
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
|||
if (pWindow->m_iX11Type != 2) {
|
||||
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
|
||||
|
||||
g_pCompositor->moveWindowToTop(pWindow);
|
||||
g_pCompositor->changeWindowZOrder(pWindow, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ void IHyprLayout::onBeginDragWindow() {
|
|||
g_pKeybindManager->shadowKeybinds();
|
||||
|
||||
g_pCompositor->focusWindow(DRAGGINGWINDOW);
|
||||
g_pCompositor->moveWindowToTop(DRAGGINGWINDOW);
|
||||
g_pCompositor->changeWindowZOrder(DRAGGINGWINDOW, true);
|
||||
}
|
||||
|
||||
void IHyprLayout::onEndDragWindow() {
|
||||
|
@ -436,7 +436,7 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
} else {
|
||||
onWindowRemovedTiling(pWindow);
|
||||
|
||||
g_pCompositor->moveWindowToTop(pWindow);
|
||||
g_pCompositor->changeWindowZOrder(pWindow, true);
|
||||
|
||||
if (DELTALESSTHAN(pWindow->m_vRealSize.vec().x, pWindow->m_vLastFloatingSize.x, 10) && DELTALESSTHAN(pWindow->m_vRealSize.vec().y, pWindow->m_vLastFloatingSize.y, 10)) {
|
||||
pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f + Vector2D{10, 10};
|
||||
|
|
|
@ -868,7 +868,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
|||
|
||||
g_pXWaylandManager->setWindowSize(pWindow, pWindow->m_vRealSize.goalv());
|
||||
|
||||
g_pCompositor->moveWindowToTop(pWindow);
|
||||
g_pCompositor->changeWindowZOrder(pWindow, true);
|
||||
|
||||
recalculateMonitor(PMONITOR->ID);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["pin"] = pinActive;
|
||||
m_mDispatchers["mouse"] = mouse;
|
||||
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
||||
m_mDispatchers["alterzorder"] = alterZOrder;
|
||||
m_mDispatchers["focusurgentorlast"] = focusUrgentOrLast;
|
||||
m_mDispatchers["focuscurrentorlast"] = focusCurrentOrLast;
|
||||
m_mDispatchers["lockgroups"] = lockGroups;
|
||||
|
@ -1910,7 +1911,32 @@ void CKeybindManager::mouse(std::string args) {
|
|||
|
||||
void CKeybindManager::bringActiveToTop(std::string args) {
|
||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
|
||||
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
||||
g_pCompositor->changeWindowZOrder(g_pCompositor->m_pLastWindow, true);
|
||||
}
|
||||
|
||||
void CKeybindManager::alterZOrder(std::string args) {
|
||||
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
||||
const auto POSITION = args.substr(0, args.find_first_of(','));
|
||||
auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||
|
||||
if (!PWINDOW && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
|
||||
PWINDOW = g_pCompositor->m_pLastWindow;
|
||||
|
||||
if (!PWINDOW) {
|
||||
Debug::log(ERR, "alterZOrder: no window");
|
||||
return;
|
||||
}
|
||||
|
||||
if (POSITION == "top")
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, 1);
|
||||
else if (POSITION == "bottom")
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, 0);
|
||||
else {
|
||||
Debug::log(ERR, "alterZOrder: bad position: %s", POSITION);
|
||||
return;
|
||||
}
|
||||
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
}
|
||||
|
||||
void CKeybindManager::fakeFullscreenActive(std::string args) {
|
||||
|
|
|
@ -143,6 +143,7 @@ class CKeybindManager {
|
|||
static void pinActive(std::string);
|
||||
static void mouse(std::string);
|
||||
static void bringActiveToTop(std::string);
|
||||
static void alterZOrder(std::string);
|
||||
static void lockGroups(std::string);
|
||||
static void lockActiveGroup(std::string);
|
||||
static void moveIntoGroup(std::string);
|
||||
|
|
|
@ -600,7 +600,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
|||
|
||||
// if clicked on a floating window make it top
|
||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsFloating)
|
||||
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
||||
g_pCompositor->changeWindowZOrder(g_pCompositor->m_pLastWindow, true);
|
||||
|
||||
break;
|
||||
case WLR_BUTTON_RELEASED: break;
|
||||
|
|
Loading…
Reference in a new issue