From d72ea5f2a7fdb0d0a7bf914412327195b05199b0 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 2 Mar 2024 21:04:55 +0000 Subject: 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 --- src/Compositor.cpp | 43 +++++++++++-------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) (limited to 'src/Compositor.cpp') diff --git a/src/Compositor.cpp b/src/Compositor.cpp index ee38764a..37626da9 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1040,13 +1040,6 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) { if (pWindow->m_phForeignToplevel) wlr_foreign_toplevel_handle_v1_set_activated(pWindow->m_phForeignToplevel, true); - if (!pWindow->m_bIsX11) { - const auto PCONSTRAINT = wlr_pointer_constraints_v1_constraint_for_surface(m_sWLRPointerConstraints, pWindow->m_uSurface.xdg->surface, m_sSeat.seat); - - if (PCONSTRAINT) - g_pInputManager->constrainMouse(m_sSeat.mouse, PCONSTRAINT); - } - g_pInputManager->recheckIdleInhibitorStatus(); // move to front of the window history @@ -1069,6 +1062,8 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { if (g_pSessionLockManager->isSessionLocked() && !g_pSessionLockManager->isSurfaceSessionLock(pSurface)) return; + const auto PLASTSURF = m_pLastFocus; + // Unfocus last surface if should if (m_pLastFocus && !pWindowOwner) g_pXWaylandManager->activateSurface(m_pLastFocus, false); @@ -1103,6 +1098,15 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { m_pLastFocus = pSurface; EMIT_HOOK_EVENT("keyboardFocus", pSurface); + + const auto SURF = CWLSurface::surfaceFromWlr(pSurface); + const auto OLDSURF = CWLSurface::surfaceFromWlr(PLASTSURF); + + if (OLDSURF && OLDSURF->constraint()) + OLDSURF->constraint()->deactivate(); + + if (SURF && SURF->constraint()) + SURF->constraint()->activate(); } bool CCompositor::windowValidMapped(CWindow* pWindow) { @@ -1770,31 +1774,6 @@ void checkFocusSurfaceIter(wlr_surface* pSurface, int x, int y, void* data) { pair->second = pair->second || pSurface == pair->first; } -CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) { - if (!pMouse->currentConstraint) - return nullptr; - - const auto PSURFACE = pMouse->currentConstraint->surface; - - for (auto& w : m_vWindows) { - if (w->isHidden() || !w->m_bIsMapped || !w->m_pWLSurface.exists()) - continue; - - if (w->m_bIsX11) { - if (PSURFACE == w->m_pWLSurface.wlr()) - return w.get(); - } else { - std::pair check = {PSURFACE, false}; - wlr_surface_for_each_surface(w->m_uSurface.xdg->surface, checkFocusSurfaceIter, &check); - - if (check.second) - return w.get(); - } - } - - return nullptr; -} - CMonitor* CCompositor::getMonitorInDirection(const char& dir) { return this->getMonitorInDirection(m_pLastMonitor, dir); } -- cgit v1.2.3