mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 12:25:59 +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);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
if (PROTO::inputCapture->isCaptured())
|
||||
return;
|
||||
|
||||
warpTo(newPos);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,9 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
|
|||
|
||||
g_pPointerManager->move(DELTA);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
if (PROTO::inputCapture->isCaptured())
|
||||
return;
|
||||
|
||||
mouseMoveUnified(e.timeMs);
|
||||
|
||||
m_tmrLastCursorMovement.reset();
|
||||
|
@ -535,7 +537,9 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
|||
|
||||
PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
if (PROTO::inputCapture->isCaptured())
|
||||
return;
|
||||
|
||||
m_tmrLastCursorMovement.reset();
|
||||
|
||||
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
|
@ -774,8 +778,7 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
|||
else if (e.delta == 0)
|
||||
PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
||||
bool passEvent = !PROTO::inputCapture->isCaptured() && g_pKeybindManager->onAxisEvent(e);
|
||||
|
||||
if (!passEvent)
|
||||
return;
|
||||
|
@ -848,7 +851,9 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
|||
void CInputManager::onMouseFrame() {
|
||||
PROTO::inputCapture->sendFrame();
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
if (PROTO::inputCapture->isCaptured())
|
||||
return;
|
||||
|
||||
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}};
|
||||
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);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state);
|
||||
|
||||
if (passEvent) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <wayland-util.h>
|
||||
|
||||
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) {
|
||||
|
@ -21,9 +21,19 @@ void CInputCaptureProtocol::onManagerResourceDestroy(wl_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) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
|
|
|
@ -8,16 +8,22 @@ class CInputCaptureProtocol : public IWaylandProtocol {
|
|||
public:
|
||||
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);
|
||||
void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
||||
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state);
|
||||
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state);
|
||||
void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value);
|
||||
void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120);
|
||||
void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis);
|
||||
|
||||
void sendFrame();
|
||||
bool isCaptured();
|
||||
|
||||
//
|
||||
void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
||||
void sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state);
|
||||
void sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state);
|
||||
void sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value);
|
||||
void sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120);
|
||||
void sendAxisStop(hyprlandInputCaptureManagerV1Axis axis);
|
||||
|
||||
void sendFrame();
|
||||
|
||||
private:
|
||||
bool active;
|
||||
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
void onCapture(CHyprlandInputCaptureManagerV1* pMgr);
|
||||
void onRelease(CHyprlandInputCaptureManagerV1* pMgr);
|
||||
|
|
Loading…
Reference in a new issue