input: hold focus on mouse buttons

This commit is contained in:
vaxerski
2023-04-02 13:30:45 +01:00
parent c2b25f4701
commit 0fc145c52c
3 changed files with 57 additions and 0 deletions

View File

@@ -145,6 +145,32 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
// update stuff
updateDragIcon();
if (!m_sDrag.drag && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_pLastFocus) {
if (m_bLastFocusOnLS) {
foundSurface = g_pCompositor->m_pLastFocus;
pFoundLayerSurface = g_pCompositor->getLayerSurfaceFromSurface(foundSurface);
if (pFoundLayerSurface) {
surfacePos = g_pCompositor->getLayerSurfaceFromSurface(foundSurface)->position;
m_bFocusHeldByButtons = true;
m_bRefocusHeldByButtons = refocus;
} else {
// ?
foundSurface = nullptr;
pFoundLayerSurface = nullptr;
}
} else if (g_pCompositor->m_pLastWindow) {
foundSurface = g_pCompositor->m_pLastFocus;
if (!g_pCompositor->m_pLastWindow->m_bIsX11)
g_pCompositor->vectorWindowToSurface(mouseCoords, g_pCompositor->m_pLastWindow, surfaceCoords);
else
surfacePos = g_pCompositor->m_pLastWindow->m_vRealPosition.vec();
m_bFocusHeldByButtons = true;
m_bRefocusHeldByButtons = refocus;
}
}
g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
if (PMONITOR && PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus)) {
@@ -391,6 +417,16 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
case CLICKMODE_KILL: processMouseDownKill(e); break;
default: break;
}
if (m_bFocusHeldByButtons && m_lCurrentlyHeldButtons.empty() && e->state == WLR_BUTTON_RELEASED) {
if (m_bRefocusHeldByButtons)
refocus();
else
simulateMouseMovement();
m_bFocusHeldByButtons = false;
m_bRefocusHeldByButtons = false;
}
}
void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_event* e) {