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:
Nikolai Nechaev 2025-11-26 07:44:26 +09:00 committed by GitHub
parent 1c1746de61
commit 40d8fa8491
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 1003 additions and 694 deletions

View file

@ -5,6 +5,7 @@
#include "../config/ConfigValue.hpp"
#include "../config/ConfigManager.hpp"
#include "../desktop/Window.hpp"
#include "../desktop/state/FocusState.hpp"
#include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../xwayland/XSurface.hpp"
@ -208,8 +209,8 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
bool IHyprLayout::onWindowCreatedAutoGroup(PHLWINDOW pWindow) {
static auto PAUTOGROUP = CConfigValue<Hyprlang::INT>("group:auto_group");
const PHLWINDOW OPENINGON = g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_workspace == pWindow->m_workspace ?
g_pCompositor->m_lastWindow.lock() :
const PHLWINDOW OPENINGON = Desktop::focusState()->window() && Desktop::focusState()->window()->m_workspace == pWindow->m_workspace ?
Desktop::focusState()->window() :
(pWindow->m_workspace ? pWindow->m_workspace->getFirstWindow() : nullptr);
const bool FLOATEDINTOTILED = pWindow->m_isFloating && OPENINGON && !OPENINGON->m_isFloating;
const bool SWALLOWING = pWindow->m_swallowed || pWindow->m_groupSwallowed;
@ -304,7 +305,7 @@ void IHyprLayout::onBeginDragWindow() {
g_pKeybindManager->shadowKeybinds();
g_pCompositor->focusWindow(DRAGGINGWINDOW);
Desktop::focusState()->rawWindowFocus(DRAGGINGWINDOW);
g_pCompositor->changeWindowZOrder(DRAGGINGWINDOW, true);
}
@ -394,7 +395,7 @@ void IHyprLayout::onEndDragWindow() {
}
g_pHyprRenderer->damageWindow(DRAGGINGWINDOW);
g_pCompositor->focusWindow(DRAGGINGWINDOW);
Desktop::focusState()->fullWindowFocus(DRAGGINGWINDOW);
g_pInputManager->m_wasDraggingWindow = false;
}
@ -785,7 +786,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
// fix pseudo leaving artifacts
g_pHyprRenderer->damageMonitor(pWindow->m_monitor.lock());
if (pWindow == g_pCompositor->m_lastWindow)
if (pWindow == Desktop::focusState()->window())
m_lastTiledWindow = pWindow;
} else {
onWindowRemovedTiling(pWindow);
@ -852,7 +853,7 @@ void IHyprLayout::fitFloatingWindowOnMonitor(PHLWINDOW w, std::optional<CBox> tb
}
void IHyprLayout::moveActiveWindow(const Vector2D& delta, PHLWINDOW pWindow) {
const auto PWINDOW = pWindow ? pWindow : g_pCompositor->m_lastWindow.lock();
const auto PWINDOW = pWindow ? pWindow : Desktop::focusState()->window();
if (!validMapped(PWINDOW))
return;
@ -927,7 +928,7 @@ PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) {
pWindowCandidate = PWORKSPACE->getFirstWindow();
if (!pWindowCandidate || pWindow == pWindowCandidate || !pWindowCandidate->m_isMapped || pWindowCandidate->isHidden() || pWindowCandidate->m_X11ShouldntFocus ||
pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_monitor != g_pCompositor->m_lastMonitor)
pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_monitor != Desktop::focusState()->monitor())
return nullptr;
return pWindowCandidate;
@ -949,13 +950,13 @@ void IHyprLayout::bringWindowToTop(PHLWINDOW pWindow) {
void IHyprLayout::requestFocusForWindow(PHLWINDOW pWindow) {
bringWindowToTop(pWindow);
g_pCompositor->focusWindow(pWindow);
Desktop::focusState()->fullWindowFocus(pWindow);
g_pCompositor->warpCursorTo(pWindow->middle());
}
Vector2D IHyprLayout::predictSizeForNewWindowFloating(PHLWINDOW pWindow) { // get all rules, see if we have any size overrides.
Vector2D sizeOverride = {};
if (g_pCompositor->m_lastMonitor) {
if (Desktop::focusState()->monitor()) {
// If `persistentsize` is set, use the stored size if available.
const bool HASPERSISTENTSIZE = pWindow->m_ruleApplicator->persistentSize().valueOrDefault();