constraint: Fix xwl cursor locking for scaled monitors (#5587)

* Fix xwl cursor locking for scaled monitors

* Add null check for window

* Replace m_fLastScale with m_fX11SurfaceScaledBy

* Improve code style

* Improve code style via clang-format
This commit is contained in:
LivingCodeX 2024-04-14 20:31:50 +00:00 committed by GitHub
parent e93fbd7c4f
commit fd7ea4f27c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
#include "Constraint.hpp" #include "Constraint.hpp"
#include "WLSurface.hpp" #include "WLSurface.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
CConstraint::CConstraint(wlr_pointer_constraint_v1* constraint, CWLSurface* owner) : m_pOwner(owner), m_pConstraint(constraint) { CConstraint::CConstraint(wlr_pointer_constraint_v1* constraint, CWLSurface* owner) : m_pOwner(owner), m_pConstraint(constraint) {
RASSERT(!constraint->data, "CConstraint: attempted to duplicate ownership"); RASSERT(!constraint->data, "CConstraint: attempted to duplicate ownership");
@ -62,8 +63,18 @@ void CConstraint::onCommit() {
const auto COMMITTED = m_pConstraint->current.committed; const auto COMMITTED = m_pConstraint->current.committed;
if (COMMITTED & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) { if (COMMITTED & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
m_bHintSet = true; static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
m_vPositionHint = {m_pConstraint->current.cursor_hint.x, m_pConstraint->current.cursor_hint.y};
m_bHintSet = true;
float scale = 1.f;
const auto PWINDOW = m_pOwner->getWindow();
if (PWINDOW) {
const auto ISXWL = PWINDOW->m_bIsX11;
scale = ISXWL && *PXWLFORCESCALEZERO ? PWINDOW->m_fX11SurfaceScaledBy : 1.f;
}
m_vPositionHint = {m_pConstraint->current.cursor_hint.x / scale, m_pConstraint->current.cursor_hint.y / scale};
g_pInputManager->simulateMouseMovement(); g_pInputManager->simulateMouseMovement();
} }