config: add tag dispacther and window rule (#6211)
This commit is contained in:
parent
73b133d015
commit
ebf258788e
9 changed files with 190 additions and 51 deletions
|
|
@ -1,10 +1,12 @@
|
|||
#include <any>
|
||||
#include <string_view>
|
||||
#include <algorithm>
|
||||
#include "Window.hpp"
|
||||
#include "../Compositor.hpp"
|
||||
#include "../render/decorations/CHyprDropShadowDecoration.hpp"
|
||||
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||
#include "../render/decorations/CHyprBorderDecoration.hpp"
|
||||
#include "../config/ConfigValue.hpp"
|
||||
#include <any>
|
||||
#include "../managers/TokenManager.hpp"
|
||||
#include "../protocols/XDGShell.hpp"
|
||||
#include "../xwayland/XWayland.hpp"
|
||||
|
|
@ -619,6 +621,13 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
|||
m_sAdditionalConfigData.forceTearing = true;
|
||||
} else if (r.szRule == "nearestneighbor") {
|
||||
m_sAdditionalConfigData.nearestNeighbor = true;
|
||||
} else if (r.szRule.starts_with("tag")) {
|
||||
CVarList vars{r.szRule, 0, 's', true};
|
||||
|
||||
if (vars.size() == 2 && vars[0] == "tag")
|
||||
m_tags.applyTag(vars[1], true);
|
||||
else
|
||||
Debug::log(ERR, "Tag rule invalid: {}", r.szRule);
|
||||
} else if (r.szRule.starts_with("rounding")) {
|
||||
try {
|
||||
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
||||
|
|
@ -800,6 +809,8 @@ void CWindow::updateDynamicRules() {
|
|||
m_sAdditionalConfigData.nearestNeighbor = false;
|
||||
m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
||||
|
||||
m_tags.removeDynamicTags();
|
||||
|
||||
m_vMatchedRules = g_pConfigManager->getMatchingRules(m_pSelf.lock());
|
||||
for (auto& r : m_vMatchedRules) {
|
||||
applyDynamicRule(r);
|
||||
|
|
@ -1370,6 +1381,7 @@ void CWindow::onUpdateState() {
|
|||
|
||||
void CWindow::onUpdateMeta() {
|
||||
const auto NEWTITLE = fetchTitle();
|
||||
bool doUpdate = false;
|
||||
|
||||
if (m_szTitle != NEWTITLE) {
|
||||
m_szTitle = NEWTITLE;
|
||||
|
|
@ -1382,11 +1394,8 @@ void CWindow::onUpdateMeta() {
|
|||
EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock());
|
||||
}
|
||||
|
||||
updateDynamicRules();
|
||||
g_pCompositor->updateWindowAnimatedDecorationValues(m_pSelf.lock());
|
||||
updateToplevel();
|
||||
|
||||
Debug::log(LOG, "Window {:x} set title to {}", (uintptr_t)this, m_szTitle);
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
const auto NEWCLASS = fetchClass();
|
||||
|
|
@ -1399,11 +1408,14 @@ void CWindow::onUpdateMeta() {
|
|||
EMIT_HOOK_EVENT("activeWindow", m_pSelf.lock());
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Window {:x} set class to {}", (uintptr_t)this, m_szClass);
|
||||
doUpdate = true;
|
||||
}
|
||||
|
||||
if (doUpdate) {
|
||||
updateDynamicRules();
|
||||
g_pCompositor->updateWindowAnimatedDecorationValues(m_pSelf.lock());
|
||||
updateToplevel();
|
||||
|
||||
Debug::log(LOG, "Window {:x} set class to {}", (uintptr_t)this, m_szClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "../defines.hpp"
|
||||
#include "Subsurface.hpp"
|
||||
#include "../helpers/AnimatedVariable.hpp"
|
||||
#include "../render/decorations/IHyprWindowDecoration.hpp"
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include "../config/ConfigDataValues.hpp"
|
||||
#include "../defines.hpp"
|
||||
#include "../helpers/AnimatedVariable.hpp"
|
||||
#include "../helpers/Vector2D.hpp"
|
||||
#include "WLSurface.hpp"
|
||||
#include "Popup.hpp"
|
||||
#include "../helpers/signal/Signal.hpp"
|
||||
#include "../helpers/TagKeeper.hpp"
|
||||
#include "../macros.hpp"
|
||||
#include "../managers/XWaylandManager.hpp"
|
||||
#include "../render/decorations/IHyprWindowDecoration.hpp"
|
||||
#include "DesktopTypes.hpp"
|
||||
#include "../helpers/signal/Signal.hpp"
|
||||
#include "Popup.hpp"
|
||||
#include "Subsurface.hpp"
|
||||
#include "WLSurface.hpp"
|
||||
|
||||
class CXDGSurfaceResource;
|
||||
class CXWaylandSurface;
|
||||
|
|
@ -183,6 +186,7 @@ struct SWindowRule {
|
|||
std::string szClass;
|
||||
std::string szInitialTitle;
|
||||
std::string szInitialClass;
|
||||
std::string szTag;
|
||||
int bX11 = -1; // -1 means "ANY"
|
||||
int bFloating = -1;
|
||||
int bFullscreen = -1;
|
||||
|
|
@ -365,6 +369,9 @@ class CWindow {
|
|||
// stores the currently matched window rules
|
||||
std::vector<SWindowRule> m_vMatchedRules;
|
||||
|
||||
// window tags
|
||||
CTagKeeper m_tags;
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const CWindow& rhs) {
|
||||
return m_pXDGSurface == rhs.m_pXDGSurface && m_pXWaylandSurface == rhs.m_pXWaylandSurface && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue