mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-03 20:29:48 +01:00
xwayland: fix use of xwayland coords in native spaces
This commit is contained in:
parent
91e28bbe9d
commit
4986d74ef2
4 changed files with 45 additions and 10 deletions
|
@ -413,8 +413,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) { Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
} catch (...) { Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||||
} else if (r.szRule.find("center") == 0) {
|
} else if (r.szRule.find("center") == 0) {
|
||||||
auto RESERVEDOFFSET = Vector2D();
|
auto RESERVEDOFFSET = Vector2D();
|
||||||
const auto ARGS = CVarList(r.szRule, 2, ' ');
|
const auto ARGS = CVarList(r.szRule, 2, ' ');
|
||||||
if (ARGS[1] == "1")
|
if (ARGS[1] == "1")
|
||||||
RESERVEDOFFSET = (PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight) / 2.f;
|
RESERVEDOFFSET = (PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight) / 2.f;
|
||||||
|
|
||||||
|
@ -994,7 +994,9 @@ void Events::listener_configureX11(void* owner, void* data) {
|
||||||
else
|
else
|
||||||
PWINDOW->setHidden(true);
|
PWINDOW->setHidden(true);
|
||||||
|
|
||||||
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
|
const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords({E->x, E->y});
|
||||||
|
|
||||||
|
PWINDOW->m_vRealPosition.setValueAndWarp(LOGICALPOS);
|
||||||
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
|
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
|
||||||
|
|
||||||
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
|
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
|
||||||
|
|
|
@ -77,7 +77,14 @@ void IHyprLayout::onWindowRemovedFloating(CWindow* pWindow) {
|
||||||
void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
wlr_box desiredGeometry = {0};
|
wlr_box desiredGeometry = {0};
|
||||||
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
|
if (pWindow->m_bIsX11) {
|
||||||
|
Vector2D xy = {desiredGeometry.x, desiredGeometry.y};
|
||||||
|
xy = g_pXWaylandManager->xwaylandToWaylandCoords(xy);
|
||||||
|
desiredGeometry.x = xy.x;
|
||||||
|
desiredGeometry.y = xy.y;
|
||||||
|
}
|
||||||
|
|
||||||
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
|
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
|
||||||
|
|
||||||
|
@ -103,7 +110,7 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
if (pWindow->m_bIsX11 && pWindow->m_uSurface.xwayland->override_redirect) {
|
if (pWindow->m_bIsX11 && pWindow->m_uSurface.xwayland->override_redirect) {
|
||||||
|
|
||||||
if (pWindow->m_uSurface.xwayland->x != 0 && pWindow->m_uSurface.xwayland->y != 0)
|
if (pWindow->m_uSurface.xwayland->x != 0 && pWindow->m_uSurface.xwayland->y != 0)
|
||||||
pWindow->m_vRealPosition = Vector2D{pWindow->m_uSurface.xwayland->x, pWindow->m_uSurface.xwayland->y};
|
pWindow->m_vRealPosition = g_pXWaylandManager->xwaylandToWaylandCoords({pWindow->m_uSurface.xwayland->x, pWindow->m_uSurface.xwayland->y});
|
||||||
else
|
else
|
||||||
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f,
|
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f,
|
||||||
PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
|
PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
|
||||||
|
@ -153,10 +160,8 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*PXWLFORCESCALEZERO && pWindow->m_bIsX11) {
|
if (*PXWLFORCESCALEZERO && pWindow->m_bIsX11)
|
||||||
pWindow->m_vRealSize = pWindow->m_vRealSize.goalv() / PMONITOR->scale;
|
pWindow->m_vRealSize = pWindow->m_vRealSize.goalv() / PMONITOR->scale;
|
||||||
pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() / PMONITOR->scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pWindow->m_bX11DoesntWantBorders || (pWindow->m_bIsX11 && pWindow->m_uSurface.xwayland->override_redirect)) {
|
if (pWindow->m_bX11DoesntWantBorders || (pWindow->m_bIsX11 && pWindow->m_uSurface.xwayland->override_redirect)) {
|
||||||
pWindow->m_vRealPosition.warp();
|
pWindow->m_vRealPosition.warp();
|
||||||
|
|
|
@ -308,4 +308,31 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
|
||||||
MAXSIZE.y = 99999;
|
MAXSIZE.y = 99999;
|
||||||
|
|
||||||
return MAXSIZE;
|
return MAXSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) {
|
||||||
|
|
||||||
|
static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue;
|
||||||
|
|
||||||
|
CMonitor* pMonitor = nullptr;
|
||||||
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
|
const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize;
|
||||||
|
if (VECINRECT(coord, m->vecXWaylandPosition.x, m->vecXWaylandPosition.y, SIZ.x, SIZ.y)) {
|
||||||
|
pMonitor = m.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pMonitor)
|
||||||
|
return Vector2D{};
|
||||||
|
|
||||||
|
// get local coords
|
||||||
|
Vector2D result = coord - pMonitor->vecXWaylandPosition;
|
||||||
|
// if scaled, unscale
|
||||||
|
if (*PXWLFORCESCALEZERO)
|
||||||
|
result = result / pMonitor->scale;
|
||||||
|
// add pos
|
||||||
|
result = result + pMonitor->vecPosition;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ class CHyprXWaylandManager {
|
||||||
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
||||||
void checkBorders(CWindow*);
|
void checkBorders(CWindow*);
|
||||||
Vector2D getMaxSizeForWindow(CWindow*);
|
Vector2D getMaxSizeForWindow(CWindow*);
|
||||||
|
Vector2D xwaylandToWaylandCoords(const Vector2D&);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
Loading…
Reference in a new issue