mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 19:26:00 +01:00
Add layerrule ignorefocus
This commit is contained in:
parent
a31dceb2c6
commit
9bab7b2d65
6 changed files with 61 additions and 41 deletions
|
@ -996,14 +996,18 @@ wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<
|
|||
SURFACEAT = ls->layerSurface->surface;
|
||||
|
||||
*ppLayerSurfaceFound = ls.get();
|
||||
if ((*ppLayerSurfaceFound)->ignoreFocus)
|
||||
continue;
|
||||
|
||||
return SURFACEAT;
|
||||
}
|
||||
|
||||
if (SURFACEAT) {
|
||||
if (!pixman_region32_not_empty(&SURFACEAT->input_region))
|
||||
continue;
|
||||
|
||||
*ppLayerSurfaceFound = ls.get();
|
||||
if ((*ppLayerSurfaceFound)->ignoreFocus)
|
||||
continue;
|
||||
return SURFACEAT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -803,7 +803,7 @@ bool windowRuleValid(const std::string& RULE) {
|
|||
}
|
||||
|
||||
bool layerRuleValid(const std::string& RULE) {
|
||||
return !(RULE != "noanim" && RULE != "blur" && RULE != "ignorezero");
|
||||
return !(RULE != "noanim" && RULE != "blur" && RULE != "ignorezero" && RULE != "ignorefocus");
|
||||
}
|
||||
|
||||
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||
|
@ -840,16 +840,14 @@ void CConfigManager::handleLayerRule(const std::string& command, const std::stri
|
|||
|
||||
if (RULE == "unset") {
|
||||
std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; });
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!layerRuleValid(RULE)) {
|
||||
Debug::log(ERR, "Invalid rule found: %s", RULE.c_str());
|
||||
parseError = "Invalid rule found: " + RULE;
|
||||
return;
|
||||
}
|
||||
|
||||
m_dLayerRules.push_back({VALUE, RULE});
|
||||
}
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors)
|
||||
for (auto& lsl : m->m_aLayerSurfaceLayers)
|
||||
|
|
|
@ -143,7 +143,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
|||
|
||||
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
|
||||
|
||||
if (layersurface->layerSurface->current.keyboard_interactive &&
|
||||
if (layersurface->layerSurface->current.keyboard_interactive && !layersurface->ignoreFocus &&
|
||||
(!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
|
||||
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
|
||||
|
||||
|
@ -218,31 +218,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
|||
|
||||
// refocus if needed
|
||||
if (WASLASTFOCUS) {
|
||||
g_pInputManager->releaseAllMouseButtons();
|
||||
|
||||
Vector2D surfaceCoords;
|
||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
||||
// find LS-es to focus
|
||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
|
||||
&surfaceCoords, &pFoundLayerSurface);
|
||||
|
||||
if (!foundSurface)
|
||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
|
||||
&surfaceCoords, &pFoundLayerSurface);
|
||||
|
||||
if (!foundSurface) {
|
||||
// if there isn't any, focus the last window
|
||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
} else {
|
||||
// otherwise, full refocus
|
||||
g_pInputManager->refocus();
|
||||
}
|
||||
layersurface->unfocus();
|
||||
}
|
||||
|
||||
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "WLClasses.hpp"
|
||||
#include "../config/ConfigManager.hpp"
|
||||
#include "src/Compositor.hpp"
|
||||
|
||||
SLayerSurface::SLayerSurface() {
|
||||
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
||||
|
@ -11,6 +12,7 @@ void SLayerSurface::applyRules() {
|
|||
noAnimations = false;
|
||||
forceBlur = false;
|
||||
ignoreZero = false;
|
||||
ignoreFocus = false;
|
||||
|
||||
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
|
||||
if (rule.rule == "noanim")
|
||||
|
@ -19,5 +21,43 @@ void SLayerSurface::applyRules() {
|
|||
forceBlur = true;
|
||||
else if (rule.rule == "ignorezero")
|
||||
ignoreZero = true;
|
||||
else if (rule.rule == "ignorefocus") {
|
||||
ignoreFocus = true;
|
||||
if(g_pCompositor->m_pLastFocus == layerSurface->surface) {
|
||||
unfocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SLayerSurface::unfocus() {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layerSurface->output);
|
||||
if (!PMONITOR)
|
||||
return;
|
||||
|
||||
g_pInputManager->releaseAllMouseButtons();
|
||||
|
||||
Vector2D surfaceCoords;
|
||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
||||
// find LS-es to focus
|
||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
|
||||
&surfaceCoords, &pFoundLayerSurface);
|
||||
|
||||
if (!foundSurface)
|
||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
|
||||
&surfaceCoords, &pFoundLayerSurface);
|
||||
|
||||
if (!foundSurface) {
|
||||
// if there isn't any, focus the last window
|
||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
||||
g_pCompositor->focusWindow(nullptr);
|
||||
g_pCompositor->focusWindow(PLASTWINDOW);
|
||||
} else {
|
||||
// otherwise, full refocus
|
||||
g_pInputManager->refocus();
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ struct SLayerSurface {
|
|||
SLayerSurface();
|
||||
|
||||
void applyRules();
|
||||
void unfocus();
|
||||
|
||||
wlr_layer_surface_v1* layerSurface;
|
||||
wl_list link;
|
||||
|
@ -48,6 +49,7 @@ struct SLayerSurface {
|
|||
|
||||
bool forceBlur = false;
|
||||
bool ignoreZero = false;
|
||||
bool ignoreFocus = false;
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const SLayerSurface& rhs) const {
|
||||
|
|
|
@ -325,7 +325,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
if (*PHOGFOCUS && !refocus && g_pCompositor->m_pLastFocus) {
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
|
||||
|
||||
if (PLS && PLS->layerSurface->current.keyboard_interactive) {
|
||||
if (PLS && !PLS->ignoreFocus && PLS->layerSurface->current.keyboard_interactive) {
|
||||
allowKeyboardRefocus = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue