mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 21:25:59 +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;
|
SURFACEAT = ls->layerSurface->surface;
|
||||||
|
|
||||||
*ppLayerSurfaceFound = ls.get();
|
*ppLayerSurfaceFound = ls.get();
|
||||||
|
if ((*ppLayerSurfaceFound)->ignoreFocus)
|
||||||
|
continue;
|
||||||
|
|
||||||
return SURFACEAT;
|
return SURFACEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SURFACEAT) {
|
if (SURFACEAT) {
|
||||||
if (!pixman_region32_not_empty(&SURFACEAT->input_region))
|
if (!pixman_region32_not_empty(&SURFACEAT->input_region))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*ppLayerSurfaceFound = ls.get();
|
*ppLayerSurfaceFound = ls.get();
|
||||||
|
if ((*ppLayerSurfaceFound)->ignoreFocus)
|
||||||
|
continue;
|
||||||
return SURFACEAT;
|
return SURFACEAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -803,7 +803,7 @@ bool windowRuleValid(const std::string& RULE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool layerRuleValid(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) {
|
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||||
|
@ -840,17 +840,15 @@ void CConfigManager::handleLayerRule(const std::string& command, const std::stri
|
||||||
|
|
||||||
if (RULE == "unset") {
|
if (RULE == "unset") {
|
||||||
std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; });
|
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});
|
||||||
}
|
}
|
||||||
|
|
||||||
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& m : g_pCompositor->m_vMonitors)
|
||||||
for (auto& lsl : m->m_aLayerSurfaceLayers)
|
for (auto& lsl : m->m_aLayerSurfaceLayers)
|
||||||
for (auto& ls : lsl)
|
for (auto& ls : lsl)
|
||||||
|
|
|
@ -143,7 +143,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
|
|
||||||
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
|
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->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
|
||||||
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
|
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
|
||||||
|
|
||||||
|
@ -218,31 +218,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
||||||
|
|
||||||
// refocus if needed
|
// refocus if needed
|
||||||
if (WASLASTFOCUS) {
|
if (WASLASTFOCUS) {
|
||||||
g_pInputManager->releaseAllMouseButtons();
|
layersurface->unfocus();
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
|
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 "WLClasses.hpp"
|
||||||
#include "../config/ConfigManager.hpp"
|
#include "../config/ConfigManager.hpp"
|
||||||
|
#include "src/Compositor.hpp"
|
||||||
|
|
||||||
SLayerSurface::SLayerSurface() {
|
SLayerSurface::SLayerSurface() {
|
||||||
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
||||||
|
@ -11,6 +12,7 @@ void SLayerSurface::applyRules() {
|
||||||
noAnimations = false;
|
noAnimations = false;
|
||||||
forceBlur = false;
|
forceBlur = false;
|
||||||
ignoreZero = false;
|
ignoreZero = false;
|
||||||
|
ignoreFocus = false;
|
||||||
|
|
||||||
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
|
for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
|
||||||
if (rule.rule == "noanim")
|
if (rule.rule == "noanim")
|
||||||
|
@ -19,5 +21,43 @@ void SLayerSurface::applyRules() {
|
||||||
forceBlur = true;
|
forceBlur = true;
|
||||||
else if (rule.rule == "ignorezero")
|
else if (rule.rule == "ignorezero")
|
||||||
ignoreZero = true;
|
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();
|
SLayerSurface();
|
||||||
|
|
||||||
void applyRules();
|
void applyRules();
|
||||||
|
void unfocus();
|
||||||
|
|
||||||
wlr_layer_surface_v1* layerSurface;
|
wlr_layer_surface_v1* layerSurface;
|
||||||
wl_list link;
|
wl_list link;
|
||||||
|
@ -46,8 +47,9 @@ struct SLayerSurface {
|
||||||
bool noProcess = false;
|
bool noProcess = false;
|
||||||
bool noAnimations = false;
|
bool noAnimations = false;
|
||||||
|
|
||||||
bool forceBlur = false;
|
bool forceBlur = false;
|
||||||
bool ignoreZero = false;
|
bool ignoreZero = false;
|
||||||
|
bool ignoreFocus = false;
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const SLayerSurface& rhs) const {
|
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) {
|
if (*PHOGFOCUS && !refocus && g_pCompositor->m_pLastFocus) {
|
||||||
const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(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;
|
allowKeyboardRefocus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue