compositor: Configurable behavior when window to be focused conflicts with fullscreen (#12033)
Renames `misc:new_window_takes_over_fullscreen` into `misc:on_focus_under_fullscreen` and implements the following behavior: - By default, when a tiling window is being focused on a workspace where a fullscreen/maximized window exists, respect the `misc:on_focus_under_fullscreen` config variable.
This commit is contained in:
parent
1c1746de61
commit
40d8fa8491
51 changed files with 1003 additions and 694 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "../config/ConfigValue.hpp"
|
||||
#include "../devices/IKeyboard.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../managers/SeatManager.hpp"
|
||||
#include "../protocols/LayerShell.hpp"
|
||||
#include "../protocols/ShortcutsInhibit.hpp"
|
||||
|
|
@ -53,7 +54,7 @@ static std::vector<std::pair<std::string, std::string>> getHyprlandLaunchEnv(PHL
|
|||
if (!*PINITIALWSTRACKING || g_pConfigManager->m_isLaunchingExecOnce)
|
||||
return {};
|
||||
|
||||
const auto PMONITOR = g_pCompositor->m_lastMonitor;
|
||||
const auto PMONITOR = Desktop::focusState()->monitor();
|
||||
if (!PMONITOR || !PMONITOR->m_activeWorkspace)
|
||||
return {};
|
||||
|
||||
|
|
@ -336,15 +337,15 @@ static void updateRelativeCursorCoords() {
|
|||
if (*PNOWARPS)
|
||||
return;
|
||||
|
||||
if (g_pCompositor->m_lastWindow)
|
||||
g_pCompositor->m_lastWindow->m_relativeCursorCoordsOnLastWarp = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_lastWindow->m_position;
|
||||
if (Desktop::focusState()->window())
|
||||
Desktop::focusState()->window()->m_relativeCursorCoordsOnLastWarp = g_pInputManager->getMouseCoordsInternal() - Desktop::focusState()->window()->m_position;
|
||||
}
|
||||
|
||||
bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
||||
if (!monitor)
|
||||
return false;
|
||||
|
||||
const auto LASTMONITOR = g_pCompositor->m_lastMonitor.lock();
|
||||
const auto LASTMONITOR = Desktop::focusState()->monitor();
|
||||
if (!LASTMONITOR)
|
||||
return false;
|
||||
if (LASTMONITOR == monitor) {
|
||||
|
|
@ -355,7 +356,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
|||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
||||
const auto PWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||
const auto PNEWMAINWORKSPACE = monitor->m_activeWorkspace;
|
||||
|
||||
g_pInputManager->unconstrainMouse();
|
||||
|
|
@ -366,7 +367,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
|||
const auto PNEWWINDOW = PNEWWORKSPACE->getLastFocusedWindow();
|
||||
if (PNEWWINDOW) {
|
||||
updateRelativeCursorCoords();
|
||||
g_pCompositor->focusWindow(PNEWWINDOW);
|
||||
Desktop::focusState()->fullWindowFocus(PNEWWINDOW);
|
||||
PNEWWINDOW->warpCursor();
|
||||
|
||||
if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) {
|
||||
|
|
@ -375,19 +376,19 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
|
|||
g_pInputManager->m_forcedFocus.reset();
|
||||
}
|
||||
} else {
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
Desktop::focusState()->rawWindowFocus(nullptr);
|
||||
g_pCompositor->warpCursorTo(monitor->middle());
|
||||
}
|
||||
g_pCompositor->setActiveMonitor(monitor);
|
||||
Desktop::focusState()->rawMonitorFocus(monitor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory) {
|
||||
void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory, bool forceFSCycle) {
|
||||
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
|
||||
static auto PNOWARPS = CConfigValue<Hyprlang::INT>("cursor:no_warps");
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
|
||||
return;
|
||||
|
|
@ -395,24 +396,11 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveF
|
|||
// remove constraints
|
||||
g_pInputManager->unconstrainMouse();
|
||||
|
||||
if (PLASTWINDOW && PLASTWINDOW->m_workspace == PWINDOWTOCHANGETO->m_workspace && PLASTWINDOW->isFullscreen()) {
|
||||
const auto PWORKSPACE = PLASTWINDOW->m_workspace;
|
||||
const auto MODE = PWORKSPACE->m_fullscreenMode;
|
||||
|
||||
if (!PWINDOWTOCHANGETO->m_pinned)
|
||||
g_pCompositor->setWindowFullscreenInternal(PLASTWINDOW, FSMODE_NONE);
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory);
|
||||
|
||||
if (!PWINDOWTOCHANGETO->m_pinned)
|
||||
g_pCompositor->setWindowFullscreenInternal(PWINDOWTOCHANGETO, MODE);
|
||||
|
||||
// warp the position + size animation, otherwise it looks weird.
|
||||
PWINDOWTOCHANGETO->m_realPosition->warp();
|
||||
PWINDOWTOCHANGETO->m_realSize->warp();
|
||||
} else {
|
||||
if (PLASTWINDOW && PLASTWINDOW->m_workspace == PWINDOWTOCHANGETO->m_workspace)
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
|
||||
else {
|
||||
updateRelativeCursorCoords();
|
||||
g_pCompositor->focusWindow(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory);
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOWTOCHANGETO, nullptr, preserveFocusHistory, forceFSCycle);
|
||||
PWINDOWTOCHANGETO->warpCursor();
|
||||
|
||||
// Move mouse focus to the new window if required by current follow_mouse and warp modes
|
||||
|
|
@ -426,7 +414,7 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveF
|
|||
// event
|
||||
const auto PNEWMON = PWINDOWTOCHANGETO->m_monitor.lock();
|
||||
|
||||
g_pCompositor->setActiveMonitor(PNEWMON);
|
||||
Desktop::focusState()->rawMonitorFocus(PNEWMON);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -998,7 +986,7 @@ uint64_t CKeybindManager::spawnRawProc(std::string args, PHLWORKSPACE pInitialWo
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::killActive(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW) {
|
||||
Debug::log(ERR, "killActive: no window found");
|
||||
|
|
@ -1011,10 +999,10 @@ SDispatchResult CKeybindManager::killActive(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::closeActive(std::string args) {
|
||||
if (g_pCompositor->m_lastWindow && g_pCompositor->m_lastWindow->m_closeableSince > Time::steadyNow())
|
||||
if (Desktop::focusState()->window() && Desktop::focusState()->window()->m_closeableSince > Time::steadyNow())
|
||||
return {.success = false, .error = "can't close window, it's not closeable yet (noclosefor)"};
|
||||
|
||||
g_pCompositor->closeWindow(g_pCompositor->m_lastWindow.lock());
|
||||
g_pCompositor->closeWindow(Desktop::focusState()->window());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -1058,13 +1046,13 @@ SDispatchResult CKeybindManager::signalActive(std::string args) {
|
|||
Debug::log(ERR, "signalActive: invalid signal number {}", SIGNALNUM);
|
||||
return {.success = false, .error = std::format("signalActive: invalid signal number {}", SIGNALNUM)};
|
||||
}
|
||||
kill(g_pCompositor->m_lastWindow.lock()->getPID(), SIGNALNUM);
|
||||
kill(Desktop::focusState()->window()->getPID(), SIGNALNUM);
|
||||
} catch (const std::exception& e) {
|
||||
Debug::log(ERR, "signalActive: invalid signal format \"{}\"", args);
|
||||
return {.success = false, .error = std::format("signalActive: invalid signal format \"{}\"", args)};
|
||||
}
|
||||
|
||||
kill(g_pCompositor->m_lastWindow.lock()->getPID(), std::stoi(args));
|
||||
kill(Desktop::focusState()->window()->getPID(), std::stoi(args));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -1108,7 +1096,7 @@ static SDispatchResult toggleActiveFloatingCore(std::string args, std::optional<
|
|||
if (args != "active" && args.length() > 1)
|
||||
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
||||
else
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1118,7 +1106,7 @@ static SDispatchResult toggleActiveFloatingCore(std::string args, std::optional<
|
|||
|
||||
// remove drag status
|
||||
if (!g_pInputManager->m_currentlyDraggedWindow.expired())
|
||||
g_pKeybindManager->changeMouseBindMode(MBIND_INVALID);
|
||||
CKeybindManager::changeMouseBindMode(MBIND_INVALID);
|
||||
|
||||
if (PWINDOW->m_groupData.pNextWindow.lock() && PWINDOW->m_groupData.pNextWindow.lock() != PWINDOW) {
|
||||
const auto PCURRENT = PWINDOW->getGroupCurrent();
|
||||
|
|
@ -1161,7 +1149,7 @@ SDispatchResult CKeybindManager::setActiveTiled(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::centerWindow(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW || !PWINDOW->m_isFloating || PWINDOW->isFullscreen())
|
||||
return {.success = false, .error = "No floating window found"};
|
||||
|
|
@ -1184,7 +1172,7 @@ SDispatchResult CKeybindManager::toggleActivePseudo(std::string args) {
|
|||
if (args != "active" && args.length() > 1)
|
||||
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
||||
else
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1225,7 +1213,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
|||
static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
|
||||
static auto PHIDESPECIALONWORKSPACECHANGE = CConfigValue<Hyprlang::INT>("binds:hide_special_on_workspace_change");
|
||||
|
||||
const auto PMONITOR = g_pCompositor->m_lastMonitor.lock();
|
||||
const auto PMONITOR = Desktop::focusState()->monitor();
|
||||
|
||||
if (!PMONITOR)
|
||||
return {.success = false, .error = "Last monitor not found"};
|
||||
|
|
@ -1275,7 +1263,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
|||
|
||||
updateRelativeCursorCoords();
|
||||
|
||||
g_pCompositor->setActiveMonitor(PMONITORWORKSPACEOWNER);
|
||||
Desktop::focusState()->rawMonitorFocus(PMONITORWORKSPACEOWNER);
|
||||
|
||||
if (BISWORKSPACECURRENT) {
|
||||
if (*PALLOWWORKSPACECYCLES)
|
||||
|
|
@ -1292,7 +1280,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
|||
if (PMONITOR != PMONITORWORKSPACEOWNER) {
|
||||
Vector2D middle = PMONITORWORKSPACEOWNER->middle();
|
||||
if (const auto PLAST = pWorkspaceToChangeTo->getLastFocusedWindow(); PLAST) {
|
||||
g_pCompositor->focusWindow(PLAST);
|
||||
Desktop::focusState()->fullWindowFocus(PLAST);
|
||||
if (*PWORKSPACECENTERON == 1)
|
||||
middle = PLAST->middle();
|
||||
}
|
||||
|
|
@ -1300,7 +1288,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
|||
}
|
||||
|
||||
if (!g_pInputManager->m_lastFocusOnLS) {
|
||||
if (g_pCompositor->m_lastFocus)
|
||||
if (Desktop::focusState()->surface())
|
||||
g_pInputManager->sendMotionEventsToFocused();
|
||||
else
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
|
|
@ -1320,7 +1308,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::fullscreenActive(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
const auto ARGS = CConstVarList(args, 2, ' ');
|
||||
|
||||
if (!PWINDOW)
|
||||
|
|
@ -1344,7 +1332,7 @@ SDispatchResult CKeybindManager::fullscreenActive(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::fullscreenStateActive(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
const auto ARGS = CVarList(args, 3, ' ');
|
||||
|
||||
if (!PWINDOW)
|
||||
|
|
@ -1390,7 +1378,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
||||
args = args.substr(0, args.find_last_of(','));
|
||||
} else {
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
}
|
||||
|
||||
if (!PWINDOW)
|
||||
|
|
@ -1420,7 +1408,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
const auto FULLSCREENMODE = PWINDOW->m_fullscreenState.internal;
|
||||
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||
pMonitor = pWorkspace->m_monitor.lock();
|
||||
g_pCompositor->setActiveMonitor(pMonitor);
|
||||
Desktop::focusState()->rawMonitorFocus(pMonitor);
|
||||
g_pCompositor->setWindowFullscreenInternal(PWINDOW, FULLSCREENMODE);
|
||||
} else {
|
||||
pWorkspace = g_pCompositor->createNewWorkspace(WORKSPACEID, PWINDOW->monitorID(), workspaceName, false);
|
||||
|
|
@ -1440,7 +1428,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
|
||||
pMonitor->changeWorkspace(pWorkspace);
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOW);
|
||||
PWINDOW->warpCursor();
|
||||
|
||||
return {};
|
||||
|
|
@ -1453,7 +1441,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
||||
args = args.substr(0, args.find_last_of(','));
|
||||
} else {
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
}
|
||||
|
||||
if (!PWINDOW)
|
||||
|
|
@ -1480,9 +1468,9 @@ SDispatchResult CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, pWorkspace);
|
||||
}
|
||||
|
||||
if (PWINDOW == g_pCompositor->m_lastWindow) {
|
||||
if (PWINDOW == Desktop::focusState()->window()) {
|
||||
if (const auto PATCOORDS = g_pCompositor->vectorToWindowUnified(OLDMIDDLE, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING, PWINDOW); PATCOORDS)
|
||||
g_pCompositor->focusWindow(PATCOORDS);
|
||||
Desktop::focusState()->fullWindowFocus(PATCOORDS);
|
||||
else
|
||||
g_pInputManager->refocus();
|
||||
}
|
||||
|
|
@ -1501,7 +1489,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
|
|||
return {.success = false, .error = std::format("Cannot move focus in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
|
||||
}
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
if (!PLASTWINDOW) {
|
||||
if (*PMONITORFALLBACK)
|
||||
tryMoveFocusToMonitor(g_pCompositor->getMonitorInDirection(arg));
|
||||
|
|
@ -1529,7 +1517,7 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
|
|||
|
||||
// Found window in direction, switch to it
|
||||
if (PWINDOWTOCHANGETO) {
|
||||
switchToWindow(PWINDOWTOCHANGETO);
|
||||
switchToWindow(PWINDOWTOCHANGETO, false, *PFULLCYCLE && PLASTWINDOW->isFullscreen());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -1587,8 +1575,8 @@ SDispatchResult CKeybindManager::moveFocusTo(std::string args) {
|
|||
|
||||
SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
|
||||
const auto PWINDOWURGENT = g_pCompositor->getUrgentWindow();
|
||||
const auto PWINDOWPREV = g_pCompositor->m_lastWindow.lock() ? (g_pCompositor->m_windowFocusHistory.size() < 2 ? nullptr : g_pCompositor->m_windowFocusHistory[1].lock()) :
|
||||
(g_pCompositor->m_windowFocusHistory.empty() ? nullptr : g_pCompositor->m_windowFocusHistory[0].lock());
|
||||
const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
|
||||
(Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
|
||||
|
||||
if (!PWINDOWURGENT && !PWINDOWPREV)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1599,8 +1587,8 @@ SDispatchResult CKeybindManager::focusUrgentOrLast(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
|
||||
const auto PWINDOWPREV = g_pCompositor->m_lastWindow.lock() ? (g_pCompositor->m_windowFocusHistory.size() < 2 ? nullptr : g_pCompositor->m_windowFocusHistory[1].lock()) :
|
||||
(g_pCompositor->m_windowFocusHistory.empty() ? nullptr : g_pCompositor->m_windowFocusHistory[0].lock());
|
||||
const auto PWINDOWPREV = Desktop::focusState()->window() ? (Desktop::focusState()->windowHistory().size() < 2 ? nullptr : Desktop::focusState()->windowHistory()[1].lock()) :
|
||||
(Desktop::focusState()->windowHistory().empty() ? nullptr : Desktop::focusState()->windowHistory()[0].lock());
|
||||
|
||||
if (!PWINDOWPREV)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1612,7 +1600,7 @@ SDispatchResult CKeybindManager::focusCurrentOrLast(std::string args) {
|
|||
|
||||
SDispatchResult CKeybindManager::swapActive(std::string args) {
|
||||
char arg = args[0];
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
PHLWINDOW PWINDOWTOCHANGETO = nullptr;
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
|
|
@ -1663,7 +1651,7 @@ SDispatchResult CKeybindManager::moveActiveTo(std::string args) {
|
|||
return {.success = false, .error = std::format("Cannot move window in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
|
||||
}
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return {.success = false, .error = "Window to move not found"};
|
||||
|
|
@ -1729,7 +1717,7 @@ SDispatchResult CKeybindManager::moveActiveTo(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::toggleGroup(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1746,7 +1734,7 @@ SDispatchResult CKeybindManager::toggleGroup(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::changeGroupActive(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1779,7 +1767,7 @@ SDispatchResult CKeybindManager::changeGroupActive(std::string args) {
|
|||
|
||||
SDispatchResult CKeybindManager::toggleSplit(std::string args) {
|
||||
SLayoutMessageHeader header;
|
||||
header.pWindow = g_pCompositor->m_lastWindow.lock();
|
||||
header.pWindow = Desktop::focusState()->window();
|
||||
|
||||
if (!header.pWindow)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1796,7 +1784,7 @@ SDispatchResult CKeybindManager::toggleSplit(std::string args) {
|
|||
|
||||
SDispatchResult CKeybindManager::swapSplit(std::string args) {
|
||||
SLayoutMessageHeader header;
|
||||
header.pWindow = g_pCompositor->m_lastWindow.lock();
|
||||
header.pWindow = Desktop::focusState()->window();
|
||||
|
||||
if (!header.pWindow)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1826,7 +1814,7 @@ SDispatchResult CKeybindManager::alterSplitRatio(std::string args) {
|
|||
return {.success = false, .error = "Splitratio invalid in alterSplitRatio!"};
|
||||
}
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1856,7 +1844,7 @@ SDispatchResult CKeybindManager::moveCursorToCorner(std::string arg) {
|
|||
return {.success = false, .error = "moveCursorToCorner, corner not 0 - 3."};
|
||||
}
|
||||
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "Window not found"};
|
||||
|
|
@ -1918,7 +1906,7 @@ SDispatchResult CKeybindManager::moveCursor(std::string args) {
|
|||
SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
|
||||
|
||||
// current workspace
|
||||
const auto PWORKSPACE = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
||||
const auto PWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||
|
||||
if (!PWORKSPACE)
|
||||
return {.success = false, .error = "Workspace not found"}; // ????
|
||||
|
|
@ -1965,7 +1953,7 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
|
|||
}
|
||||
|
||||
// recalc mon
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_lastMonitor->m_id);
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(Desktop::focusState()->monitor()->m_id);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -2011,7 +1999,7 @@ SDispatchResult CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args)
|
|||
}
|
||||
|
||||
// get the current workspace
|
||||
const auto PCURRENTWORKSPACE = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
||||
const auto PCURRENTWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||
if (!PCURRENTWORKSPACE) {
|
||||
Debug::log(ERR, "moveCurrentWorkspaceToMonitor invalid workspace!");
|
||||
return {.success = false, .error = "moveCurrentWorkspaceToMonitor invalid workspace!"};
|
||||
|
|
@ -2062,7 +2050,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
|
|||
return {.success = false, .error = "focusWorkspaceOnCurrentMonitor invalid workspace!"};
|
||||
}
|
||||
|
||||
const auto PCURRMONITOR = g_pCompositor->m_lastMonitor.lock();
|
||||
const auto PCURRMONITOR = Desktop::focusState()->monitor();
|
||||
|
||||
if (!PCURRMONITOR) {
|
||||
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!");
|
||||
|
|
@ -2117,7 +2105,7 @@ SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
|||
}
|
||||
|
||||
bool requestedWorkspaceIsAlreadyOpen = false;
|
||||
const auto PMONITOR = g_pCompositor->m_lastMonitor;
|
||||
const auto PMONITOR = Desktop::focusState()->monitor();
|
||||
auto specialOpenOnMonitor = PMONITOR->activeSpecialWorkspaceID();
|
||||
|
||||
for (auto const& m : g_pCompositor->m_monitors) {
|
||||
|
|
@ -2183,7 +2171,7 @@ SDispatchResult CKeybindManager::forceRendererReload(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::resizeActive(std::string args) {
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
|
@ -2205,7 +2193,7 @@ SDispatchResult CKeybindManager::resizeActive(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::moveActive(std::string args) {
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
|
@ -2271,9 +2259,9 @@ SDispatchResult CKeybindManager::resizeWindow(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::circleNext(std::string arg) {
|
||||
if (g_pCompositor->m_lastWindow.expired()) {
|
||||
if (!Desktop::focusState()->window()) {
|
||||
// if we have a clear focus, find the first window and get the next focusable.
|
||||
const auto PWS = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
||||
const auto PWS = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||
if (PWS && PWS->getWindows() > 0) {
|
||||
const auto PWINDOW = PWS->getFirstWindow();
|
||||
switchToWindow(PWINDOW);
|
||||
|
|
@ -2294,8 +2282,8 @@ SDispatchResult CKeybindManager::circleNext(std::string arg) {
|
|||
const auto PREV = args.contains("prev") || args.contains("p") || args.contains("last") || args.contains("l");
|
||||
const auto NEXT = args.contains("next") || args.contains("n"); // prev is default in classic alt+tab
|
||||
const auto HIST = args.contains("hist") || args.contains("h");
|
||||
const auto& w = HIST ? g_pCompositor->getWindowCycleHist(g_pCompositor->m_lastWindow, true, floatStatus, VISIBLE, NEXT) :
|
||||
g_pCompositor->getWindowCycle(g_pCompositor->m_lastWindow.lock(), true, floatStatus, VISIBLE, PREV);
|
||||
const auto& w = HIST ? g_pCompositor->getWindowCycleHist(Desktop::focusState()->window(), true, floatStatus, VISIBLE, NEXT) :
|
||||
g_pCompositor->getWindowCycle(Desktop::focusState()->window(), true, floatStatus, VISIBLE, PREV);
|
||||
|
||||
switchToWindow(w, HIST);
|
||||
|
||||
|
|
@ -2318,40 +2306,13 @@ SDispatchResult CKeybindManager::focusWindow(std::string regexp) {
|
|||
|
||||
updateRelativeCursorCoords();
|
||||
|
||||
if (g_pCompositor->m_lastMonitor && g_pCompositor->m_lastMonitor->m_activeWorkspace != PWINDOW->m_workspace &&
|
||||
g_pCompositor->m_lastMonitor->m_activeSpecialWorkspace != PWINDOW->m_workspace) {
|
||||
if (Desktop::focusState()->monitor() && Desktop::focusState()->monitor()->m_activeWorkspace != PWINDOW->m_workspace &&
|
||||
Desktop::focusState()->monitor()->m_activeSpecialWorkspace != PWINDOW->m_workspace) {
|
||||
Debug::log(LOG, "Fake executing workspace to move focus");
|
||||
changeworkspace(PWORKSPACE->getConfigName());
|
||||
}
|
||||
|
||||
if (PWORKSPACE->m_hasFullscreenWindow) {
|
||||
const auto FSWINDOW = PWORKSPACE->getFullscreenWindow();
|
||||
const auto FSMODE = PWORKSPACE->m_fullscreenMode;
|
||||
|
||||
if (PWINDOW->m_isFloating) {
|
||||
// don't make floating implicitly fs
|
||||
if (!PWINDOW->m_createdOverFullscreen) {
|
||||
g_pCompositor->changeWindowZOrder(PWINDOW, true);
|
||||
g_pDesktopAnimationManager->setFullscreenFadeAnimation(
|
||||
PWORKSPACE, PWORKSPACE->m_hasFullscreenWindow ? CDesktopAnimationManager::ANIMATION_TYPE_IN : CDesktopAnimationManager::ANIMATION_TYPE_OUT);
|
||||
}
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
} else {
|
||||
if (FSWINDOW != PWINDOW && !PWINDOW->m_pinned)
|
||||
g_pCompositor->setWindowFullscreenClient(FSWINDOW, FSMODE_NONE);
|
||||
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
|
||||
if (FSWINDOW != PWINDOW && !PWINDOW->m_pinned)
|
||||
g_pCompositor->setWindowFullscreenClient(PWINDOW, FSMODE);
|
||||
|
||||
// warp the position + size animation, otherwise it looks weird.
|
||||
PWINDOW->m_realPosition->warp();
|
||||
PWINDOW->m_realSize->warp();
|
||||
}
|
||||
} else
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOW, nullptr, false);
|
||||
|
||||
PWINDOW->warpCursor();
|
||||
|
||||
|
|
@ -2363,7 +2324,7 @@ SDispatchResult CKeybindManager::tagWindow(std::string args) {
|
|||
CVarList vars{args, 0, 's', true};
|
||||
|
||||
if (vars.size() == 1)
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
else if (vars.size() == 2)
|
||||
PWINDOW = g_pCompositor->getWindowByRegex(vars[1]);
|
||||
else
|
||||
|
|
@ -2378,7 +2339,7 @@ SDispatchResult CKeybindManager::tagWindow(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::toggleSwallow(std::string args) {
|
||||
PHLWINDOWREF pWindow = g_pCompositor->m_lastWindow;
|
||||
PHLWINDOWREF pWindow = Desktop::focusState()->window();
|
||||
|
||||
if (!valid(pWindow) || !valid(pWindow->m_swallowed))
|
||||
return {};
|
||||
|
|
@ -2436,7 +2397,7 @@ SDispatchResult CKeybindManager::pass(std::string regexp) {
|
|||
return {.success = false, .error = "No kb in pass?"};
|
||||
}
|
||||
|
||||
const auto XWTOXW = PWINDOW->m_isX11 && g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_isX11;
|
||||
const auto XWTOXW = PWINDOW->m_isX11 && Desktop::focusState()->window() && Desktop::focusState()->window()->m_isX11;
|
||||
const auto LASTMOUSESURF = g_pSeatManager->m_state.pointerFocus.lock();
|
||||
const auto LASTKBSURF = g_pSeatManager->m_state.keyboardFocus.lock();
|
||||
|
||||
|
|
@ -2573,7 +2534,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
|
|||
|
||||
const std::string regexp = ARGS[2];
|
||||
PHLWINDOW PWINDOW = nullptr;
|
||||
const auto LASTSURFACE = g_pCompositor->m_lastFocus.lock();
|
||||
const auto LASTSURFACE = Desktop::focusState()->surface();
|
||||
|
||||
//if regexp is not empty, send shortcut to current window
|
||||
//else, don't change focus
|
||||
|
|
@ -2598,10 +2559,10 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
|
|||
|
||||
//copied the rest from pass and modified it
|
||||
// if wl -> xwl, activate destination
|
||||
if (PWINDOW && PWINDOW->m_isX11 && g_pCompositor->m_lastWindow && !g_pCompositor->m_lastWindow->m_isX11)
|
||||
if (PWINDOW && PWINDOW->m_isX11 && Desktop::focusState()->window() && !Desktop::focusState()->window()->m_isX11)
|
||||
g_pXWaylandManager->activateSurface(PWINDOW->m_wlSurface->resource(), true);
|
||||
// if xwl -> xwl, send to current. Timing issues make this not work.
|
||||
if (PWINDOW && PWINDOW->m_isX11 && g_pCompositor->m_lastWindow && g_pCompositor->m_lastWindow->m_isX11)
|
||||
if (PWINDOW && PWINDOW->m_isX11 && Desktop::focusState()->window() && Desktop::focusState()->window()->m_isX11)
|
||||
PWINDOW = nullptr;
|
||||
|
||||
g_pSeatManager->sendKeyboardMods(MOD, 0, 0, 0);
|
||||
|
|
@ -2653,7 +2614,7 @@ SDispatchResult CKeybindManager::sendshortcut(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::layoutmsg(std::string msg) {
|
||||
SLayoutMessageHeader hd = {g_pCompositor->m_lastWindow.lock()};
|
||||
SLayoutMessageHeader hd = {Desktop::focusState()->window()};
|
||||
g_pLayoutManager->getCurrentLayout()->layoutMessage(hd, msg);
|
||||
|
||||
return {};
|
||||
|
|
@ -2690,14 +2651,14 @@ SDispatchResult CKeybindManager::swapnext(std::string arg) {
|
|||
|
||||
PHLWINDOW toSwap = nullptr;
|
||||
|
||||
if (g_pCompositor->m_lastWindow.expired())
|
||||
if (!Desktop::focusState()->window())
|
||||
return {};
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
const auto PLASTCYCLED =
|
||||
validMapped(g_pCompositor->m_lastWindow->m_lastCycledWindow) && g_pCompositor->m_lastWindow->m_lastCycledWindow->m_workspace == PLASTWINDOW->m_workspace ?
|
||||
g_pCompositor->m_lastWindow->m_lastCycledWindow.lock() :
|
||||
validMapped(Desktop::focusState()->window()->m_lastCycledWindow) && Desktop::focusState()->window()->m_lastCycledWindow->m_workspace == PLASTWINDOW->m_workspace ?
|
||||
Desktop::focusState()->window()->m_lastCycledWindow.lock() :
|
||||
nullptr;
|
||||
|
||||
const bool NEED_PREV = arg == "last" || arg == "l" || arg == "prev" || arg == "p";
|
||||
|
|
@ -2711,7 +2672,7 @@ SDispatchResult CKeybindManager::swapnext(std::string arg) {
|
|||
|
||||
PLASTWINDOW->m_lastCycledWindow = toSwap;
|
||||
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
Desktop::focusState()->fullWindowFocus(PLASTWINDOW);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -2741,7 +2702,7 @@ SDispatchResult CKeybindManager::pinActive(std::string args) {
|
|||
if (args != "active" && args.length() > 1)
|
||||
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
||||
else
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW) {
|
||||
Debug::log(ERR, "pin: window not found");
|
||||
|
|
@ -2827,8 +2788,8 @@ SDispatchResult CKeybindManager::changeMouseBindMode(const eMouseBindMode MODE)
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::bringActiveToTop(std::string args) {
|
||||
if (g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_isFloating)
|
||||
g_pCompositor->changeWindowZOrder(g_pCompositor->m_lastWindow.lock(), true);
|
||||
if (Desktop::focusState()->window() && Desktop::focusState()->window()->m_isFloating)
|
||||
g_pCompositor->changeWindowZOrder(Desktop::focusState()->window(), true);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
@ -2838,8 +2799,8 @@ SDispatchResult CKeybindManager::alterZOrder(std::string args) {
|
|||
const auto POSITION = args.substr(0, args.find_first_of(','));
|
||||
auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||
|
||||
if (!PWINDOW && g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_isFloating)
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
if (!PWINDOW && Desktop::focusState()->window() && Desktop::focusState()->window()->m_isFloating)
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW) {
|
||||
Debug::log(ERR, "alterZOrder: no window");
|
||||
|
|
@ -2875,7 +2836,7 @@ SDispatchResult CKeybindManager::lockGroups(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::lockActiveGroup(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
|
@ -2916,7 +2877,7 @@ void CKeybindManager::moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowIn
|
|||
pWindowInDirection->setGroupCurrent(pWindow);
|
||||
pWindow->updateWindowDecos();
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow);
|
||||
g_pCompositor->focusWindow(pWindow);
|
||||
Desktop::focusState()->fullWindowFocus(pWindow);
|
||||
pWindow->warpCursor();
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"moveintogroup", std::format("{:x}", rc<uintptr_t>(pWindow.get()))});
|
||||
|
|
@ -2953,10 +2914,10 @@ void CKeybindManager::moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string&
|
|||
}
|
||||
|
||||
if (*BFOCUSREMOVEDWINDOW) {
|
||||
g_pCompositor->focusWindow(pWindow);
|
||||
Desktop::focusState()->fullWindowFocus(pWindow);
|
||||
pWindow->warpCursor();
|
||||
} else {
|
||||
g_pCompositor->focusWindow(PWINDOWPREV);
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOWPREV);
|
||||
PWINDOWPREV->warpCursor();
|
||||
}
|
||||
|
||||
|
|
@ -2976,7 +2937,7 @@ SDispatchResult CKeybindManager::moveIntoGroup(std::string args) {
|
|||
return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
|
||||
}
|
||||
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW || PWINDOW->m_groupData.deny)
|
||||
return {};
|
||||
|
|
@ -3006,7 +2967,7 @@ SDispatchResult CKeybindManager::moveOutOfGroup(std::string args) {
|
|||
if (args != "active" && args.length() > 1)
|
||||
PWINDOW = g_pCompositor->getWindowByRegex(args);
|
||||
else
|
||||
PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
PWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
|
@ -3029,7 +2990,7 @@ SDispatchResult CKeybindManager::moveWindowOrGroup(std::string args) {
|
|||
return {.success = false, .error = std::format("Cannot move into group in direction {}, unsupported direction. Supported: l,r,u/t,d/b", arg)};
|
||||
}
|
||||
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
if (!PWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
||||
|
|
@ -3088,7 +3049,7 @@ SDispatchResult CKeybindManager::setIgnoreGroupLock(std::string args) {
|
|||
}
|
||||
|
||||
SDispatchResult CKeybindManager::denyWindowFromGroup(std::string args) {
|
||||
const auto PWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PWINDOW = Desktop::focusState()->window();
|
||||
if (!PWINDOW || (PWINDOW && PWINDOW->m_groupData.pNextWindow.lock()))
|
||||
return {};
|
||||
|
||||
|
|
@ -3120,7 +3081,7 @@ SDispatchResult CKeybindManager::global(std::string args) {
|
|||
SDispatchResult CKeybindManager::moveGroupWindow(std::string args) {
|
||||
const auto BACK = args == "b" || args == "prev";
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return {.success = false, .error = "No window found"};
|
||||
|
|
@ -3186,7 +3147,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
|
|||
if (vars.size() < 3)
|
||||
return {.success = false, .error = "Not enough args"};
|
||||
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
const auto PWINDOW = g_pCompositor->getWindowByRegex(vars[0]);
|
||||
|
||||
if (!PWINDOW)
|
||||
|
|
@ -3321,10 +3282,11 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
|
|||
|
||||
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
|
||||
|
||||
if (!(PWINDOW->m_ruleApplicator->noFocus().valueOrDefault() == noFocus)) {
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
g_pCompositor->focusWindow(PWINDOW);
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
if (PWINDOW->m_ruleApplicator->noFocus().valueOrDefault() != noFocus) {
|
||||
// FIXME: what the fuck is going on here? -vax
|
||||
Desktop::focusState()->rawWindowFocus(nullptr);
|
||||
Desktop::focusState()->fullWindowFocus(PWINDOW);
|
||||
Desktop::focusState()->fullWindowFocus(PLASTWINDOW);
|
||||
}
|
||||
|
||||
if (PROP == "no_vrr")
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ class CKeybindManager {
|
|||
static bool tryMoveFocusToMonitor(PHLMONITOR monitor);
|
||||
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
|
||||
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
|
||||
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory = false);
|
||||
|
||||
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveFocusHistory = false, bool forceFSCycle = false);
|
||||
static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace, const std::string& execRuleToken = "");
|
||||
static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "../managers/HookSystemManager.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../render/OpenGL.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "SeatManager.hpp"
|
||||
#include "../helpers/time/Time.hpp"
|
||||
#include <cstring>
|
||||
|
|
@ -799,7 +800,7 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
|
|||
|
||||
auto outputMappedArea = [&mappedArea](const std::string& output) {
|
||||
if (output == "current") {
|
||||
if (const auto PLASTMONITOR = g_pCompositor->m_lastMonitor.lock(); PLASTMONITOR)
|
||||
if (const auto PLASTMONITOR = Desktop::focusState()->monitor(); PLASTMONITOR)
|
||||
return PLASTMONITOR->logicalBox();
|
||||
} else if (const auto PMONITOR = g_pCompositor->getMonitorFromString(output); PMONITOR)
|
||||
return PMONITOR->logicalBox();
|
||||
|
|
@ -927,7 +928,7 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
|
|||
listener->frame = pointer->m_pointerEvents.frame.listen([] {
|
||||
bool shouldSkip = false;
|
||||
if (!g_pSeatManager->m_mouse.expired() && g_pInputManager->isLocked()) {
|
||||
auto PMONITOR = g_pCompositor->m_lastMonitor.get();
|
||||
auto PMONITOR = Desktop::focusState()->monitor().get();
|
||||
shouldSkip = PMONITOR && PMONITOR->shouldSkipScheduleFrameOnMouseEvent();
|
||||
}
|
||||
g_pSeatManager->m_isPointerFrameSkipped = shouldSkip;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "../protocols/PrimarySelection.hpp"
|
||||
#include "../protocols/core/Compositor.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../devices/IKeyboard.hpp"
|
||||
#include "../desktop/LayerSurface.hpp"
|
||||
#include "../managers/input/InputManager.hpp"
|
||||
|
|
@ -659,7 +660,7 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
|||
|
||||
// If this was a popup grab, focus its parent window to maintain context
|
||||
if (validMapped(parentWindow)) {
|
||||
g_pCompositor->focusWindow(parentWindow);
|
||||
Desktop::focusState()->rawWindowFocus(parentWindow);
|
||||
Debug::log(LOG, "[seatmgr] Refocused popup parent window {} (follow_mouse={})", parentWindow->m_title, *PFOLLOWMOUSE);
|
||||
} else
|
||||
g_pInputManager->refocusLastWindow(PMONITOR);
|
||||
|
|
@ -689,10 +690,10 @@ void CSeatManager::setGrab(SP<CSeatGrab> grab) {
|
|||
refocus = layer->m_interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE;
|
||||
|
||||
if (refocus) {
|
||||
auto candidate = g_pCompositor->m_lastWindow.lock();
|
||||
auto candidate = Desktop::focusState()->window();
|
||||
|
||||
if (candidate)
|
||||
g_pCompositor->focusWindow(candidate);
|
||||
Desktop::focusState()->rawWindowFocus(candidate);
|
||||
}
|
||||
|
||||
if (oldGrab->m_onEnd)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../protocols/FractionalScale.hpp"
|
||||
#include "../protocols/SessionLock.hpp"
|
||||
#include "../render/Renderer.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "./managers/SeatManager.hpp"
|
||||
#include "./managers/input/InputManager.hpp"
|
||||
#include "./managers/eventLoop/EventLoopManager.hpp"
|
||||
|
|
@ -25,8 +26,8 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur
|
|||
});
|
||||
|
||||
listeners.destroy = surface_->m_events.destroy.listen([this] {
|
||||
if (pWlrSurface == g_pCompositor->m_lastFocus)
|
||||
g_pCompositor->m_lastFocus.reset();
|
||||
if (pWlrSurface == Desktop::focusState()->surface())
|
||||
Desktop::focusState()->surface().reset();
|
||||
|
||||
g_pSessionLockManager->removeSessionLockSurface(this);
|
||||
});
|
||||
|
|
@ -34,7 +35,7 @@ SSessionLockSurface::SSessionLockSurface(SP<CSessionLockSurface> surface_) : sur
|
|||
listeners.commit = surface_->m_events.commit.listen([this] {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(iMonitorID);
|
||||
|
||||
if (mapped && !g_pCompositor->m_lastFocus)
|
||||
if (mapped && !Desktop::focusState()->surface())
|
||||
g_pInputManager->simulateMouseMovement();
|
||||
|
||||
if (PMONITOR)
|
||||
|
|
@ -82,13 +83,13 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
|
|||
|
||||
m_sessionLock->listeners.destroy = pLock->m_events.destroyed.listen([this] {
|
||||
m_sessionLock.reset();
|
||||
g_pCompositor->focusSurface(nullptr);
|
||||
Desktop::focusState()->rawSurfaceFocus(nullptr);
|
||||
|
||||
for (auto const& m : g_pCompositor->m_monitors)
|
||||
g_pHyprRenderer->damageMonitor(m);
|
||||
});
|
||||
|
||||
g_pCompositor->focusSurface(nullptr);
|
||||
Desktop::focusState()->rawSurfaceFocus(nullptr);
|
||||
g_pSeatManager->setGrab(nullptr);
|
||||
|
||||
const bool NOACTIVEMONS = std::ranges::all_of(g_pCompositor->m_monitors, [](const auto& m) { return !m->m_enabled || !m->m_dpmsStatus; });
|
||||
|
|
@ -196,14 +197,14 @@ void CSessionLockManager::removeSessionLockSurface(SSessionLockSurface* pSLS) {
|
|||
|
||||
std::erase_if(m_sessionLock->vSessionLockSurfaces, [&](const auto& other) { return pSLS == other.get(); });
|
||||
|
||||
if (g_pCompositor->m_lastFocus)
|
||||
if (Desktop::focusState()->surface())
|
||||
return;
|
||||
|
||||
for (auto const& sls : m_sessionLock->vSessionLockSurfaces) {
|
||||
if (!sls->mapped)
|
||||
continue;
|
||||
|
||||
g_pCompositor->focusSurface(sls->surface->surface());
|
||||
Desktop::focusState()->rawSurfaceFocus(sls->surface->surface());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "XWaylandManager.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../desktop/state/FocusState.hpp"
|
||||
#include "../events/Events.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include "../helpers/Monitor.hpp"
|
||||
|
|
@ -69,8 +70,8 @@ void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
|
|||
pWindow->m_xdgSurface->m_toplevel->setActive(activate);
|
||||
|
||||
if (activate) {
|
||||
g_pCompositor->m_lastFocus = getWindowSurface(pWindow);
|
||||
g_pCompositor->m_lastWindow = pWindow;
|
||||
Desktop::focusState()->surface() = getWindowSurface(pWindow);
|
||||
Desktop::focusState()->window() = pWindow;
|
||||
}
|
||||
|
||||
if (!pWindow->m_pinned)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "../../config/ConfigManager.hpp"
|
||||
#include "../../desktop/Window.hpp"
|
||||
#include "../../desktop/LayerSurface.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../protocols/CursorShape.hpp"
|
||||
#include "../../protocols/IdleInhibit.hpp"
|
||||
#include "../../protocols/RelativePointer.hpp"
|
||||
|
|
@ -168,18 +169,18 @@ void CInputManager::simulateMouseMovement() {
|
|||
}
|
||||
|
||||
void CInputManager::sendMotionEventsToFocused() {
|
||||
if (!g_pCompositor->m_lastFocus || isConstrained())
|
||||
if (!Desktop::focusState()->surface() || isConstrained())
|
||||
return;
|
||||
|
||||
// todo: this sucks ass
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(g_pCompositor->m_lastFocus.lock());
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock());
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(Desktop::focusState()->surface());
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(Desktop::focusState()->surface());
|
||||
|
||||
const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_realPosition->goal() : (PLS ? Vector2D{PLS->m_geometry.x, PLS->m_geometry.y} : Vector2D{}));
|
||||
|
||||
m_emptyFocusCursorSet = false;
|
||||
|
||||
g_pSeatManager->setPointerFocus(g_pCompositor->m_lastFocus.lock(), LOCAL);
|
||||
g_pSeatManager->setPointerFocus(Desktop::focusState()->surface(), LOCAL);
|
||||
}
|
||||
|
||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, std::optional<Vector2D> overridePos) {
|
||||
|
|
@ -223,7 +224,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
m_lastCursorPosFloored = MOUSECOORDSFLOORED;
|
||||
|
||||
const auto PMONITOR = isLocked() && g_pCompositor->m_lastMonitor ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromCursor();
|
||||
const auto PMONITOR = isLocked() && Desktop::focusState()->monitor() ? Desktop::focusState()->monitor() : g_pCompositor->getMonitorFromCursor();
|
||||
|
||||
// this can happen if there are no displays hooked up to Hyprland
|
||||
if (PMONITOR == nullptr)
|
||||
|
|
@ -239,7 +240,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
// constraints
|
||||
if (!g_pSeatManager->m_mouse.expired() && isConstrained()) {
|
||||
const auto SURF = CWLSurface::fromResource(g_pCompositor->m_lastFocus.lock());
|
||||
const auto SURF = CWLSurface::fromResource(Desktop::focusState()->surface());
|
||||
const auto CONSTRAINT = SURF ? SURF->constraint() : nullptr;
|
||||
|
||||
if (CONSTRAINT) {
|
||||
|
|
@ -263,8 +264,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", rc<uintptr_t>(SURF.get()), rc<uintptr_t>(CONSTRAINT.get()));
|
||||
}
|
||||
|
||||
if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired())
|
||||
g_pCompositor->setActiveMonitor(PMONITOR);
|
||||
if (PMONITOR != Desktop::focusState()->monitor() && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired())
|
||||
Desktop::focusState()->rawMonitorFocus(PMONITOR);
|
||||
|
||||
// check for windows that have focus priority like our permission popups
|
||||
pFoundWindow = g_pCompositor->vectorToWindowUnified(mouseCoords, FOCUS_PRIORITY);
|
||||
|
|
@ -277,7 +278,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
const auto PSESSIONLOCKSURFACE = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->m_id);
|
||||
const auto foundLockSurface = PSESSIONLOCKSURFACE ? PSESSIONLOCKSURFACE->surface->surface() : nullptr;
|
||||
|
||||
g_pCompositor->focusSurface(foundLockSurface);
|
||||
Desktop::focusState()->rawSurfaceFocus(foundLockSurface);
|
||||
|
||||
// search for interactable abovelock surfaces for pointer focus, or use session lock surface if not found
|
||||
for (auto& lsl : PMONITOR->m_layerSurfaceLayers | std::views::reverse) {
|
||||
|
|
@ -317,7 +318,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
// if we are holding a pointer button,
|
||||
// and we're not dnd-ing, don't refocus. Keep focus on last surface.
|
||||
if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->m_mapped &&
|
||||
if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && Desktop::focusState()->surface() && Desktop::focusState()->surface()->m_mapped &&
|
||||
g_pSeatManager->m_state.pointerFocus && !m_hardInput) {
|
||||
foundSurface = g_pSeatManager->m_state.pointerFocus.lock();
|
||||
|
||||
|
|
@ -339,7 +340,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
surfacePos = BOX->pos();
|
||||
pFoundLayerSurface = HLSurface->getLayer();
|
||||
if (!pFoundLayerSurface)
|
||||
pFoundWindow = !PWINDOW || PWINDOW->isHidden() ? g_pCompositor->m_lastWindow.lock() : PWINDOW;
|
||||
pFoundWindow = !PWINDOW || PWINDOW->isHidden() ? Desktop::focusState()->window() : PWINDOW;
|
||||
} else // reset foundSurface, find one normally
|
||||
foundSurface = nullptr;
|
||||
} else // reset foundSurface, find one normally
|
||||
|
|
@ -461,7 +462,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_layerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface);
|
||||
|
||||
if (g_pPointerManager->softwareLockedFor(PMONITOR->m_self.lock()) > 0 && !skipFrameSchedule)
|
||||
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_lastMonitor.lock(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_MOVE);
|
||||
g_pCompositor->scheduleFrameForMonitor(Desktop::focusState()->monitor(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_MOVE);
|
||||
|
||||
// FIXME: This will be disabled during DnD operations because we do not exactly follow the spec
|
||||
// xdg-popup grabs should be keyboard-only, while they are absolute in our case...
|
||||
|
|
@ -492,8 +493,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
g_pSeatManager->setPointerFocus(nullptr, {});
|
||||
|
||||
if (refocus || g_pCompositor->m_lastWindow.expired()) // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
if (refocus || !Desktop::focusState()->window()) // if we are forcing a refocus, and we don't find a surface, clear the kb focus too!
|
||||
Desktop::focusState()->rawWindowFocus(nullptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -514,8 +515,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
bool allowKeyboardRefocus = true;
|
||||
|
||||
if (!refocus && g_pCompositor->m_lastFocus) {
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_lastFocus.lock());
|
||||
if (!refocus && Desktop::focusState()->surface()) {
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(Desktop::focusState()->surface());
|
||||
|
||||
if (PLS && PLS->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
|
||||
allowKeyboardRefocus = false;
|
||||
|
|
@ -556,19 +557,19 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
}
|
||||
|
||||
if (FOLLOWMOUSE != 1 && !refocus) {
|
||||
if (pFoundWindow != g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow.lock() &&
|
||||
((pFoundWindow->m_isFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_lastWindow->m_isFloating != pFoundWindow->m_isFloating && *PFLOATBEHAVIOR != 0))) {
|
||||
if (pFoundWindow != Desktop::focusState()->window() && Desktop::focusState()->window() &&
|
||||
((pFoundWindow->m_isFloating && *PFLOATBEHAVIOR == 2) || (Desktop::focusState()->window()->m_isFloating != pFoundWindow->m_isFloating && *PFLOATBEHAVIOR != 0))) {
|
||||
// enter if change floating style
|
||||
if (FOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
Desktop::focusState()->rawWindowFocus(pFoundWindow, foundSurface);
|
||||
g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal);
|
||||
} else if (FOLLOWMOUSE == 2 || FOLLOWMOUSE == 3)
|
||||
g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal);
|
||||
|
||||
if (pFoundWindow == g_pCompositor->m_lastWindow)
|
||||
if (pFoundWindow == Desktop::focusState()->window())
|
||||
g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal);
|
||||
|
||||
if (FOLLOWMOUSE != 0 || pFoundWindow == g_pCompositor->m_lastWindow)
|
||||
if (FOLLOWMOUSE != 0 || pFoundWindow == Desktop::focusState()->window())
|
||||
g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal);
|
||||
|
||||
if (g_pSeatManager->m_state.pointerFocus == foundSurface)
|
||||
|
|
@ -578,26 +579,26 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
return; // don't enter any new surfaces
|
||||
} else {
|
||||
if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_lastMouseFocus.lock() != pFoundWindow)) || refocus)) {
|
||||
if (m_lastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow || g_pCompositor->m_lastFocus != foundSurface || refocus) {
|
||||
if (m_lastMouseFocus.lock() != pFoundWindow || Desktop::focusState()->window() != pFoundWindow || Desktop::focusState()->surface() != foundSurface || refocus) {
|
||||
m_lastMouseFocus = pFoundWindow;
|
||||
|
||||
// TODO: this looks wrong. When over a popup, it constantly is switching.
|
||||
// Temp fix until that's figured out. Otherwise spams windowrule lookups and other shit.
|
||||
if (m_lastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow) {
|
||||
if (m_lastMouseFocus.lock() != pFoundWindow || Desktop::focusState()->window() != pFoundWindow) {
|
||||
if (m_mousePosDelta > *PFOLLOWMOUSETHRESHOLD || refocus) {
|
||||
const bool hasNoFollowMouse = pFoundWindow && pFoundWindow->m_ruleApplicator->noFollowMouse().valueOrDefault();
|
||||
|
||||
if (refocus || !hasNoFollowMouse)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
Desktop::focusState()->rawWindowFocus(pFoundWindow, foundSurface);
|
||||
}
|
||||
} else
|
||||
g_pCompositor->focusSurface(foundSurface, pFoundWindow);
|
||||
Desktop::focusState()->rawSurfaceFocus(foundSurface, pFoundWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_pSeatManager->m_state.keyboardFocus == nullptr)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
Desktop::focusState()->rawWindowFocus(pFoundWindow, foundSurface);
|
||||
|
||||
m_lastFocusOnLS = false;
|
||||
} else {
|
||||
|
|
@ -608,7 +609,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
|
|||
|
||||
if (pFoundLayerSurface && (pFoundLayerSurface->m_layerSurface->m_current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) && FOLLOWMOUSE != 3 &&
|
||||
(allowKeyboardRefocus || pFoundLayerSurface->m_layerSurface->m_current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)) {
|
||||
g_pCompositor->focusSurface(foundSurface);
|
||||
Desktop::focusState()->rawSurfaceFocus(foundSurface);
|
||||
}
|
||||
|
||||
if (pFoundLayerSurface)
|
||||
|
|
@ -762,7 +763,7 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) {
|
|||
break;
|
||||
|
||||
if ((g_pSeatManager->m_mouse.expired() || !isConstrained()) /* No constraints */
|
||||
&& (w && g_pCompositor->m_lastWindow.lock() != w) /* window should change */) {
|
||||
&& (w && Desktop::focusState()->window() != w) /* window should change */) {
|
||||
// a bit hacky
|
||||
// if we only pressed one button, allow us to refocus. m_lCurrentlyHeldButtons.size() > 0 will stick the focus
|
||||
if (m_currentlyHeldButtons.size() == 1) {
|
||||
|
|
@ -791,8 +792,8 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) {
|
|||
// notify app if we didn't handle it
|
||||
g_pSeatManager->sendPointerButton(e.timeMs, e.button, e.state);
|
||||
|
||||
if (const auto PMON = g_pCompositor->getMonitorFromVector(mouseCoords); PMON != g_pCompositor->m_lastMonitor && PMON)
|
||||
g_pCompositor->setActiveMonitor(PMON);
|
||||
if (const auto PMON = g_pCompositor->getMonitorFromVector(mouseCoords); PMON != Desktop::focusState()->monitor() && PMON)
|
||||
Desktop::focusState()->rawMonitorFocus(PMON);
|
||||
|
||||
if (g_pSeatManager->m_seatGrab && e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
m_hardInput = true;
|
||||
|
|
@ -1022,8 +1023,8 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
|
|||
keeb->updateLEDs();
|
||||
|
||||
// in case m_lastFocus was set without a keyboard
|
||||
if (m_keyboards.size() == 1 && g_pCompositor->m_lastFocus)
|
||||
g_pSeatManager->setKeyboardFocus(g_pCompositor->m_lastFocus.lock());
|
||||
if (m_keyboards.size() == 1 && Desktop::focusState()->surface())
|
||||
g_pSeatManager->setKeyboardFocus(Desktop::focusState()->surface());
|
||||
}
|
||||
|
||||
void CInputManager::setKeyboardLayout() {
|
||||
|
|
@ -1577,16 +1578,16 @@ bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
|
|||
foundSurface = nullptr;
|
||||
}
|
||||
|
||||
if (!foundSurface && g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_workspace && g_pCompositor->m_lastWindow->m_workspace->isVisibleNotCovered()) {
|
||||
if (!foundSurface && Desktop::focusState()->window() && Desktop::focusState()->window()->m_workspace && Desktop::focusState()->window()->m_workspace->isVisibleNotCovered()) {
|
||||
// then the last focused window if we're on the same workspace as it
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
Desktop::focusState()->fullWindowFocus(PLASTWINDOW);
|
||||
} else {
|
||||
// otherwise fall back to a normal refocus.
|
||||
|
||||
if (foundSurface && !foundSurface->m_hlSurface->keyboardFocusable()) {
|
||||
const auto PLASTWINDOW = g_pCompositor->m_lastWindow.lock();
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
const auto PLASTWINDOW = Desktop::focusState()->window();
|
||||
Desktop::focusState()->fullWindowFocus(PLASTWINDOW);
|
||||
}
|
||||
|
||||
refocus();
|
||||
|
|
@ -1615,7 +1616,7 @@ void CInputManager::unconstrainMouse() {
|
|||
bool CInputManager::isConstrained() {
|
||||
return std::ranges::any_of(m_constraints, [](auto const& c) {
|
||||
const auto constraint = c.lock();
|
||||
return constraint && constraint->isActive() && constraint->owner()->resource() == g_pCompositor->m_lastFocus;
|
||||
return constraint && constraint->isActive() && constraint->owner()->resource() == Desktop::focusState()->surface();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1623,7 +1624,7 @@ bool CInputManager::isLocked() {
|
|||
if (!isConstrained())
|
||||
return false;
|
||||
|
||||
const auto SURF = CWLSurface::fromResource(g_pCompositor->m_lastFocus.lock());
|
||||
const auto SURF = CWLSurface::fromResource(Desktop::focusState()->surface());
|
||||
const auto CONSTRAINT = SURF ? SURF->constraint() : nullptr;
|
||||
|
||||
return CONSTRAINT && CONSTRAINT->isLocked();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "InputMethodRelay.hpp"
|
||||
#include "InputManager.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../protocols/TextInputV3.hpp"
|
||||
#include "../../protocols/TextInputV1.hpp"
|
||||
#include "../../protocols/InputMethodV2.hpp"
|
||||
|
|
@ -54,17 +53,17 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
|
|||
Debug::log(LOG, "New input popup");
|
||||
});
|
||||
|
||||
if (!g_pCompositor->m_lastFocus)
|
||||
if (!Desktop::focusState()->surface())
|
||||
return;
|
||||
|
||||
for (auto const& ti : m_textInputs) {
|
||||
if (ti->client() != g_pCompositor->m_lastFocus->client())
|
||||
if (ti->client() != Desktop::focusState()->surface()->client())
|
||||
continue;
|
||||
|
||||
if (ti->isV3())
|
||||
ti->enter(g_pCompositor->m_lastFocus.lock());
|
||||
ti->enter(Desktop::focusState()->surface());
|
||||
else
|
||||
ti->onEnabled(g_pCompositor->m_lastFocus.lock());
|
||||
ti->onEnabled(Desktop::focusState()->surface());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,11 +72,11 @@ void CInputMethodRelay::removePopup(CInputPopup* pPopup) {
|
|||
}
|
||||
|
||||
CTextInput* CInputMethodRelay::getFocusedTextInput() {
|
||||
if (!g_pCompositor->m_lastFocus)
|
||||
if (!Desktop::focusState()->surface())
|
||||
return nullptr;
|
||||
|
||||
for (auto const& ti : m_textInputs) {
|
||||
if (ti->focusedSurface() == g_pCompositor->m_lastFocus)
|
||||
if (ti->focusedSurface() == Desktop::focusState()->surface())
|
||||
return ti.get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#include "TextInput.hpp"
|
||||
#include "../../defines.hpp"
|
||||
#include "InputManager.hpp"
|
||||
#include "../../protocols/TextInputV1.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../protocols/TextInputV3.hpp"
|
||||
#include "../../protocols/InputMethodV2.hpp"
|
||||
#include "../../protocols/core/Compositor.hpp"
|
||||
|
|
@ -31,8 +30,8 @@ void CTextInput::initCallbacks() {
|
|||
g_pInputManager->m_relay.deactivateIME(this);
|
||||
});
|
||||
|
||||
if (!g_pCompositor->m_lastFocus.expired() && g_pCompositor->m_lastFocus->client() == INPUT->client())
|
||||
enter(g_pCompositor->m_lastFocus.lock());
|
||||
if (Desktop::focusState()->surface() && Desktop::focusState()->surface()->client() == INPUT->client())
|
||||
enter(Desktop::focusState()->surface());
|
||||
} else {
|
||||
const auto INPUT = m_v1Input.lock();
|
||||
|
||||
|
|
@ -60,7 +59,7 @@ void CTextInput::onEnabled(SP<CWLSurfaceResource> surfV1) {
|
|||
|
||||
// v1 only, map surface to PTI
|
||||
if (!isV3()) {
|
||||
if (g_pCompositor->m_lastFocus != surfV1 || !m_v1Input->m_active)
|
||||
if (Desktop::focusState()->surface() != surfV1 || !m_v1Input->m_active)
|
||||
return;
|
||||
|
||||
enter(surfV1);
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
#include "../../protocols/SessionLock.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../desktop/LayerSurface.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
#include "../../helpers/Monitor.hpp"
|
||||
#include "../../devices/ITouch.hpp"
|
||||
#include "../SeatManager.hpp"
|
||||
#include "managers/animation/AnimationManager.hpp"
|
||||
#include "../HookSystemManager.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "UnifiedWorkspaceSwipeGesture.hpp"
|
||||
|
|
@ -26,7 +26,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
|||
|
||||
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->m_boundOutput.empty() ? e.device->m_boundOutput : "");
|
||||
|
||||
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_lastMonitor.lock();
|
||||
PMONITOR = PMONITOR ? PMONITOR : Desktop::focusState()->monitor();
|
||||
|
||||
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "UnifiedWorkspaceSwipeGesture.hpp"
|
||||
|
||||
#include "../../Compositor.hpp"
|
||||
#include "../../desktop/state/FocusState.hpp"
|
||||
#include "../../render/Renderer.hpp"
|
||||
#include "InputManager.hpp"
|
||||
|
||||
|
|
@ -12,18 +13,18 @@ void CUnifiedWorkspaceSwipeGesture::begin() {
|
|||
if (isGestureInProgress())
|
||||
return;
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->m_lastMonitor->m_activeWorkspace;
|
||||
const auto PWORKSPACE = Desktop::focusState()->monitor()->m_activeWorkspace;
|
||||
|
||||
Debug::log(LOG, "CUnifiedWorkspaceSwipeGesture::begin: Starting a swipe from {}", PWORKSPACE->m_name);
|
||||
|
||||
m_workspaceBegin = PWORKSPACE;
|
||||
m_delta = 0;
|
||||
m_monitor = g_pCompositor->m_lastMonitor;
|
||||
m_monitor = Desktop::focusState()->monitor();
|
||||
m_avgSpeed = 0;
|
||||
m_speedPoints = 0;
|
||||
|
||||
if (PWORKSPACE->m_hasFullscreenWindow) {
|
||||
for (auto const& ls : g_pCompositor->m_lastMonitor->m_layerSurfaceLayers[2]) {
|
||||
for (auto const& ls : Desktop::focusState()->monitor()->m_layerSurfaceLayers[2]) {
|
||||
*ls->m_alpha = 1.f;
|
||||
}
|
||||
}
|
||||
|
|
@ -307,7 +308,7 @@ void CUnifiedWorkspaceSwipeGesture::end() {
|
|||
g_pInputManager->refocus();
|
||||
|
||||
// apply alpha
|
||||
for (auto const& ls : g_pCompositor->m_lastMonitor->m_layerSurfaceLayers[2]) {
|
||||
for (auto const& ls : Desktop::focusState()->monitor()->m_layerSurfaceLayers[2]) {
|
||||
*ls->m_alpha = pSwitchedTo->m_hasFullscreenWindow && pSwitchedTo->m_fullscreenMode == FSMODE_FULLSCREEN ? 0.f : 1.f;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include "../../../../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../../../../managers/eventLoop/EventLoopTimer.hpp"
|
||||
#include "../../../../config/ConfigValue.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
|
||||
constexpr const float MAX_DISTANCE = 200.F;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ static float lerpVal(const float& from, const float& to, const float& t) {
|
|||
void CCloseTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
||||
ITrackpadGesture::begin(e);
|
||||
|
||||
m_window = g_pCompositor->m_lastWindow;
|
||||
m_window = Desktop::focusState()->window();
|
||||
|
||||
if (!m_window)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include "FloatGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../managers/LayoutManager.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../desktop/Window.hpp"
|
||||
|
||||
constexpr const float MAX_DISTANCE = 250.F;
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ CFloatTrackpadGesture::CFloatTrackpadGesture(const std::string_view& data) {
|
|||
void CFloatTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
||||
ITrackpadGesture::begin(e);
|
||||
|
||||
m_window = g_pCompositor->m_lastWindow;
|
||||
m_window = Desktop::focusState()->window();
|
||||
|
||||
if (!m_window)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "FullscreenGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
#include "../../../animation/DesktopAnimationManager.hpp"
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ CFullscreenTrackpadGesture::CFullscreenTrackpadGesture(const std::string_view& m
|
|||
void CFullscreenTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
||||
ITrackpadGesture::begin(e);
|
||||
|
||||
m_window = g_pCompositor->m_lastWindow;
|
||||
m_window = Desktop::focusState()->window();
|
||||
|
||||
if (!m_window)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#include "MoveGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../desktop/Window.hpp"
|
||||
#include "../../../../managers/LayoutManager.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
|
||||
void CMoveTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
||||
ITrackpadGesture::begin(e);
|
||||
|
||||
m_window = g_pCompositor->m_lastWindow;
|
||||
m_window = Desktop::focusState()->window();
|
||||
m_lastDelta = {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
#include "ResizeGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../desktop/Window.hpp"
|
||||
#include "../../../../managers/LayoutManager.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
|
||||
void CResizeTrackpadGesture::begin(const ITrackpadGesture::STrackpadGestureBegin& e) {
|
||||
ITrackpadGesture::begin(e);
|
||||
|
||||
m_window = g_pCompositor->m_lastWindow;
|
||||
m_window = Desktop::focusState()->window();
|
||||
}
|
||||
|
||||
void CResizeTrackpadGesture::update(const ITrackpadGesture::STrackpadGestureUpdate& e) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "SpecialWorkspaceGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../managers/LayoutManager.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
|
||||
#include <hyprutils/memory/Casts.hpp>
|
||||
|
|
@ -36,7 +36,7 @@ void CSpecialWorkspaceGesture::begin(const ITrackpadGesture::STrackpadGestureBeg
|
|||
|
||||
if (m_specialWorkspace) {
|
||||
m_animatingOut = m_specialWorkspace->isVisible();
|
||||
m_monitor = m_animatingOut ? m_specialWorkspace->m_monitor : g_pCompositor->m_lastMonitor;
|
||||
m_monitor = m_animatingOut ? m_specialWorkspace->m_monitor : Desktop::focusState()->monitor();
|
||||
|
||||
if (!m_monitor)
|
||||
return;
|
||||
|
|
@ -44,7 +44,7 @@ void CSpecialWorkspaceGesture::begin(const ITrackpadGesture::STrackpadGestureBeg
|
|||
if (!m_animatingOut)
|
||||
m_monitor->setSpecialWorkspace(m_specialWorkspace);
|
||||
} else {
|
||||
m_monitor = g_pCompositor->m_lastMonitor;
|
||||
m_monitor = Desktop::focusState()->monitor();
|
||||
|
||||
if (!m_monitor)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "WorkspaceSwipeGesture.hpp"
|
||||
|
||||
#include "../../../../Compositor.hpp"
|
||||
#include "../../../../managers/input/InputManager.hpp"
|
||||
#include "../../../../desktop/state/FocusState.hpp"
|
||||
#include "../../../../render/Renderer.hpp"
|
||||
|
||||
#include "../../UnifiedWorkspaceSwipeGesture.hpp"
|
||||
|
|
@ -16,7 +16,7 @@ void CWorkspaceSwipeGesture::begin(const ITrackpadGesture::STrackpadGestureBegin
|
|||
|
||||
int onMonitor = 0;
|
||||
for (auto const& w : g_pCompositor->getWorkspaces()) {
|
||||
if (w->m_monitor == g_pCompositor->m_lastMonitor && !g_pCompositor->isWorkspaceSpecial(w->m_id))
|
||||
if (w->m_monitor == Desktop::focusState()->monitor() && !g_pCompositor->isWorkspaceSpecial(w->m_id))
|
||||
onMonitor++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue