From d08ea692771caa8e385412c2f992089672773e30 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 May 2025 12:03:43 +0200 Subject: Keep keyboard led when turning on global hotkeys, move files --- include/CursorTracker/CursorTracker.hpp | 23 ++++++++++++++ include/CursorTracker/CursorTrackerWayland.hpp | 43 ++++++++++++++++++++++++++ include/CursorTracker/CursorTrackerX11.hpp | 20 ++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 include/CursorTracker/CursorTracker.hpp create mode 100644 include/CursorTracker/CursorTrackerWayland.hpp create mode 100644 include/CursorTracker/CursorTrackerX11.hpp (limited to 'include/CursorTracker') diff --git a/include/CursorTracker/CursorTracker.hpp b/include/CursorTracker/CursorTracker.hpp new file mode 100644 index 0000000..ff7374f --- /dev/null +++ b/include/CursorTracker/CursorTracker.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include + +namespace gsr { + struct CursorInfo { + mgl::vec2i position; + std::string monitor_name; + }; + + class CursorTracker { + public: + CursorTracker() = default; + CursorTracker(const CursorTracker&) = delete; + CursorTracker& operator=(const CursorTracker&) = delete; + virtual ~CursorTracker() = default; + + virtual void update() = 0; + virtual std::optional get_latest_cursor_info() = 0; + }; +} \ No newline at end of file diff --git a/include/CursorTracker/CursorTrackerWayland.hpp b/include/CursorTracker/CursorTrackerWayland.hpp new file mode 100644 index 0000000..1eeee83 --- /dev/null +++ b/include/CursorTracker/CursorTrackerWayland.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include "CursorTracker.hpp" +#include +#include + +struct wl_display; +struct wl_registry; +struct wl_output; +struct zxdg_output_manager_v1; +struct zxdg_output_v1; + +namespace gsr { + struct WaylandOutput { + uint32_t wl_name; + struct wl_output *output; + struct zxdg_output_v1 *xdg_output; + mgl::vec2i pos; + mgl::vec2i size; + int32_t transform; + std::string name; + }; + + class CursorTrackerWayland : public CursorTracker { + public: + CursorTrackerWayland(const char *card_path); + CursorTrackerWayland(const CursorTrackerWayland&) = delete; + CursorTrackerWayland& operator=(const CursorTrackerWayland&) = delete; + ~CursorTrackerWayland(); + + void update() override; + std::optional get_latest_cursor_info() override; + + std::vector monitors; + struct zxdg_output_manager_v1 *xdg_output_manager = nullptr; + private: + void set_monitor_outputs_from_xdg_output(struct wl_display *dpy); + private: + int drm_fd = -1; + mgl::vec2i latest_cursor_position; // Position of the cursor within the monitor + int latest_crtc_id = -1; + }; +} \ No newline at end of file diff --git a/include/CursorTracker/CursorTrackerX11.hpp b/include/CursorTracker/CursorTrackerX11.hpp new file mode 100644 index 0000000..66618c4 --- /dev/null +++ b/include/CursorTracker/CursorTrackerX11.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "CursorTracker.hpp" + +typedef struct _XDisplay Display; + +namespace gsr { + class CursorTrackerX11 : public CursorTracker { + public: + CursorTrackerX11(Display *dpy); + CursorTrackerX11(const CursorTrackerX11&) = delete; + CursorTrackerX11& operator=(const CursorTrackerX11&) = delete; + ~CursorTrackerX11() = default; + + void update() override {} + std::optional get_latest_cursor_info() override; + private: + Display *dpy = nullptr; + }; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2