From ed411f53bdcf8d455f9e6ca769693aa84dc8372f Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 5 May 2024 22:18:10 +0100 Subject: cursor: move to a hyprland impl This moves wlr_cursor to a completely new impl mostly under CPointerManager Also adds beginSimple to OpenGL for simple render passes (e.g. cursor) --- src/devices/IHID.cpp | 5 +++++ src/devices/IHID.hpp | 11 +++++++++++ src/devices/IKeyboard.cpp | 4 ++++ src/devices/IKeyboard.hpp | 1 + src/devices/IPointer.cpp | 4 ++++ src/devices/IPointer.hpp | 2 ++ src/devices/ITouch.cpp | 6 +++++- src/devices/ITouch.hpp | 8 +++++--- src/devices/Mouse.cpp | 5 +++++ src/devices/TouchDevice.cpp | 1 + src/devices/VirtualPointer.cpp | 5 +++++ 11 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/devices/IHID.cpp (limited to 'src/devices') diff --git a/src/devices/IHID.cpp b/src/devices/IHID.cpp new file mode 100644 index 00000000..2b7466dc --- /dev/null +++ b/src/devices/IHID.cpp @@ -0,0 +1,5 @@ +#include "IHID.hpp" + +eHIDType IHID::getType() { + return HID_TYPE_UNKNOWN; +} diff --git a/src/devices/IHID.hpp b/src/devices/IHID.hpp index c2b397c7..2830864b 100644 --- a/src/devices/IHID.hpp +++ b/src/devices/IHID.hpp @@ -10,13 +10,24 @@ enum eHIDCapabilityType : uint32_t { HID_INPUT_CAPABILITY_TOUCH = (1 << 2), }; +enum eHIDType { + HID_TYPE_UNKNOWN = 0, + HID_TYPE_POINTER, + HID_TYPE_KEYBOARD, + HID_TYPE_TOUCH, + HID_TYPE_TABLET, +}; + /* Base class for a HID device. This could be a keyboard, a mouse, or a touchscreen. */ class IHID { public: + virtual ~IHID() {} + virtual uint32_t getCapabilities() = 0; + virtual eHIDType getType(); struct { CSignal destroy; diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index 61c78f5b..3bd42eac 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -7,6 +7,10 @@ uint32_t IKeyboard::getCapabilities() { return HID_INPUT_CAPABILITY_KEYBOARD; } +eHIDType IKeyboard::getType() { + return HID_TYPE_KEYBOARD; +} + IKeyboard::~IKeyboard() { events.destroy.emit(); diff --git a/src/devices/IKeyboard.hpp b/src/devices/IKeyboard.hpp index 35ccd8cb..d90550da 100644 --- a/src/devices/IKeyboard.hpp +++ b/src/devices/IKeyboard.hpp @@ -13,6 +13,7 @@ class IKeyboard : public IHID { public: virtual ~IKeyboard(); virtual uint32_t getCapabilities(); + virtual eHIDType getType(); virtual bool isVirtual() = 0; virtual wlr_keyboard* wlr() = 0; diff --git a/src/devices/IPointer.cpp b/src/devices/IPointer.cpp index 9eb507b2..c2ac78c5 100644 --- a/src/devices/IPointer.cpp +++ b/src/devices/IPointer.cpp @@ -3,3 +3,7 @@ uint32_t IPointer::getCapabilities() { return HID_INPUT_CAPABILITY_POINTER; } + +eHIDType IPointer::getType() { + return HID_TYPE_POINTER; +} diff --git a/src/devices/IPointer.hpp b/src/devices/IPointer.hpp index eda7da2c..e2347c95 100644 --- a/src/devices/IPointer.hpp +++ b/src/devices/IPointer.hpp @@ -13,6 +13,7 @@ struct wlr_pointer; class IPointer : public IHID { public: virtual uint32_t getCapabilities(); + virtual eHIDType getType(); virtual bool isVirtual() = 0; virtual wlr_pointer* wlr() = 0; @@ -24,6 +25,7 @@ class IPointer : public IHID { struct SMotionAbsoluteEvent { uint32_t timeMs = 0; Vector2D absolute; // 0.0 - 1.0 + SP device; }; struct SButtonEvent { diff --git a/src/devices/ITouch.cpp b/src/devices/ITouch.cpp index 3fa347fd..72a9ade6 100644 --- a/src/devices/ITouch.cpp +++ b/src/devices/ITouch.cpp @@ -2,4 +2,8 @@ uint32_t ITouch::getCapabilities() { return HID_INPUT_CAPABILITY_TOUCH; -} \ No newline at end of file +} + +eHIDType ITouch::getType() { + return HID_TYPE_TOUCH; +} diff --git a/src/devices/ITouch.hpp b/src/devices/ITouch.hpp index 7a109bec..5929be02 100644 --- a/src/devices/ITouch.hpp +++ b/src/devices/ITouch.hpp @@ -10,13 +10,15 @@ struct wlr_touch; class ITouch : public IHID { public: virtual uint32_t getCapabilities(); + virtual eHIDType getType(); virtual bool isVirtual() = 0; virtual wlr_touch* wlr() = 0; struct SDownEvent { - uint32_t timeMs = 0; - int32_t touchID = 0; - Vector2D pos; + uint32_t timeMs = 0; + int32_t touchID = 0; + Vector2D pos; + SP device; }; struct SUpEvent { diff --git a/src/devices/Mouse.cpp b/src/devices/Mouse.cpp index e2a6f4ed..b860298c 100644 --- a/src/devices/Mouse.cpp +++ b/src/devices/Mouse.cpp @@ -36,6 +36,7 @@ CMouse::CMouse(wlr_pointer* mouse_) : mouse(mouse_) { pointerEvents.motionAbsolute.emit(SMotionAbsoluteEvent{ .timeMs = E->time_msec, .absolute = {E->x, E->y}, + .device = self.lock(), }); }, this, "CMouse"); @@ -62,6 +63,10 @@ CMouse::CMouse(wlr_pointer* mouse_) : mouse(mouse_) { }); }, this, "CMouse"); + hyprListener_frame.initCallback(&mouse->events.frame, [this] (void* owner, void* data) { + pointerEvents.frame.emit(); + }, this, "CMouse"); + hyprListener_swipeBegin.initCallback(&mouse->events.swipe_begin, [this] (void* owner, void* data) { auto E = (wlr_pointer_swipe_begin_event*)data; diff --git a/src/devices/TouchDevice.cpp b/src/devices/TouchDevice.cpp index e8e52dc2..64c521a2 100644 --- a/src/devices/TouchDevice.cpp +++ b/src/devices/TouchDevice.cpp @@ -27,6 +27,7 @@ CTouchDevice::CTouchDevice(wlr_touch* touch_) : touch(touch_) { .timeMs = E->time_msec, .touchID = E->touch_id, .pos = {E->x, E->y}, + .device = self.lock(), }); }, this, "CTouchDevice"); diff --git a/src/devices/VirtualPointer.cpp b/src/devices/VirtualPointer.cpp index 4ebf8865..c8ee3332 100644 --- a/src/devices/VirtualPointer.cpp +++ b/src/devices/VirtualPointer.cpp @@ -37,6 +37,7 @@ CVirtualPointer::CVirtualPointer(SP resource) : point pointerEvents.motionAbsolute.emit(SMotionAbsoluteEvent{ .timeMs = E->time_msec, .absolute = {E->x, E->y}, + .device = self.lock(), }); }, this, "CVirtualPointer"); @@ -63,6 +64,10 @@ CVirtualPointer::CVirtualPointer(SP resource) : point }); }, this, "CVirtualPointer"); + hyprListener_frame.initCallback(&mouse->events.frame, [this] (void* owner, void* data) { + pointerEvents.frame.emit(); + }, this, "CVirtualPointer"); + hyprListener_swipeBegin.initCallback(&mouse->events.swipe_begin, [this] (void* owner, void* data) { auto E = (wlr_pointer_swipe_begin_event*)data; -- cgit v1.2.3