mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-21 06:53:48 -07:00
touch: detach from pointer input
this detaches touch from pointer input. Touch should not affect where your cursor is, and it doesn't make much sense for it to move when we use touch
This commit is contained in:
@@ -85,3 +85,23 @@ class CLayerSurface {
|
|||||||
return m_layerSurface == rhs.m_layerSurface && m_monitor == rhs.m_monitor;
|
return m_layerSurface == rhs.m_layerSurface && m_monitor == rhs.m_monitor;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool valid(PHLLS l) {
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool valid(PHLLSREF l) {
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool validMapped(PHLLS l) {
|
||||||
|
if (!valid(l))
|
||||||
|
return false;
|
||||||
|
return l->m_mapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool validMapped(PHLLSREF l) {
|
||||||
|
if (!valid(l))
|
||||||
|
return false;
|
||||||
|
return l->m_mapped;
|
||||||
|
}
|
||||||
|
@@ -164,13 +164,13 @@ void CInputManager::sendMotionEventsToFocused() {
|
|||||||
g_pSeatManager->setPointerFocus(g_pCompositor->m_lastFocus.lock(), LOCAL);
|
g_pSeatManager->setPointerFocus(g_pCompositor->m_lastFocus.lock(), LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) {
|
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, std::optional<Vector2D> overridePos) {
|
||||||
m_lastInputMouse = mouse;
|
m_lastInputMouse = mouse;
|
||||||
|
|
||||||
if (!g_pCompositor->m_readyToProcess || g_pCompositor->m_isShuttingDown || g_pCompositor->m_unsafeState)
|
if (!g_pCompositor->m_readyToProcess || g_pCompositor->m_isShuttingDown || g_pCompositor->m_unsafeState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector2D const mouseCoords = getMouseCoordsInternal();
|
Vector2D const mouseCoords = overridePos.value_or(getMouseCoordsInternal());
|
||||||
auto const MOUSECOORDSFLOORED = mouseCoords.floor();
|
auto const MOUSECOORDSFLOORED = mouseCoords.floor();
|
||||||
|
|
||||||
if (MOUSECOORDSFLOORED == m_lastCursorPosFloored && !refocus)
|
if (MOUSECOORDSFLOORED == m_lastCursorPosFloored && !refocus)
|
||||||
@@ -1488,8 +1488,8 @@ bool CInputManager::shouldIgnoreVirtualKeyboard(SP<IKeyboard> pKeyboard) {
|
|||||||
return !pKeyboard || (client && !m_relay.m_inputMethod.expired() && m_relay.m_inputMethod->grabClient() == client);
|
return !pKeyboard || (client && !m_relay.m_inputMethod.expired() && m_relay.m_inputMethod->grabClient() == client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::refocus() {
|
void CInputManager::refocus(std::optional<Vector2D> overridePos) {
|
||||||
mouseMoveUnified(0, true);
|
mouseMoveUnified(0, true, false, overridePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
|
bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
|
||||||
|
@@ -116,7 +116,7 @@ class CInputManager {
|
|||||||
bool isLocked();
|
bool isLocked();
|
||||||
|
|
||||||
Vector2D getMouseCoordsInternal();
|
Vector2D getMouseCoordsInternal();
|
||||||
void refocus();
|
void refocus(std::optional<Vector2D> overridePos = std::nullopt);
|
||||||
bool refocusLastWindow(PHLMONITOR pMonitor);
|
bool refocusLastWindow(PHLMONITOR pMonitor);
|
||||||
void simulateMouseMovement();
|
void simulateMouseMovement();
|
||||||
void sendMotionEventsToFocused();
|
void sendMotionEventsToFocused();
|
||||||
@@ -244,7 +244,7 @@ class CInputManager {
|
|||||||
|
|
||||||
uint32_t m_capabilities = 0;
|
uint32_t m_capabilities = 0;
|
||||||
|
|
||||||
void mouseMoveUnified(uint32_t, bool refocus = false, bool mouse = false);
|
void mouseMoveUnified(uint32_t, bool refocus = false, bool mouse = false, std::optional<Vector2D> overridePos = std::nullopt);
|
||||||
void recheckMouseWarpOnMouseInput();
|
void recheckMouseWarpOnMouseInput();
|
||||||
|
|
||||||
SP<CTabletTool> ensureTabletToolPresent(SP<Aquamarine::ITabletTool>);
|
SP<CTabletTool> ensureTabletToolPresent(SP<Aquamarine::ITabletTool>);
|
||||||
|
@@ -27,9 +27,9 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
|||||||
|
|
||||||
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_lastMonitor.lock();
|
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_lastMonitor.lock();
|
||||||
|
|
||||||
g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true);
|
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||||
|
|
||||||
refocus();
|
refocus(TOUCH_COORDS);
|
||||||
|
|
||||||
if (m_clickBehavior == CLICKMODE_KILL) {
|
if (m_clickBehavior == CLICKMODE_KILL) {
|
||||||
IPointer::SButtonEvent e;
|
IPointer::SButtonEvent e;
|
||||||
@@ -78,27 +78,27 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
|||||||
Vector2D local;
|
Vector2D local;
|
||||||
|
|
||||||
if (m_touchData.touchFocusLockSurface) {
|
if (m_touchData.touchFocusLockSurface) {
|
||||||
local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->m_position;
|
local = TOUCH_COORDS - PMONITOR->m_position;
|
||||||
m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
m_touchData.touchSurfaceOrigin = TOUCH_COORDS - local;
|
||||||
} else if (!m_touchData.touchFocusWindow.expired()) {
|
} else if (!m_touchData.touchFocusWindow.expired()) {
|
||||||
if (m_touchData.touchFocusWindow->m_isX11) {
|
if (m_touchData.touchFocusWindow->m_isX11) {
|
||||||
local = (g_pInputManager->getMouseCoordsInternal() - m_touchData.touchFocusWindow->m_realPosition->goal()) * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy;
|
local = (TOUCH_COORDS - m_touchData.touchFocusWindow->m_realPosition->goal()) * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy;
|
||||||
m_touchData.touchSurfaceOrigin = m_touchData.touchFocusWindow->m_realPosition->goal();
|
m_touchData.touchSurfaceOrigin = m_touchData.touchFocusWindow->m_realPosition->goal();
|
||||||
} else {
|
} else {
|
||||||
g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_touchData.touchFocusWindow.lock(), local);
|
g_pCompositor->vectorWindowToSurface(TOUCH_COORDS, m_touchData.touchFocusWindow.lock(), local);
|
||||||
m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
m_touchData.touchSurfaceOrigin = TOUCH_COORDS - local;
|
||||||
}
|
}
|
||||||
} else if (!m_touchData.touchFocusLS.expired()) {
|
} else if (!m_touchData.touchFocusLS.expired()) {
|
||||||
PHLLS foundSurf;
|
PHLLS foundSurf;
|
||||||
Vector2D foundCoords;
|
Vector2D foundCoords;
|
||||||
auto surf = g_pCompositor->vectorToLayerPopupSurface(g_pInputManager->getMouseCoordsInternal(), PMONITOR, &foundCoords, &foundSurf);
|
auto surf = g_pCompositor->vectorToLayerPopupSurface(TOUCH_COORDS, PMONITOR, &foundCoords, &foundSurf);
|
||||||
if (surf) {
|
if (surf) {
|
||||||
local = foundCoords;
|
local = foundCoords;
|
||||||
m_touchData.touchFocusSurface = surf;
|
m_touchData.touchFocusSurface = surf;
|
||||||
} else
|
} else
|
||||||
local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchFocusLS->m_geometry.pos();
|
local = TOUCH_COORDS - m_touchData.touchFocusLS->m_geometry.pos();
|
||||||
|
|
||||||
m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
m_touchData.touchSurfaceOrigin = TOUCH_COORDS - local;
|
||||||
} else
|
} else
|
||||||
return; // oops, nothing found.
|
return; // oops, nothing found.
|
||||||
|
|
||||||
@@ -151,27 +151,23 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_touchData.touchFocusLockSurface) {
|
if (m_touchData.touchFocusLockSurface) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_touchData.touchFocusLockSurface->iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_touchData.touchFocusLockSurface->iMonitorID);
|
||||||
g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true);
|
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||||
auto local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->m_position;
|
const auto LOCAL = TOUCH_COORDS - PMONITOR->m_position;
|
||||||
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local);
|
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, LOCAL);
|
||||||
} else if (validMapped(m_touchData.touchFocusWindow)) {
|
} else if (validMapped(m_touchData.touchFocusWindow)) {
|
||||||
const auto PMONITOR = m_touchData.touchFocusWindow->m_monitor.lock();
|
const auto PMONITOR = m_touchData.touchFocusWindow->m_monitor.lock();
|
||||||
|
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||||
g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true);
|
auto local = TOUCH_COORDS - m_touchData.touchSurfaceOrigin;
|
||||||
|
|
||||||
auto local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchSurfaceOrigin;
|
|
||||||
if (m_touchData.touchFocusWindow->m_isX11)
|
if (m_touchData.touchFocusWindow->m_isX11)
|
||||||
local = local * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy;
|
local = local * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy;
|
||||||
|
|
||||||
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local);
|
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local);
|
||||||
} else if (!m_touchData.touchFocusLS.expired()) {
|
} else if (validMapped(m_touchData.touchFocusLS)) {
|
||||||
const auto PMONITOR = m_touchData.touchFocusLS->m_monitor.lock();
|
const auto PMONITOR = m_touchData.touchFocusLS->m_monitor.lock();
|
||||||
|
const auto TOUCH_COORDS = PMONITOR->m_position + (e.pos * PMONITOR->m_size);
|
||||||
|
const auto LOCAL = TOUCH_COORDS - m_touchData.touchSurfaceOrigin;
|
||||||
|
|
||||||
g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true);
|
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, LOCAL);
|
||||||
|
|
||||||
const auto local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchSurfaceOrigin;
|
|
||||||
|
|
||||||
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user