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
|
|
@ -308,4 +308,31 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
|
|||
MAXSIZE.y = 99999;
|
||||
|
||||
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 checkBorders(CWindow*);
|
||||
Vector2D getMaxSizeForWindow(CWindow*);
|
||||
Vector2D xwaylandToWaylandCoords(const Vector2D&);
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
||||
Loading…
Add table
Add a link
Reference in a new issue