input: pass touch events to lock screens (#9129)
* refactor: use weak pointers for session lock surfaces * input: pass touch events to lock screens
This commit is contained in:
parent
bce58d9d65
commit
9199a9746d
6 changed files with 47 additions and 25 deletions
|
|
@ -95,20 +95,20 @@ bool CSessionLockManager::isSessionLocked() {
|
||||||
return PROTO::sessionLock->isLocked();
|
return PROTO::sessionLock->isLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
SSessionLockSurface* CSessionLockManager::getSessionLockSurfaceForMonitor(uint64_t id) {
|
WP<SSessionLockSurface> CSessionLockManager::getSessionLockSurfaceForMonitor(uint64_t id) {
|
||||||
if (!m_pSessionLock)
|
if (!m_pSessionLock)
|
||||||
return nullptr;
|
return {};
|
||||||
|
|
||||||
for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) {
|
for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) {
|
||||||
if (sls->iMonitorID == id) {
|
if (sls->iMonitorID == id) {
|
||||||
if (sls->mapped)
|
if (sls->mapped)
|
||||||
return sls.get();
|
return sls;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want the red screen to flash.
|
// We don't want the red screen to flash.
|
||||||
|
|
|
||||||
|
|
@ -49,20 +49,20 @@ class CSessionLockManager {
|
||||||
CSessionLockManager();
|
CSessionLockManager();
|
||||||
~CSessionLockManager() = default;
|
~CSessionLockManager() = default;
|
||||||
|
|
||||||
SSessionLockSurface* getSessionLockSurfaceForMonitor(uint64_t);
|
WP<SSessionLockSurface> getSessionLockSurfaceForMonitor(uint64_t);
|
||||||
|
|
||||||
float getRedScreenAlphaForMonitor(uint64_t);
|
float getRedScreenAlphaForMonitor(uint64_t);
|
||||||
|
|
||||||
bool isSessionLocked();
|
bool isSessionLocked();
|
||||||
bool isSessionLockPresent();
|
bool isSessionLockPresent();
|
||||||
bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
|
bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
|
||||||
bool anySessionLockSurfacesPresent();
|
bool anySessionLockSurfacesPresent();
|
||||||
|
|
||||||
void removeSessionLockSurface(SSessionLockSurface*);
|
void removeSessionLockSurface(SSessionLockSurface*);
|
||||||
|
|
||||||
void onLockscreenRenderedOnMonitor(uint64_t id);
|
void onLockscreenRenderedOnMonitor(uint64_t id);
|
||||||
|
|
||||||
bool shallConsiderLockMissing();
|
bool shallConsiderLockMissing();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UP<SSessionLock> m_pSessionLock;
|
UP<SSessionLock> m_pSessionLock;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../../devices/IPointer.hpp"
|
#include "../../devices/IPointer.hpp"
|
||||||
#include "../../devices/ITouch.hpp"
|
#include "../../devices/ITouch.hpp"
|
||||||
#include "../../devices/Tablet.hpp"
|
#include "../../devices/Tablet.hpp"
|
||||||
|
#include "../SessionLockManager.hpp"
|
||||||
|
|
||||||
class CPointerConstraint;
|
class CPointerConstraint;
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
|
@ -52,10 +53,11 @@ enum eBorderIconDirection : uint8_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STouchData {
|
struct STouchData {
|
||||||
PHLWINDOWREF touchFocusWindow;
|
WP<SSessionLockSurface> touchFocusLockSurface;
|
||||||
PHLLSREF touchFocusLS;
|
PHLWINDOWREF touchFocusWindow;
|
||||||
WP<CWLSurfaceResource> touchFocusSurface;
|
PHLLSREF touchFocusLS;
|
||||||
Vector2D touchSurfaceOrigin;
|
WP<CWLSurfaceResource> touchFocusSurface;
|
||||||
|
Vector2D touchSurfaceOrigin;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
|
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#include "InputManager.hpp"
|
#include "InputManager.hpp"
|
||||||
|
#include "../SessionLockManager.hpp"
|
||||||
|
#include "../../protocols/SessionLock.hpp"
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
#include "../../desktop/LayerSurface.hpp"
|
#include "../../desktop/LayerSurface.hpp"
|
||||||
#include "../../config/ConfigValue.hpp"
|
#include "../../config/ConfigValue.hpp"
|
||||||
|
|
@ -6,6 +8,7 @@
|
||||||
#include "../SeatManager.hpp"
|
#include "../SeatManager.hpp"
|
||||||
#include "managers/AnimationManager.hpp"
|
#include "managers/AnimationManager.hpp"
|
||||||
#include "../HookSystemManager.hpp"
|
#include "../HookSystemManager.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
|
|
||||||
void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
||||||
m_bLastInputTouch = true;
|
m_bLastInputTouch = true;
|
||||||
|
|
@ -57,13 +60,25 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
if (g_pSessionLockManager->isSessionLocked()) {
|
||||||
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
|
m_sTouchData.touchFocusLockSurface = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->ID);
|
||||||
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
if (!m_sTouchData.touchFocusLockSurface)
|
||||||
|
Debug::log(WARN, "The session is locked but can't find a lock surface");
|
||||||
|
else
|
||||||
|
m_sTouchData.touchFocusSurface = m_sTouchData.touchFocusLockSurface->surface->surface();
|
||||||
|
} else {
|
||||||
|
m_sTouchData.touchFocusLockSurface.reset();
|
||||||
|
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
||||||
|
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
|
||||||
|
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2D local;
|
Vector2D local;
|
||||||
|
|
||||||
if (!m_sTouchData.touchFocusWindow.expired()) {
|
if (m_sTouchData.touchFocusLockSurface) {
|
||||||
|
local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->vecPosition;
|
||||||
|
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
||||||
|
} else if (!m_sTouchData.touchFocusWindow.expired()) {
|
||||||
if (m_sTouchData.touchFocusWindow->m_bIsX11) {
|
if (m_sTouchData.touchFocusWindow->m_bIsX11) {
|
||||||
local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition->goal()) * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
|
local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_vRealPosition->goal()) * m_sTouchData.touchFocusWindow->m_fX11SurfaceScaledBy;
|
||||||
m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_vRealPosition->goal();
|
m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_vRealPosition->goal();
|
||||||
|
|
@ -126,7 +141,12 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) {
|
||||||
updateWorkspaceSwipe(SWIPEDISTANCE * (1 - (VERTANIMS ? e.pos.y : e.pos.x)));
|
updateWorkspaceSwipe(SWIPEDISTANCE * (1 - (VERTANIMS ? e.pos.y : e.pos.x)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (validMapped(m_sTouchData.touchFocusWindow)) {
|
if (m_sTouchData.touchFocusLockSurface) {
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLockSurface->iMonitorID);
|
||||||
|
g_pCompositor->warpCursorTo({PMONITOR->vecPosition.x + e.pos.x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e.pos.y * PMONITOR->vecSize.y}, true);
|
||||||
|
auto local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->vecPosition;
|
||||||
|
g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local);
|
||||||
|
} else if (validMapped(m_sTouchData.touchFocusWindow)) {
|
||||||
const auto PMONITOR = m_sTouchData.touchFocusWindow->m_pMonitor.lock();
|
const auto PMONITOR = m_sTouchData.touchFocusWindow->m_pMonitor.lock();
|
||||||
|
|
||||||
g_pCompositor->warpCursorTo({PMONITOR->vecPosition.x + e.pos.x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e.pos.y * PMONITOR->vecSize.y}, true);
|
g_pCompositor->warpCursorTo({PMONITOR->vecPosition.x + e.pos.x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e.pos.y * PMONITOR->vecSize.y}, true);
|
||||||
|
|
|
||||||
|
|
@ -768,7 +768,7 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, tim
|
||||||
&renderdata);
|
&renderdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, PHLMONITOR pMonitor, timespec* time) {
|
void CHyprRenderer::renderSessionLockSurface(WP<SSessionLockSurface> pSurface, PHLMONITOR pMonitor, timespec* time) {
|
||||||
CSurfacePassElement::SRenderData renderdata = {pMonitor, time, pMonitor->vecPosition, pMonitor->vecPosition};
|
CSurfacePassElement::SRenderData renderdata = {pMonitor, time, pMonitor->vecPosition, pMonitor->vecPosition};
|
||||||
|
|
||||||
renderdata.blur = false;
|
renderdata.blur = false;
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class CHyprRenderer {
|
||||||
void renderWorkspaceWindows(PHLMONITOR, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
|
void renderWorkspaceWindows(PHLMONITOR, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
|
||||||
void renderWindow(PHLWINDOW, PHLMONITOR, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool standalone = false);
|
void renderWindow(PHLWINDOW, PHLMONITOR, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool standalone = false);
|
||||||
void renderLayer(PHLLS, PHLMONITOR, timespec*, bool popups = false);
|
void renderLayer(PHLLS, PHLMONITOR, timespec*, bool popups = false);
|
||||||
void renderSessionLockSurface(SSessionLockSurface*, PHLMONITOR, timespec*);
|
void renderSessionLockSurface(WP<SSessionLockSurface>, PHLMONITOR, timespec*);
|
||||||
void renderDragIcon(PHLMONITOR, timespec*);
|
void renderDragIcon(PHLMONITOR, timespec*);
|
||||||
void renderIMEPopup(CInputPopup*, PHLMONITOR, timespec*);
|
void renderIMEPopup(CInputPopup*, PHLMONITOR, timespec*);
|
||||||
void renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry);
|
void renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue