diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-03-02 21:04:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-02 21:04:55 +0000 |
| commit | d72ea5f2a7fdb0d0a7bf914412327195b05199b0 (patch) | |
| tree | 0ebc3bb4c8320e88cfa9010d314122c9533dcc0e /src/events/Devices.cpp | |
| parent | 328ab431655f207a5ee59737291f8e8d85fab992 (diff) | |
input: Rewritten pointer constraints (#4889)
* rewritten constraints
* send pointer enter on activate if not pointer focus
* minor cleanup
* simulate movement on commit
* don't ignore oneshot prop
* various fixes
* dont send motion on confined
* update pos hint on region change
Diffstat (limited to 'src/events/Devices.cpp')
| -rw-r--r-- | src/events/Devices.cpp | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/src/events/Devices.cpp b/src/events/Devices.cpp index 1ba6cad4..64050320 100644 --- a/src/events/Devices.cpp +++ b/src/events/Devices.cpp @@ -97,44 +97,14 @@ void Events::listener_newConstraint(wl_listener* listener, void* data) { Debug::log(LOG, "New mouse constraint at {:x}", (uintptr_t)PCONSTRAINT); - g_pInputManager->m_lConstraints.emplace_back(); - const auto CONSTRAINT = &g_pInputManager->m_lConstraints.back(); + const auto SURFACE = CWLSurface::surfaceFromWlr(PCONSTRAINT->surface); - CONSTRAINT->pMouse = g_pCompositor->m_sSeat.mouse; - CONSTRAINT->constraint = PCONSTRAINT; - - CONSTRAINT->hyprListener_destroyConstraint.initCallback(&PCONSTRAINT->events.destroy, &Events::listener_destroyConstraint, CONSTRAINT, "Constraint"); - CONSTRAINT->hyprListener_setConstraintRegion.initCallback(&PCONSTRAINT->events.set_region, &Events::listener_setConstraintRegion, CONSTRAINT, "Constraint"); - - if (g_pCompositor->m_pLastFocus == PCONSTRAINT->surface) { - g_pInputManager->constrainMouse(CONSTRAINT->pMouse, PCONSTRAINT); - - if (!CONSTRAINT->hintSet) - CONSTRAINT->positionHint = Vector2D{-1, -1}; + if (!SURFACE) { + Debug::log(ERR, "Refusing a constraint from an unassigned wl_surface {:x}", (uintptr_t)PCONSTRAINT->surface); + return; } -} - -void Events::listener_destroyConstraint(void* owner, void* data) { - const auto PCONSTRAINT = (SConstraint*)owner; - - if (PCONSTRAINT->pMouse->currentConstraint == PCONSTRAINT->constraint) { - PCONSTRAINT->pMouse->hyprListener_commitConstraint.removeCallback(); - - const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse); - - if (PWINDOW && PCONSTRAINT->active && PCONSTRAINT->constraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) - g_pInputManager->warpMouseToConstraintMiddle(PCONSTRAINT); - - PCONSTRAINT->pMouse->currentConstraint = nullptr; - } - - Debug::log(LOG, "Unconstrained mouse from {:x}", (uintptr_t)PCONSTRAINT->constraint); - - g_pInputManager->m_lConstraints.remove(*PCONSTRAINT); -} -void Events::listener_setConstraintRegion(void* owner, void* data) { - // no + SURFACE->appendConstraint(PCONSTRAINT); } void Events::listener_newVirtPtr(wl_listener* listener, void* data) { |
