aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLivingCodeX <[email protected]>2024-04-14 20:31:50 +0000
committerGitHub <[email protected]>2024-04-14 21:31:50 +0100
commitfd7ea4f27c8a596d1b72101ab4c0eca5b5b60ed5 (patch)
treeff1fcb7354b9620cbdee071eb8d7b5a39148489e
parente93fbd7c4f991cb8ef03e433ccc4d43587923e15 (diff)
downloadHyprland-fd7ea4f27c8a596d1b72101ab4c0eca5b5b60ed5.tar.gz
Hyprland-fd7ea4f27c8a596d1b72101ab4c0eca5b5b60ed5.zip
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
-rw-r--r--src/desktop/Constraint.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/desktop/Constraint.cpp b/src/desktop/Constraint.cpp
index dfe8d217..428c8745 100644
--- a/src/desktop/Constraint.cpp
+++ b/src/desktop/Constraint.cpp
@@ -1,6 +1,7 @@
#include "Constraint.hpp"
#include "WLSurface.hpp"
#include "../Compositor.hpp"
+#include "../config/ConfigValue.hpp"
CConstraint::CConstraint(wlr_pointer_constraint_v1* constraint, CWLSurface* owner) : m_pOwner(owner), m_pConstraint(constraint) {
RASSERT(!constraint->data, "CConstraint: attempted to duplicate ownership");
@@ -62,8 +63,18 @@ void CConstraint::onCommit() {
const auto COMMITTED = m_pConstraint->current.committed;
if (COMMITTED & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
- m_bHintSet = true;
- m_vPositionHint = {m_pConstraint->current.cursor_hint.x, m_pConstraint->current.cursor_hint.y};
+ static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
+
+ 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();
}