mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-05-19 08:30:22 -07:00
parent
5bd7ff884d
commit
b10a43dabc
@ -2547,10 +2547,9 @@ void CCompositor::warpCursorTo(const Vector2D& pos, bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::closeWindow(PHLWINDOW pWindow) {
|
void CCompositor::closeWindow(PHLWINDOW pWindow) {
|
||||||
if (pWindow && validMapped(pWindow)) {
|
if (pWindow && validMapped(pWindow))
|
||||||
g_pXWaylandManager->sendCloseWindow(pWindow);
|
g_pXWaylandManager->sendCloseWindow(pWindow);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PHLLS CCompositor::getLayerSurfaceFromSurface(SP<CWLSurfaceResource> pSurface) {
|
PHLLS CCompositor::getLayerSurfaceFromSurface(SP<CWLSurfaceResource> pSurface) {
|
||||||
std::pair<SP<CWLSurfaceResource>, bool> result = {pSurface, false};
|
std::pair<SP<CWLSurfaceResource>, bool> result = {pSurface, false};
|
||||||
|
@ -311,6 +311,9 @@ class CWindow {
|
|||||||
// ANR
|
// ANR
|
||||||
PHLANIMVAR<float> m_notRespondingTint;
|
PHLANIMVAR<float> m_notRespondingTint;
|
||||||
|
|
||||||
|
// For the noclosefor windowrule
|
||||||
|
Time::steady_tp m_closeableSince = Time::steadyNow();
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const CWindow& rhs) const {
|
bool operator==(const CWindow& rhs) const {
|
||||||
return m_xdgSurface == rhs.m_xdgSurface && m_xwaylandSurface == rhs.m_xwaylandSurface && m_position == rhs.m_position && m_size == rhs.m_size &&
|
return m_xdgSurface == rhs.m_xdgSurface && m_xwaylandSurface == rhs.m_xwaylandSurface && m_position == rhs.m_position && m_size == rhs.m_size &&
|
||||||
|
@ -8,9 +8,9 @@ static const auto RULES = std::unordered_set<std::string>{
|
|||||||
"float", "fullscreen", "maximize", "noinitialfocus", "pin", "stayfocused", "tile", "renderunfocused", "persistentsize",
|
"float", "fullscreen", "maximize", "noinitialfocus", "pin", "stayfocused", "tile", "renderunfocused", "persistentsize",
|
||||||
};
|
};
|
||||||
static const auto RULES_PREFIX = std::unordered_set<std::string>{
|
static const auto RULES_PREFIX = std::unordered_set<std::string>{
|
||||||
"animation", "bordercolor", "bordersize", "center", "content", "fullscreenstate", "group", "idleinhibit", "maxsize", "minsize",
|
"animation", "bordercolor", "bordersize", "center", "content", "fullscreenstate", "group", "idleinhibit", "maxsize", "minsize", "monitor",
|
||||||
"monitor", "move", "opacity", "plugin:", "prop", "pseudo", "rounding", "roundingpower", "scrollmouse", "scrolltouchpad",
|
"move", "noclosefor", "opacity", "plugin:", "prop", "pseudo", "rounding", "roundingpower", "scrollmouse", "scrolltouchpad", "size",
|
||||||
"size", "suppressevent", "tag", "workspace", "xray",
|
"suppressevent", "tag", "workspace", "xray",
|
||||||
};
|
};
|
||||||
|
|
||||||
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) {
|
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) {
|
||||||
@ -79,6 +79,8 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool
|
|||||||
m_ruleType = RULE_PROP;
|
m_ruleType = RULE_PROP;
|
||||||
else if (rule.starts_with("content"))
|
else if (rule.starts_with("content"))
|
||||||
m_ruleType = RULE_CONTENT;
|
m_ruleType = RULE_CONTENT;
|
||||||
|
else if (rule.starts_with("noclosefor"))
|
||||||
|
m_ruleType = RULE_NOCLOSEFOR;
|
||||||
else {
|
else {
|
||||||
// check if this is a prop.
|
// check if this is a prop.
|
||||||
const CVarList VARS(rule, 0, 's', true);
|
const CVarList VARS(rule, 0, 's', true);
|
||||||
|
@ -37,7 +37,8 @@ class CWindowRule {
|
|||||||
RULE_WORKSPACE,
|
RULE_WORKSPACE,
|
||||||
RULE_PROP,
|
RULE_PROP,
|
||||||
RULE_CONTENT,
|
RULE_CONTENT,
|
||||||
RULE_PERSISTENTSIZE
|
RULE_PERSISTENTSIZE,
|
||||||
|
RULE_NOCLOSEFOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
eRuleType m_ruleType = RULE_INVALID;
|
eRuleType m_ruleType = RULE_INVALID;
|
||||||
|
@ -315,6 +315,12 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||||||
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
|
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CWindowRule::RULE_NOCLOSEFOR: {
|
||||||
|
const CVarList VARS(r->m_rule, 0, ' ');
|
||||||
|
try {
|
||||||
|
PWINDOW->m_closeableSince = Time::steadyNow() + std::chrono::milliseconds(std::stoull(VARS[1]));
|
||||||
|
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); }
|
||||||
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,6 +1037,9 @@ SDispatchResult CKeybindManager::killActive(std::string args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::closeActive(std::string args) {
|
SDispatchResult CKeybindManager::closeActive(std::string args) {
|
||||||
|
if (g_pCompositor->m_lastWindow && g_pCompositor->m_lastWindow->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(g_pCompositor->m_lastWindow.lock());
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -1050,6 +1053,9 @@ SDispatchResult CKeybindManager::closeWindow(std::string args) {
|
|||||||
return {.success = false, .error = "closeWindow: no window found"};
|
return {.success = false, .error = "closeWindow: no window found"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PWINDOW->m_closeableSince > Time::steadyNow())
|
||||||
|
return {.success = false, .error = "can't close window, it's not closeable yet (noclosefor)"};
|
||||||
|
|
||||||
g_pCompositor->closeWindow(PWINDOW);
|
g_pCompositor->closeWindow(PWINDOW);
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user