mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 16:25:58 +01:00
input-capture: inhibit inputs
This commit is contained in:
parent
9a22c90741
commit
98ecfe583e
4 changed files with 40 additions and 18 deletions
|
@ -677,7 +677,9 @@ void CPointerManager::move(const Vector2D& deltaLogical) {
|
||||||
|
|
||||||
PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical);
|
PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical);
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
if (PROTO::inputCapture->isCaptured())
|
||||||
|
return;
|
||||||
|
|
||||||
warpTo(newPos);
|
warpTo(newPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,9 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
|
||||||
|
|
||||||
g_pPointerManager->move(DELTA);
|
g_pPointerManager->move(DELTA);
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
if (PROTO::inputCapture->isCaptured())
|
||||||
|
return;
|
||||||
|
|
||||||
mouseMoveUnified(e.timeMs);
|
mouseMoveUnified(e.timeMs);
|
||||||
|
|
||||||
m_tmrLastCursorMovement.reset();
|
m_tmrLastCursorMovement.reset();
|
||||||
|
@ -535,7 +537,9 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
||||||
|
|
||||||
PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state);
|
PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state);
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
if (PROTO::inputCapture->isCaptured())
|
||||||
|
return;
|
||||||
|
|
||||||
m_tmrLastCursorMovement.reset();
|
m_tmrLastCursorMovement.reset();
|
||||||
|
|
||||||
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
|
@ -774,8 +778,7 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
||||||
else if (e.delta == 0)
|
else if (e.delta == 0)
|
||||||
PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis);
|
PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis);
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
bool passEvent = !PROTO::inputCapture->isCaptured() && g_pKeybindManager->onAxisEvent(e);
|
||||||
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
|
||||||
|
|
||||||
if (!passEvent)
|
if (!passEvent)
|
||||||
return;
|
return;
|
||||||
|
@ -848,7 +851,9 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
||||||
void CInputManager::onMouseFrame() {
|
void CInputManager::onMouseFrame() {
|
||||||
PROTO::inputCapture->sendFrame();
|
PROTO::inputCapture->sendFrame();
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
if (PROTO::inputCapture->isCaptured())
|
||||||
|
return;
|
||||||
|
|
||||||
g_pSeatManager->sendPointerFrame();
|
g_pSeatManager->sendPointerFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,11 +1316,10 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
||||||
const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
|
const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
|
||||||
EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);
|
EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);
|
||||||
|
|
||||||
bool passEvent = DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard);
|
bool passEvent = !PROTO::inputCapture->isCaptured() && (DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard));
|
||||||
|
|
||||||
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
||||||
|
|
||||||
//TODO: Inhibit inputs
|
|
||||||
PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state);
|
PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state);
|
||||||
|
|
||||||
if (passEvent) {
|
if (passEvent) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <wayland-util.h>
|
#include <wayland-util.h>
|
||||||
|
|
||||||
CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
CInputCaptureProtocol::CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||||
;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
void CInputCaptureProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||||
|
@ -21,9 +21,19 @@ void CInputCaptureProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||||
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
std::erase_if(m_vManagers, [&](const auto& other) { return other->resource() == res; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputCaptureProtocol::onCapture(CHyprlandInputCaptureManagerV1* pMgr) {}
|
void CInputCaptureProtocol::onCapture(CHyprlandInputCaptureManagerV1* pMgr) {
|
||||||
|
Debug::log(LOG, "[input-capture] Input captured");
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
|
|
||||||
void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) {}
|
void CInputCaptureProtocol::onRelease(CHyprlandInputCaptureManagerV1* pMgr) {
|
||||||
|
Debug::log(LOG, "[input-capture] Input released");
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CInputCaptureProtocol::isCaptured() {
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta) {
|
void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta) {
|
||||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||||
|
|
|
@ -8,6 +8,10 @@ class CInputCaptureProtocol : public IWaylandProtocol {
|
||||||
public:
|
public:
|
||||||
CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
CInputCaptureProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
||||||
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
||||||
|
|
||||||
|
bool isCaptured();
|
||||||
|
|
||||||
|
//
|
||||||
void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
||||||
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state);
|
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state);
|
||||||
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state);
|
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state);
|
||||||
|
@ -18,6 +22,8 @@ class CInputCaptureProtocol : public IWaylandProtocol {
|
||||||
void sendFrame();
|
void sendFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool active;
|
||||||
|
|
||||||
void onManagerResourceDestroy(wl_resource* res);
|
void onManagerResourceDestroy(wl_resource* res);
|
||||||
void onCapture(CHyprlandInputCaptureManagerV1* pMgr);
|
void onCapture(CHyprlandInputCaptureManagerV1* pMgr);
|
||||||
void onRelease(CHyprlandInputCaptureManagerV1* pMgr);
|
void onRelease(CHyprlandInputCaptureManagerV1* pMgr);
|
||||||
|
|
Loading…
Reference in a new issue