-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add per-window content scaling #9428
base: main
Are you sure you want to change the base?
Changes from all commits
e13d685
037d545
c85b6f9
6ba4e54
0d3ccec
c38e2d0
5377126
b7bc1bf
d562ee0
767abf0
613fe44
4ee1b6e
a6024ae
effb3bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ static const auto RULES = 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", | ||
"monitor", "move", "opacity", "plugin:", "prop", "pseudo", "rounding", "roundingpower", "scrollmouse", "scrolltouchpad", | ||
"size", "suppressevent", "tag", "workspace", "xray", | ||
"size", "suppressevent", "tag", "workspace", "xray", "contentscale", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this shouldn't be needed, props are already being searched There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this because like you saw..."everybody is doing it, why don't we". I thought maybe there is some need or plan to have every property listed there, even if they don't get accessed this way. Do I remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you're using a prop ( |
||
}; | ||
|
||
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : szValue(value), szRule(rule), v2(isV2), execRule(isExecRule) { | ||
|
@@ -57,6 +57,8 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool | |
ruleType = RULE_MAXSIZE; | ||
else if (rule.starts_with("minsize")) | ||
ruleType = RULE_MINSIZE; | ||
else if (rule.starts_with("contentscale")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the property needs to be here, because it needs special treatment. Like you mention below, it needs to invert the value and also call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it does if you're using your custom rule type, but like I said bellow this should use the default treatment if you're using a prop ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, since you are using a prop it's handled for you |
||
ruleType = RULE_CONTENTSCALE; | ||
else if (rule.starts_with("monitor")) | ||
ruleType = RULE_MONITOR; | ||
else if (rule.starts_with("move")) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ class CWindowRule { | |
RULE_IDLEINHIBIT, | ||
RULE_MAXSIZE, | ||
RULE_MINSIZE, | ||
RULE_CONTENTSCALE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nor this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what is your suggestion? It is the only way I found to be able to update the client's resolution, invert the scale etc. It seems to me a generic floating point property doesn't allow me to do those things. |
||
RULE_MONITOR, | ||
RULE_MOVE, | ||
RULE_OPACITY, | ||
|
@@ -68,4 +69,4 @@ class CWindowRule { | |
CRuleRegexContainer rInitialTitle; | ||
CRuleRegexContainer rInitialClass; | ||
CRuleRegexContainer rV1Regex; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,7 @@ CKeybindManager::CKeybindManager() { | |
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace; | ||
m_mDispatchers["forcerendererreload"] = forceRendererReload; | ||
m_mDispatchers["resizeactive"] = resizeActive; | ||
m_mDispatchers["scaleactive"] = scaleActive; | ||
m_mDispatchers["moveactive"] = moveActive; | ||
m_mDispatchers["cyclenext"] = circleNext; | ||
m_mDispatchers["focuswindowbyclass"] = focusWindow; | ||
|
@@ -2148,6 +2149,41 @@ SDispatchResult CKeybindManager::resizeActive(std::string args) { | |
return {}; | ||
} | ||
|
||
SDispatchResult CKeybindManager::scaleActive(std::string args) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dispatcher allows absolute and delta increases, as requested above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #9566 would allow that for all props There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so we will wait for that to happen. |
||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock(); | ||
|
||
if (!PLASTWINDOW) | ||
return {.success = false, .error = "Window not found"}; | ||
|
||
std::optional<float> scaleResult; | ||
bool exact = false; | ||
|
||
if (args.starts_with("exact")) { | ||
exact = true; | ||
scaleResult = getPlusMinusKeywordResult(args.substr(5), 0); | ||
} else | ||
scaleResult = getPlusMinusKeywordResult(args, 0); | ||
|
||
if (!scaleResult.has_value()) { | ||
Debug::log(ERR, "Invalid arg \"{}\" in scaleactive!", args); | ||
return {.success = false, .error = "Invalid scale argument in scaleactive!"}; | ||
} | ||
|
||
float scale = scaleResult.value(); | ||
if (!exact) | ||
scale += 1.0 / PLASTWINDOW->m_sWindowData.contentScale.valueOr(1.0f); | ||
|
||
if (scale > 0.0f) { | ||
dawsers marked this conversation as resolved.
Show resolved
Hide resolved
|
||
scale = std::max(scale, 0.25f); | ||
PLASTWINDOW->m_sWindowData.contentScale = CWindowOverridableVar(1.0f / scale, PRIORITY_SET_PROP); | ||
} else | ||
PLASTWINDOW->m_sWindowData.contentScale.unset(PRIORITY_SET_PROP); | ||
|
||
PLASTWINDOW->sendWindowSize(); | ||
|
||
return {}; | ||
} | ||
|
||
SDispatchResult CKeybindManager::moveActive(std::string args) { | ||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow.lock(); | ||
|
||
|
@@ -3135,6 +3171,9 @@ SDispatchResult CKeybindManager::setProp(std::string args) { | |
PWINDOW->m_sWindowData.minSize = CWindowOverridableVar(configStringToVector2D(VAL), PRIORITY_SET_PROP); | ||
PWINDOW->clampWindowSize(PWINDOW->m_sWindowData.minSize.value(), std::nullopt); | ||
PWINDOW->setHidden(false); | ||
} else if (PROP == "contentscale") { | ||
PWINDOW->m_sWindowData.contentScale = CWindowOverridableVar(1.0f / std::stof(VAL), PRIORITY_SET_PROP); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also use the already existing window prop code to support unset and avoid duplication There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need to agree on whether this property is "special" like the others in the When I implemented it at the beginning, I tried to add it to the list, like you suggest. But then I saw I couldn't do the things I needed if I added it there. I saw other properties had the same problem, and I followed their process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a point in inverting the value here as for adding an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The input value is chosen to be similar to fractional scale so the user has a better intuition on how to use the feature, but then internally it is easier to manage it inverted. That is the only reason, and inverting it just here is easier and more efficient than having to do it every time the value is read or written, or so I thought. |
||
PWINDOW->sendWindowSize(); | ||
} else if (PROP == "alpha") { | ||
PWINDOW->m_sWindowData.alpha = CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alpha.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP); | ||
} else if (PROP == "alphainactive") { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be needed