mirror of
https://github.com/hyprwm/Hyprland
synced 2025-01-12 10:49:50 +01:00
input-capture: impl keyboard, mouse button & mouse wheel
This commit is contained in:
parent
56e6824de9
commit
62c5ee5f19
5 changed files with 68 additions and 0 deletions
|
@ -705,6 +705,7 @@ void CPointerManager::move(const Vector2D& deltaLogical) {
|
|||
|
||||
PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
warpTo(newPos);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "../../protocols/core/DataDevice.hpp"
|
||||
#include "../../protocols/core/Compositor.hpp"
|
||||
#include "../../protocols/XDGShell.hpp"
|
||||
#include "../../protocols/InputCapture.hpp"
|
||||
|
||||
#include "../../devices/Mouse.hpp"
|
||||
#include "../../devices/VirtualPointer.hpp"
|
||||
|
@ -99,6 +100,7 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
|
|||
|
||||
g_pPointerManager->move(DELTA);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
mouseMoveUnified(e.timeMs, false, e.mouse);
|
||||
|
||||
m_tmrLastCursorMovement.reset();
|
||||
|
@ -545,6 +547,9 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
|||
if (e.mouse)
|
||||
recheckMouseWarpOnMouseInput();
|
||||
|
||||
PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
m_tmrLastCursorMovement.reset();
|
||||
|
||||
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
|
@ -782,6 +787,13 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
|||
if (e.mouse)
|
||||
recheckMouseWarpOnMouseInput();
|
||||
|
||||
PROTO::inputCapture->sendAxis((hyprlandInputCaptureManagerV1Axis)e.axis, e.delta);
|
||||
if (e.source == 0)
|
||||
PROTO::inputCapture->sendAxisValue120((hyprlandInputCaptureManagerV1Axis)e.axis, e.delta);
|
||||
else if (e.delta == 0)
|
||||
PROTO::inputCapture->sendAxisStop((hyprlandInputCaptureManagerV1Axis)e.axis);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
||||
|
||||
if (!passEvent)
|
||||
|
@ -862,6 +874,13 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
|||
g_pSeatManager->sendPointerAxis(e.timeMs, e.axis, delta, deltaDiscrete, value120, e.source, WL_POINTER_AXIS_RELATIVE_DIRECTION_IDENTICAL);
|
||||
}
|
||||
|
||||
void CInputManager::onMouseFrame() {
|
||||
PROTO::inputCapture->sendFrame();
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
g_pSeatManager->sendPointerFrame();
|
||||
}
|
||||
|
||||
Vector2D CInputManager::getMouseCoordsInternal() {
|
||||
return g_pPointerManager->position();
|
||||
}
|
||||
|
@ -1325,6 +1344,9 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
|
|||
|
||||
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
|
||||
|
||||
//TODO: Inhibit inputs
|
||||
PROTO::inputCapture->sendKey(e.keycode, (hyprlandInputCaptureManagerV1KeyState)e.state);
|
||||
|
||||
if (passEvent) {
|
||||
const auto IME = m_sIMERelay.m_pIME.lock();
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ class CInputManager {
|
|||
void onMouseWarp(IPointer::SMotionAbsoluteEvent);
|
||||
void onMouseButton(IPointer::SButtonEvent);
|
||||
void onMouseWheel(IPointer::SAxisEvent);
|
||||
void onMouseFrame();
|
||||
void onKeyboardKey(std::any, SP<IKeyboard>);
|
||||
void onKeyboardMod(SP<IKeyboard>);
|
||||
|
||||
|
|
|
@ -31,3 +31,39 @@ void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition,
|
|||
wl_fixed_from_double(delta.y));
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendKey(uint32_t keyCode, hyprlandInputCaptureManagerV1KeyState state) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendKey(keyCode, state);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendButton(uint32_t button, hyprlandInputCaptureManagerV1ButtonState state) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendButton(button, state);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendAxis(hyprlandInputCaptureManagerV1Axis axis, double value) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendAxis(axis, value);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendAxisValue120(hyprlandInputCaptureManagerV1Axis axis, int32_t value120) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendAxisValue120(axis, value120);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendAxisStop(hyprlandInputCaptureManagerV1Axis axis) {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendAxisStop(axis);
|
||||
}
|
||||
}
|
||||
|
||||
void CInputCaptureProtocol::sendFrame() {
|
||||
for (const UP<CHyprlandInputCaptureManagerV1>& manager : m_vManagers) {
|
||||
manager->sendFrame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,20 @@ class CInputCaptureProtocol : public IWaylandProtocol {
|
|||
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();
|
||||
|
||||
private:
|
||||
void onManagerResourceDestroy(wl_resource* res);
|
||||
void onCapture(CHyprlandInputCaptureManagerV1* pMgr);
|
||||
void onRelease(CHyprlandInputCaptureManagerV1* pMgr);
|
||||
|
||||
//
|
||||
std::vector<UP<CHyprlandInputCaptureManagerV1>> m_vManagers;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue