Skip to content

Commit

Permalink
window: fixup sendWindowSize
Browse files Browse the repository at this point in the history
Remove the size argument from sendWindowSize, since it is now a member of the Window class
and we don't want any mismatches between m_vRealSize and what we report.

Remove sendWindowSize from mapWindow, since we shouldn't need it.
  • Loading branch information
PaideiaDilemma committed Feb 3, 2025
1 parent aba6ec5 commit afffb1c
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, SFullscreenS

updateFullscreenFadeOnWorkspace(PWORKSPACE);

PWINDOW->sendWindowSize(PWINDOW->m_vRealSize->goal(), true);
PWINDOW->sendWindowSize(true);

PWORKSPACE->forceReportSizesToWindows();

Expand Down
20 changes: 9 additions & 11 deletions src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
}

// update xwayland coords
sendWindowSize(m_vRealSize->goal());
sendWindowSize();

if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_iID) && OLDWORKSPACE->getWindows() == 0 && *PCLOSEONLASTSPECIAL) {
if (const auto PMONITOR = OLDWORKSPACE->m_pMonitor.lock(); PMONITOR)
Expand Down Expand Up @@ -560,8 +560,8 @@ void CWindow::onMap() {
}

m_vRealSize->setUpdateCallback([this](auto) {
if (m_bIsFloating)
sendWindowSize(m_vRealSize->goal());
if (validMapped(m_pSelf) && m_bIsFloating)
sendWindowSize();
});

m_fMovingFromWorkspaceAlpha->setValueAndWarp(1.F);
Expand Down Expand Up @@ -1316,7 +1316,7 @@ void CWindow::clampWindowSize(const std::optional<Vector2D> minSize, const std::

*m_vRealPosition = m_vRealPosition->goal() + DELTA / 2.0;
*m_vRealSize = NEWSIZE;
sendWindowSize(NEWSIZE);
sendWindowSize();
}

bool CWindow::isFullscreen() {
Expand Down Expand Up @@ -1540,7 +1540,7 @@ void CWindow::onX11Configure(CBox box) {
g_pHyprRenderer->damageWindow(m_pSelf.lock());

if (!m_bIsFloating || isFullscreen() || g_pInputManager->currentlyDraggedWindow == m_pSelf) {
sendWindowSize(m_vRealSize->goal(), true);
sendWindowSize(true);
g_pInputManager->refocus();
g_pHyprRenderer->damageWindow(m_pSelf.lock());
return;
Expand All @@ -1567,7 +1567,7 @@ void CWindow::onX11Configure(CBox box) {
m_vPosition = m_vRealPosition->goal();
m_vSize = m_vRealSize->goal();

sendWindowSize(box.size(), true);
sendWindowSize(true);

m_vPendingReportedSize = box.size();
m_vReportedSize = box.size();
Expand Down Expand Up @@ -1698,15 +1698,13 @@ Vector2D CWindow::requestedMaxSize() {
return maxSize;
}

void CWindow::sendWindowSize(Vector2D size, bool force, std::optional<Vector2D> overridePos) {
void CWindow::sendWindowSize(bool force) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
const auto PMONITOR = m_pMonitor.lock();

size = size.clamp(Vector2D{1, 1}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});

// calculate pos
// TODO: this should be decoupled from setWindowSize IMO
Vector2D windowPos = overridePos.value_or(m_vRealPosition->goal());
Vector2D windowPos = m_vRealPosition->goal();
Vector2D size = m_vRealSize->goal().clamp(Vector2D{1, 1}, Vector2D{std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()});

if (m_bIsX11 && PMONITOR) {
windowPos = g_pXWaylandManager->waylandToXWaylandCoords(windowPos);
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class CWindow {
bool isModal();
Vector2D requestedMinSize();
Vector2D requestedMaxSize();
void sendWindowSize(Vector2D size, bool force = false, std::optional<Vector2D> overridePos = std::nullopt);
void sendWindowSize(bool force = false);

CBox getWindowMainSurfaceBox() const {
return {m_vRealPosition->value().x, m_vRealPosition->value().y, m_vRealSize->value().x, m_vRealSize->value().y};
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/Workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void CWorkspace::forceReportSizesToWindows() {
if (w->m_pWorkspace != m_pSelf || !w->m_bIsMapped || w->isHidden())
continue;

w->sendWindowSize(w->m_vRealSize->goal(), true);
w->sendWindowSize(true);
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,6 @@ void Events::listener_mapWindow(void* owner, void* data) {

if (PMONITOR && PWINDOW->isX11OverrideRedirect())
PWINDOW->m_fX11SurfaceScaledBy = PMONITOR->scale;

if (!PWINDOW->isX11OverrideRedirect() && PWINDOW->m_bIsX11 && PWINDOW->m_bIsFloating)
PWINDOW->sendWindowSize(PWINDOW->m_vRealSize->goal(), true);
}

void Events::listener_unmapWindow(void* owner, void* data) {
Expand Down Expand Up @@ -948,7 +945,7 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
PWINDOW->setHidden(true);

if (PWINDOW->isFullscreen() || !PWINDOW->m_bIsFloating) {
PWINDOW->sendWindowSize(PWINDOW->m_vRealSize->goal(), true);
PWINDOW->sendWindowSize(true);
g_pHyprRenderer->damageWindow(PWINDOW);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/layout/DwindleLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
*PWINDOW->m_vRealPosition = wb.pos();
*PWINDOW->m_vRealSize = wb.size();

PWINDOW->sendWindowSize(wb.size());
PWINDOW->sendWindowSize();
} else {
CBox wb = {calcPos, calcSize};
wb.round(); // avoid rounding mess

*PWINDOW->m_vRealSize = wb.size();
*PWINDOW->m_vRealPosition = wb.pos();

PWINDOW->sendWindowSize(wb.size());
PWINDOW->sendWindowSize();
}

if (force) {
Expand Down
10 changes: 5 additions & 5 deletions src/layout/IHyprLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
}

if (!pWindow->isX11OverrideRedirect()) {
pWindow->sendWindowSize(pWindow->m_vRealSize->goal());
pWindow->sendWindowSize();

g_pCompositor->changeWindowZOrder(pWindow, true);
} else {
Expand Down Expand Up @@ -363,7 +363,7 @@ void IHyprLayout::onEndDragWindow() {
DRAGGINGWINDOW->m_bDraggingTiled = false;

if (pWindow->m_bIsFloating)
DRAGGINGWINDOW->sendWindowSize(DRAGGINGWINDOW->m_vRealSize->goal()); // match the size of the window
DRAGGINGWINDOW->sendWindowSize(); // match the size of the window

static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
(*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW);
Expand Down Expand Up @@ -609,7 +609,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
else
DRAGGINGWINDOW->m_vRealPosition->setValueAndWarp(wb.pos());

DRAGGINGWINDOW->sendWindowSize(DRAGGINGWINDOW->m_vRealSize->goal());
DRAGGINGWINDOW->sendWindowSize();
} else if (g_pInputManager->dragMode == MBIND_RESIZE || g_pInputManager->dragMode == MBIND_RESIZE_FORCE_RATIO || g_pInputManager->dragMode == MBIND_RESIZE_BLOCK_RATIO) {
if (DRAGGINGWINDOW->m_bIsFloating) {

Expand Down Expand Up @@ -681,7 +681,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
DRAGGINGWINDOW->m_vRealPosition->setValueAndWarp(wb.pos());
}

DRAGGINGWINDOW->sendWindowSize(DRAGGINGWINDOW->m_vRealSize->goal());
DRAGGINGWINDOW->sendWindowSize();
} else {
resizeActiveWindow(TICKDELTA, m_eGrabbedCorner, DRAGGINGWINDOW);
}
Expand Down Expand Up @@ -787,7 +787,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {

g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
pWindow->updateToplevel();
pWindow->sendWindowSize(pWindow->m_vRealSize->goal());
pWindow->sendWindowSize();
g_pHyprRenderer->damageWindow(pWindow);
}

Expand Down
4 changes: 2 additions & 2 deletions src/layout/MasterLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,15 +679,15 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
*PWINDOW->m_vRealPosition = wb.pos();
*PWINDOW->m_vRealSize = wb.size();

PWINDOW->sendWindowSize(wb.size());
PWINDOW->sendWindowSize();
} else {
CBox wb = {calcPos, calcSize};
wb.round(); // avoid rounding mess

*PWINDOW->m_vRealPosition = wb.pos();
*PWINDOW->m_vRealSize = wb.size();

PWINDOW->sendWindowSize(wb.size());
PWINDOW->sendWindowSize();
}

if (m_bForceWarps && !*PANIMATE) {
Expand Down
2 changes: 1 addition & 1 deletion src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
if (PWORKSPACE->m_bDefaultFloating) {
w->m_vRealPosition->setValueAndWarp(SAVEDPOS);
w->m_vRealSize->setValueAndWarp(SAVEDSIZE);
w->sendWindowSize(SAVEDSIZE);
w->sendWindowSize();
*w->m_vRealSize = w->m_vRealSize->value() + Vector2D(4, 4);
*w->m_vRealPosition = w->m_vRealPosition->value() - Vector2D(2, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion src/managers/XWaylandManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void CHyprXWaylandManager::activateWindow(PHLWINDOW pWindow, bool activate) {
if (pWindow->m_bIsX11) {

if (activate) {
pWindow->sendWindowSize(pWindow->m_vRealSize->value(), true); // update xwayland output pos
pWindow->sendWindowSize(true); // update xwayland output pos
pWindow->m_pXWaylandSurface->setMinimized(false);

if (!pWindow->isX11OverrideRedirect())
Expand Down
4 changes: 1 addition & 3 deletions src/render/decorations/CHyprGroupBarDecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,13 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND

pDraggedWindow->m_bIsFloating = pWindowInsertAfter->m_bIsFloating; // match the floating state of the window

if (pWindowInsertAfter->m_bIsFloating)
pDraggedWindow->sendWindowSize(pWindowInsertAfter->m_vRealSize->goal()); // match the size of the window

pWindowInsertAfter->insertWindowToGroup(pDraggedWindow);

if (WINDOWINDEX == -1)
std::swap(pDraggedHead->m_sGroupData.head, pWindowInsertEnd->m_sGroupData.head);

m_pWindow->setGroupCurrent(pDraggedWindow);
m_pWindow->sendWindowSize();
pDraggedWindow->applyGroupRules();
pDraggedWindow->updateWindowDecos();
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pDraggedWindow);
Expand Down

0 comments on commit afffb1c

Please sign in to comment.