mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 04:45:57 +01:00
Merge branch 'hyprwm:main' into main
This commit is contained in:
commit
a5ac4f4852
2 changed files with 29 additions and 13 deletions
|
@ -330,24 +330,38 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
for (auto const& r : PWINDOW->m_vMatchedRules) {
|
for (auto const& r : PWINDOW->m_vMatchedRules) {
|
||||||
if (r.szRule.starts_with("size")) {
|
if (r.szRule.starts_with("size")) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
auto stringToFloatClamp = [](const std::string& VALUE, const float CURR, const float REL) {
|
||||||
|
auto stringToPercentage = [](const std::string& VALUE, const float REL) {
|
||||||
|
if (VALUE.ends_with('%'))
|
||||||
|
return (std::stof(VALUE.substr(0, VALUE.length() - 1)) * REL) / 100;
|
||||||
|
else
|
||||||
|
return std::stof(VALUE);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (VALUE.starts_with('<'))
|
||||||
|
return std::min(CURR, stringToPercentage(VALUE.substr(1, VALUE.length() - 1), REL));
|
||||||
|
else if (VALUE.starts_with('>'))
|
||||||
|
return std::max(CURR, stringToPercentage(VALUE.substr(1, VALUE.length() - 1), REL));
|
||||||
|
|
||||||
|
return stringToPercentage(VALUE, REL);
|
||||||
|
};
|
||||||
|
|
||||||
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
||||||
|
|
||||||
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
|
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
|
||||||
|
|
||||||
const auto SIZEX = SIZEXSTR == "max" ?
|
const float SIZEX =
|
||||||
std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) :
|
SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : stringToFloatClamp(SIZEXSTR, PWINDOW->m_vRealSize.goal().x, PMONITOR->vecSize.x);
|
||||||
(!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stof(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
|
|
||||||
const auto SIZEY = SIZEYSTR == "max" ?
|
const float SIZEY =
|
||||||
std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) :
|
SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : stringToFloatClamp(SIZEYSTR, PWINDOW->m_vRealSize.goal().y, PMONITOR->vecSize.y);
|
||||||
(!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stof(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
|
|
||||||
|
|
||||||
Debug::log(LOG, "Rule size, applying to {}", PWINDOW);
|
Debug::log(LOG, "Rule size, applying to {}", PWINDOW);
|
||||||
|
|
||||||
PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY);
|
PWINDOW->clampWindowSize(Vector2D{SIZEXSTR.starts_with("<") ? 0 : SIZEX, SIZEYSTR.starts_with("<") ? 0 : SIZEY}, Vector2D{SIZEX, SIZEY});
|
||||||
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goal();
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goal());
|
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) { Debug::log(LOG, "Rule size failed, rule: {} -> {}", r.szRule, r.szValue); }
|
} catch (...) { Debug::log(LOG, "Rule size failed, rule: {} -> {}", r.szRule, r.szValue); }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "../config/ConfigValue.hpp"
|
#include "../config/ConfigValue.hpp"
|
||||||
#include "../protocols/FractionalScale.hpp"
|
#include "../protocols/FractionalScale.hpp"
|
||||||
#include "../protocols/SessionLock.hpp"
|
#include "../protocols/SessionLock.hpp"
|
||||||
|
#include "../managers/SeatManager.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
|
||||||
});
|
});
|
||||||
|
|
||||||
g_pCompositor->focusSurface(nullptr);
|
g_pCompositor->focusSurface(nullptr);
|
||||||
|
g_pSeatManager->setGrab(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSessionLockManager::isSessionLocked() {
|
bool CSessionLockManager::isSessionLocked() {
|
||||||
|
|
Loading…
Reference in a new issue