Skip to content
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

window: move size reporting to animation begin callback #9298

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,7 @@ void CCompositor::setWindowFullscreenState(const PHLWINDOW PWINDOW, SFullscreenS

updateFullscreenFadeOnWorkspace(PWORKSPACE);

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

PWORKSPACE->forceReportSizesToWindows();

Expand Down
23 changes: 14 additions & 9 deletions src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,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 @@ -561,6 +561,13 @@ void CWindow::onMap() {
*m_fBorderAngleAnimationProgress = 1.f;
}

m_vRealSize->setCallbackOnBegin(
[this](auto) {
if (m_bIsMapped && m_bIsFloating)
sendWindowSize();
},
false);

m_fMovingFromWorkspaceAlpha->setValueAndWarp(1.F);

g_pCompositor->m_vWindowFocusHistory.push_back(m_pSelf);
Expand Down Expand Up @@ -1313,7 +1320,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 @@ -1537,7 +1544,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 @@ -1564,7 +1571,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 @@ -1695,15 +1702,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 @@ -470,7 +470,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);
NContentType::eContentType getContentType();
void setContentType(NContentType::eContentType contentType);

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
9 changes: 1 addition & 8 deletions src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,6 @@ void Events::listener_mapWindow(void* owner, void* data) {

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

// Fix some X11 popups being invisible / having incorrect size on open.
// What the ACTUAL FUCK is going on?????? I HATE X11
if (!PWINDOW->isX11OverrideRedirect() && PWINDOW->m_bIsX11 && PWINDOW->m_bIsFloating) {
PWINDOW->sendWindowSize(PWINDOW->m_vRealSize->goal(), true, PWINDOW->m_vRealPosition->goal() - Vector2D{1, 1});
PWINDOW->sendWindowSize(PWINDOW->m_vRealSize->goal(), true);
}
}

void Events::listener_unmapWindow(void* owner, void* data) {
Expand Down Expand Up @@ -959,7 +952,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 @@ -1907,7 +1907,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
Loading