Skip to content

Commit

Permalink
window: move most calls to sendWindowSize to the animation begin
Browse files Browse the repository at this point in the history
callback
  • Loading branch information
PaideiaDilemma committed Feb 5, 2025
1 parent 56d6aa0 commit 53ebcd9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 30 deletions.
15 changes: 7 additions & 8 deletions src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,6 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
SWALLOWED->m_pMonitor = m_pMonitor;
}

// update xwayland coords
sendWindowSize();

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

m_vRealSize->setCallbackOnBegin(
[this](auto) {
if (m_bIsMapped && m_bIsFloating)
sendWindowSize();
if (!m_bIsMapped || isX11OverrideRedirect())
return;

sendWindowSize();
},
false);

Expand Down Expand Up @@ -1320,7 +1319,6 @@ void CWindow::clampWindowSize(const std::optional<Vector2D> minSize, const std::

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

bool CWindow::isFullscreen() {
Expand Down Expand Up @@ -1571,8 +1569,6 @@ void CWindow::onX11Configure(CBox box) {
m_vPosition = m_vRealPosition->goal();
m_vSize = m_vRealSize->goal();

sendWindowSize(true);

m_vPendingReportedSize = box.size();
m_vReportedSize = box.size();

Expand Down Expand Up @@ -1706,6 +1702,9 @@ void CWindow::sendWindowSize(bool force) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
const auto PMONITOR = m_pMonitor.lock();

Debug::log(TRACE, "sendWindowSize: window:{:x},title:{} with real pos {}, real size {} (force: {})", (uintptr_t)this, this->m_szTitle, m_vRealPosition->goal(),
m_vRealSize->goal(), force);

// TODO: this should be decoupled from setWindowSize IMO
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()});
Expand Down
4 changes: 0 additions & 4 deletions src/layout/DwindleLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,12 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for

*PWINDOW->m_vRealPosition = wb.pos();
*PWINDOW->m_vRealSize = 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();
}

if (force) {
Expand Down
18 changes: 6 additions & 12 deletions src/layout/IHyprLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
pWindow->m_vRealSize->warp();
}

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

if (!pWindow->isX11OverrideRedirect())
g_pCompositor->changeWindowZOrder(pWindow, true);
} else {
else {
pWindow->m_vPendingReportedSize = pWindow->m_vRealSize->goal();
pWindow->m_vReportedSize = pWindow->m_vPendingReportedSize;
}
Expand Down Expand Up @@ -362,9 +360,6 @@ void IHyprLayout::onEndDragWindow() {
DRAGGINGWINDOW->m_vLastFloatingSize = m_vDraggingWindowOriginalFloatSize;
DRAGGINGWINDOW->m_bDraggingTiled = false;

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

static auto USECURRPOS = CConfigValue<Hyprlang::INT>("group:insert_after_current");
(*USECURRPOS ? pWindow : pWindow->getGroupTail())->insertWindowToGroup(DRAGGINGWINDOW);
pWindow->setGroupCurrent(DRAGGINGWINDOW);
Expand Down Expand Up @@ -606,10 +601,11 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {

if (*PANIMATEMOUSE)
*DRAGGINGWINDOW->m_vRealPosition = wb.pos();
else
else {
DRAGGINGWINDOW->m_vRealPosition->setValueAndWarp(wb.pos());
DRAGGINGWINDOW->sendWindowSize();
}

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 @@ -679,9 +675,8 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
} else {
DRAGGINGWINDOW->m_vRealSize->setValueAndWarp(wb.size());
DRAGGINGWINDOW->m_vRealPosition->setValueAndWarp(wb.pos());
DRAGGINGWINDOW->sendWindowSize();
}

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

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

Expand Down
4 changes: 0 additions & 4 deletions src/layout/MasterLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,12 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {

*PWINDOW->m_vRealPosition = wb.pos();
*PWINDOW->m_vRealSize = 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();
}

if (m_bForceWarps && !*PANIMATE) {
Expand Down
1 change: 0 additions & 1 deletion src/managers/KeybindManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,6 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
if (PWORKSPACE->m_bDefaultFloating) {
w->m_vRealPosition->setValueAndWarp(SAVEDPOS);
w->m_vRealSize->setValueAndWarp(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
1 change: 0 additions & 1 deletion src/render/decorations/CHyprGroupBarDecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
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 53ebcd9

Please sign in to comment.