xdg: check for floating conditions before sending tiled size hint

ref #4871
This commit is contained in:
Vaxry 2024-02-28 23:14:50 +00:00
parent 097f561e41
commit 1e7eb3a5a5
4 changed files with 30 additions and 13 deletions

View file

@ -946,7 +946,7 @@ SWorkspaceRule CConfigManager::getWorkspaceRuleFor(CWorkspace* pWorkspace) {
}
std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow, bool dynamic) {
if (!g_pCompositor->windowValidMapped(pWindow))
if (!g_pCompositor->windowExists(pWindow))
return std::vector<SWindowRule>();
std::vector<SWindowRule> returns;

View file

@ -806,9 +806,26 @@ void Events::listener_commitWindow(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
if (!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->initial_commit) {
const auto PREDSIZE = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow();
Debug::log(LOG, "Layout predicts size {} for {}", PREDSIZE, PWINDOW);
wlr_xdg_toplevel_set_size(PWINDOW->m_uSurface.xdg->toplevel, PREDSIZE.x, PREDSIZE.y);
Vector2D predSize = g_pLayoutManager->getCurrentLayout()->predictSizeForNewWindow();
if (g_pXWaylandManager->shouldBeFloated(PWINDOW, true))
predSize = {};
Vector2D maxSize = Vector2D{PWINDOW->m_uSurface.xdg->toplevel->pending.max_width, PWINDOW->m_uSurface.xdg->toplevel->pending.max_height};
if ((maxSize.x > 0 && maxSize.x < predSize.x) || (maxSize.y > 0 && maxSize.y < predSize.y))
predSize = {};
for (auto& r : g_pConfigManager->getMatchingRules(PWINDOW)) {
if (r.szRule == "float") {
predSize = {};
break;
}
}
Debug::log(LOG, "Layout predicts size {} for {}", predSize, PWINDOW);
wlr_xdg_toplevel_set_size(PWINDOW->m_uSurface.xdg->toplevel, predSize.x, predSize.y);
return;
}

View file

@ -98,11 +98,11 @@ void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, CBox* pbox) {
}
std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
if (!pWindow->m_bIsMapped)
return "";
try {
if (pWindow->m_bIsX11) {
if (!pWindow->m_bIsMapped && pWindow->m_iX11Type != 1)
return "";
if (pWindow->m_uSurface.xwayland && pWindow->m_uSurface.xwayland->title) {
return std::string(pWindow->m_uSurface.xwayland->title);
}
@ -119,11 +119,11 @@ std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
}
std::string CHyprXWaylandManager::getAppIDClass(CWindow* pWindow) {
if (!pWindow->m_bIsMapped)
return "";
try {
if (pWindow->m_bIsX11) {
if (!pWindow->m_bIsMapped && pWindow->m_iX11Type != 1)
return "";
if (pWindow->m_uSurface.xwayland && pWindow->m_uSurface.xwayland->_class) {
return std::string(pWindow->m_uSurface.xwayland->_class);
}
@ -198,7 +198,7 @@ wlr_surface* CHyprXWaylandManager::surfaceAt(CWindow* pWindow, const Vector2D& c
return wlr_xdg_surface_surface_at(pWindow->m_uSurface.xdg, client.x, client.y, &surface.x, &surface.y);
}
bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow, bool pending) {
if (pWindow->m_bIsX11) {
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++)
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"] ||
@ -243,7 +243,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
if (SIZEHINTS && (pWindow->m_uSurface.xwayland->parent || ((SIZEHINTS->min_width == SIZEHINTS->max_width) && (SIZEHINTS->min_height == SIZEHINTS->max_height))))
return true;
} else {
const auto PSTATE = &pWindow->m_uSurface.xdg->toplevel->current;
const auto PSTATE = pending ? &pWindow->m_uSurface.xdg->toplevel->pending : &pWindow->m_uSurface.xdg->toplevel->current;
if ((PSTATE->min_width != 0 && PSTATE->min_height != 0 && (PSTATE->min_width == PSTATE->max_width || PSTATE->min_height == PSTATE->max_height)) ||
pWindow->m_uSurface.xdg->toplevel->parent)

View file

@ -23,7 +23,7 @@ class CHyprXWaylandManager {
void setWindowStyleTiled(CWindow*, uint32_t);
void setWindowFullscreen(CWindow*, bool);
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
bool shouldBeFloated(CWindow*);
bool shouldBeFloated(CWindow*, bool pending = false);
void moveXWaylandWindow(CWindow*, const Vector2D&);
void checkBorders(CWindow*);
Vector2D getMaxSizeForWindow(CWindow*);