mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 14:25:59 +01:00
input-capture: impl keyboard, mouse button & mouse wheel
This commit is contained in:
parent
057f00bf8f
commit
9a22c90741
6 changed files with 69 additions and 1 deletions
|
@ -677,6 +677,7 @@ void CPointerManager::move(const Vector2D& deltaLogical) {
|
||||||
|
|
||||||
PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical);
|
PROTO::inputCapture->sendAbsoluteMotion(newPos, deltaLogical);
|
||||||
|
|
||||||
|
//TODO: Inhibit inputs
|
||||||
warpTo(newPos);
|
warpTo(newPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "../../protocols/core/DataDevice.hpp"
|
#include "../../protocols/core/DataDevice.hpp"
|
||||||
#include "../../protocols/core/Compositor.hpp"
|
#include "../../protocols/core/Compositor.hpp"
|
||||||
#include "../../protocols/XDGShell.hpp"
|
#include "../../protocols/XDGShell.hpp"
|
||||||
|
#include "../../protocols/InputCapture.hpp"
|
||||||
|
|
||||||
#include "../../devices/Mouse.hpp"
|
#include "../../devices/Mouse.hpp"
|
||||||
#include "../../devices/VirtualPointer.hpp"
|
#include "../../devices/VirtualPointer.hpp"
|
||||||
|
@ -96,6 +97,7 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
|
||||||
|
|
||||||
g_pPointerManager->move(DELTA);
|
g_pPointerManager->move(DELTA);
|
||||||
|
|
||||||
|
//TODO: Inhibit inputs
|
||||||
mouseMoveUnified(e.timeMs);
|
mouseMoveUnified(e.timeMs);
|
||||||
|
|
||||||
m_tmrLastCursorMovement.reset();
|
m_tmrLastCursorMovement.reset();
|
||||||
|
@ -531,6 +533,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
|
||||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
|
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
|
||||||
|
|
||||||
|
PROTO::inputCapture->sendButton(e.button, (hyprlandInputCaptureManagerV1ButtonState)e.state);
|
||||||
|
|
||||||
|
//TODO: Inhibit inputs
|
||||||
m_tmrLastCursorMovement.reset();
|
m_tmrLastCursorMovement.reset();
|
||||||
|
|
||||||
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
|
@ -763,6 +768,13 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
|
||||||
const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}};
|
const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}};
|
||||||
EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP);
|
EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP);
|
||||||
|
|
||||||
|
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);
|
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
||||||
|
|
||||||
if (!passEvent)
|
if (!passEvent)
|
||||||
|
@ -833,6 +845,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);
|
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() {
|
Vector2D CInputManager::getMouseCoordsInternal() {
|
||||||
return g_pPointerManager->position();
|
return g_pPointerManager->position();
|
||||||
}
|
}
|
||||||
|
@ -1296,6 +1315,9 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> 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);
|
||||||
|
|
||||||
if (passEvent) {
|
if (passEvent) {
|
||||||
const auto IME = m_sIMERelay.m_pIME.lock();
|
const auto IME = m_sIMERelay.m_pIME.lock();
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ class CInputManager {
|
||||||
void onMouseWarp(IPointer::SMotionAbsoluteEvent);
|
void onMouseWarp(IPointer::SMotionAbsoluteEvent);
|
||||||
void onMouseButton(IPointer::SButtonEvent);
|
void onMouseButton(IPointer::SButtonEvent);
|
||||||
void onMouseWheel(IPointer::SAxisEvent);
|
void onMouseWheel(IPointer::SAxisEvent);
|
||||||
|
void onMouseFrame();
|
||||||
void onKeyboardKey(std::any, SP<IKeyboard>);
|
void onKeyboardKey(std::any, SP<IKeyboard>);
|
||||||
void onKeyboardMod(SP<IKeyboard>);
|
void onKeyboardMod(SP<IKeyboard>);
|
||||||
|
|
||||||
|
|
|
@ -31,3 +31,39 @@ void CInputCaptureProtocol::sendAbsoluteMotion(const Vector2D& absolutePosition,
|
||||||
wl_fixed_from_double(delta.y));
|
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);
|
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);
|
||||||
void sendAbsoluteMotion(const Vector2D& absolutePosition, const Vector2D& delta);
|
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:
|
private:
|
||||||
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);
|
||||||
|
|
||||||
|
//
|
||||||
std::vector<UP<CHyprlandInputCaptureManagerV1>> m_vManagers;
|
std::vector<UP<CHyprlandInputCaptureManagerV1>> m_vManagers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1c4de2b22b9a7100ca664e46e37e29b0b724ce97
|
Subproject commit 53a994b2efbcc19862125fc9a8d5a752a24a0f20
|
Loading…
Reference in a new issue