window: only damage floating on clamped size change (#12633)

currently it damage the entire window if its floating and not x11 nor
fullscreen meaning damage isnt working at all for floating. im tracing
this back to a364df4 where the logic changed from damaging window only
if size was being forced to now unconditonally doing it.

change clampWindowSize to return as a bool if size changed and only
damage window if it got clamped.
This commit is contained in:
Tom Englund 2025-12-11 19:54:43 +01:00 committed by GitHub
parent 5dd224805d
commit 75f6435f70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -1197,14 +1197,19 @@ int CWindow::surfacesCount() {
return no; return no;
} }
void CWindow::clampWindowSize(const std::optional<Vector2D> minSize, const std::optional<Vector2D> maxSize) { bool CWindow::clampWindowSize(const std::optional<Vector2D> minSize, const std::optional<Vector2D> maxSize) {
const Vector2D REALSIZE = m_realSize->goal(); const Vector2D REALSIZE = m_realSize->goal();
const Vector2D MAX = isFullscreen() ? Vector2D{INFINITY, INFINITY} : maxSize.value_or(Vector2D{INFINITY, INFINITY}); const Vector2D MAX = isFullscreen() ? Vector2D{INFINITY, INFINITY} : maxSize.value_or(Vector2D{INFINITY, INFINITY});
const Vector2D NEWSIZE = REALSIZE.clamp(minSize.value_or(Vector2D{MIN_WINDOW_SIZE, MIN_WINDOW_SIZE}), MAX); const Vector2D NEWSIZE = REALSIZE.clamp(minSize.value_or(Vector2D{MIN_WINDOW_SIZE, MIN_WINDOW_SIZE}), MAX);
const Vector2D DELTA = REALSIZE - NEWSIZE; const bool changed = !(NEWSIZE == REALSIZE);
*m_realPosition = m_realPosition->goal() + DELTA / 2.0; if (changed) {
*m_realSize = NEWSIZE; const Vector2D DELTA = REALSIZE - NEWSIZE;
*m_realPosition = m_realPosition->goal() + DELTA / 2.0;
*m_realSize = NEWSIZE;
}
return changed;
} }
bool CWindow::isFullscreen() { bool CWindow::isFullscreen() {
@ -2554,8 +2559,8 @@ void CWindow::commitWindow() {
const auto MINSIZE = m_xdgSurface->m_toplevel->layoutMinSize(); const auto MINSIZE = m_xdgSurface->m_toplevel->layoutMinSize();
const auto MAXSIZE = m_xdgSurface->m_toplevel->layoutMaxSize(); const auto MAXSIZE = m_xdgSurface->m_toplevel->layoutMaxSize();
clampWindowSize(MINSIZE, MAXSIZE > Vector2D{1, 1} ? std::optional<Vector2D>{MAXSIZE} : std::nullopt); if (clampWindowSize(MINSIZE, MAXSIZE > Vector2D{1, 1} ? std::optional<Vector2D>{MAXSIZE} : std::nullopt))
g_pHyprRenderer->damageWindow(m_self.lock()); g_pHyprRenderer->damageWindow(m_self.lock());
} }
if (!m_workspace->m_visible) if (!m_workspace->m_visible)

View file

@ -286,7 +286,7 @@ namespace Desktop::View {
bool onSpecialWorkspace(); bool onSpecialWorkspace();
void activate(bool force = false); void activate(bool force = false);
int surfacesCount(); int surfacesCount();
void clampWindowSize(const std::optional<Vector2D> minSize, const std::optional<Vector2D> maxSize); bool clampWindowSize(const std::optional<Vector2D> minSize, const std::optional<Vector2D> maxSize);
bool isFullscreen(); bool isFullscreen();
bool isEffectiveInternalFSMode(const eFullscreenMode) const; bool isEffectiveInternalFSMode(const eFullscreenMode) const;
int getRealBorderSize() const; int getRealBorderSize() const;