aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CursorTracker.hpp23
-rw-r--r--include/CursorTrackerWayland.hpp43
-rw-r--r--include/CursorTrackerX11.hpp20
-rw-r--r--include/Overlay.hpp5
-rw-r--r--include/WindowUtils.hpp1
5 files changed, 92 insertions, 0 deletions
diff --git a/include/CursorTracker.hpp b/include/CursorTracker.hpp
new file mode 100644
index 0000000..ff7374f
--- /dev/null
+++ b/include/CursorTracker.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <optional>
+#include <string>
+#include <mglpp/system/vec.hpp>
+
+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<CursorInfo> get_latest_cursor_info() = 0;
+ };
+} \ No newline at end of file
diff --git a/include/CursorTrackerWayland.hpp b/include/CursorTrackerWayland.hpp
new file mode 100644
index 0000000..1eeee83
--- /dev/null
+++ b/include/CursorTrackerWayland.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "CursorTracker.hpp"
+#include <stdint.h>
+#include <vector>
+
+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<CursorInfo> get_latest_cursor_info() override;
+
+ std::vector<WaylandOutput> 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/CursorTrackerX11.hpp b/include/CursorTrackerX11.hpp
new file mode 100644
index 0000000..66618c4
--- /dev/null
+++ b/include/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<CursorInfo> get_latest_cursor_info() override;
+ private:
+ Display *dpy = nullptr;
+ };
+} \ No newline at end of file
diff --git a/include/Overlay.hpp b/include/Overlay.hpp
index d7b8af1..4a9ef98 100644
--- a/include/Overlay.hpp
+++ b/include/Overlay.hpp
@@ -9,6 +9,7 @@
#include "GlobalHotkeysJoystick.hpp"
#include "AudioPlayer.hpp"
#include "RegionSelector.hpp"
+#include "CursorTracker.hpp"
#include <mglpp/window/Window.hpp>
#include <mglpp/window/Event.hpp>
@@ -115,6 +116,8 @@ namespace gsr {
void on_press_take_screenshot(bool finished_region_selection, bool force_region_capture);
bool update_compositor_texture(const Monitor &monitor);
+ std::string get_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options);
+
void force_window_on_top();
private:
using KeyBindingCallback = std::function<void()>;
@@ -205,5 +208,7 @@ namespace gsr {
RegionSelector region_selector;
bool start_region_capture = false;
std::function<void()> on_region_selected;
+
+ std::unique_ptr<CursorTracker> cursor_tracker;
};
} \ No newline at end of file
diff --git a/include/WindowUtils.hpp b/include/WindowUtils.hpp
index e31eeb2..72d2179 100644
--- a/include/WindowUtils.hpp
+++ b/include/WindowUtils.hpp
@@ -15,6 +15,7 @@ namespace gsr {
struct Monitor {
mgl::vec2i position;
mgl::vec2i size;
+ std::string name;
};
std::optional<std::string> get_window_title(Display *dpy, Window window);