mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 00:05:58 +01:00
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:
parent
e93fbd7c4f
commit
fd7ea4f27c
1 changed files with 13 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue