aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/rootston/cursor.h2
-rw-r--r--include/rootston/desktop.h2
-rw-r--r--include/rootston/xcursor.h13
-rw-r--r--include/wlr/types/wlr_cursor.h16
-rw-r--r--include/wlr/types/wlr_xcursor_manager.h53
-rw-r--r--include/wlr/xcursor.h2
6 files changed, 77 insertions, 11 deletions
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
index c0dbc010..f49b6439 100644
--- a/include/rootston/cursor.h
+++ b/include/rootston/cursor.h
@@ -30,7 +30,7 @@ struct roots_cursor {
enum roots_cursor_mode mode;
// state from input (review if this is necessary)
- struct wlr_xcursor_theme *xcursor_theme;
+ struct wlr_xcursor_manager *xcursor_manager;
struct wlr_seat *wl_seat;
struct wl_client *cursor_client;
int offs_x, offs_y;
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index 376412fb..b809db43 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -7,6 +7,7 @@
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
+#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_screenshooter.h>
#include <wlr/types/wlr_list.h>
@@ -31,6 +32,7 @@ struct roots_desktop {
struct roots_config *config;
struct wlr_output_layout *layout;
+ struct wlr_xcursor_manager *xcursor_manager;
struct wlr_compositor *compositor;
struct wlr_wl_shell *wl_shell;
diff --git a/include/rootston/xcursor.h b/include/rootston/xcursor.h
index c96e50ef..bc00f79c 100644
--- a/include/rootston/xcursor.h
+++ b/include/rootston/xcursor.h
@@ -1,15 +1,14 @@
#ifndef _ROOTSTON_XCURSOR_H
#define _ROOTSTON_XCURSOR_H
-#include <wlr/xcursor.h>
+#include <stdint.h>
-struct wlr_xcursor *get_default_xcursor(struct wlr_xcursor_theme *theme);
+#define ROOTS_XCURSOR_SIZE 16
-struct wlr_xcursor *get_move_xcursor(struct wlr_xcursor_theme *theme);
+#define ROOTS_XCURSOR_DEFAULT "left_ptr"
+#define ROOTS_XCURSOR_MOVE "grabbing"
+#define ROOTS_XCURSOR_ROTATE "grabbing"
-struct wlr_xcursor *get_resize_xcursor(struct wlr_xcursor_theme *theme,
- uint32_t edges);
-
-struct wlr_xcursor *get_rotate_xcursor(struct wlr_xcursor_theme *theme);
+const char *roots_xcursor_get_resize_name(uint32_t edges);
#endif
diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h
index 1aac2b94..0db32eb2 100644
--- a/include/wlr/types/wlr_cursor.h
+++ b/include/wlr/types/wlr_cursor.h
@@ -6,7 +6,6 @@
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_box.h>
-#include <wlr/xcursor.h>
struct wlr_cursor_state;
@@ -60,9 +59,22 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
void wlr_cursor_move(struct wlr_cursor *cur, struct wlr_input_device *dev,
double delta_x, double delta_y);
+/**
+ * Set the cursor image. stride is given in bytes. If pixels is NULL, hides the
+ * cursor.
+ *
+ * If scale isn't zero, the image is only set on outputs having the provided
+ * scale.
+ */
void wlr_cursor_set_image(struct wlr_cursor *cur, const uint8_t *pixels,
int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x,
- int32_t hotspot_y);
+ int32_t hotspot_y, uint32_t scale);
+
+/**
+ * Set the cursor surface. The surface can be committed to update the cursor
+ * image. The surface position is substracted from the hotspot. A NULL surface
+ * commit hides the cursor.
+ */
void wlr_cursor_set_surface(struct wlr_cursor *cur, struct wlr_surface *surface,
int32_t hotspot_x, int32_t hotspot_y);
diff --git a/include/wlr/types/wlr_xcursor_manager.h b/include/wlr/types/wlr_xcursor_manager.h
new file mode 100644
index 00000000..c78a6e8d
--- /dev/null
+++ b/include/wlr/types/wlr_xcursor_manager.h
@@ -0,0 +1,53 @@
+#ifndef WLR_TYPES_WLR_XCURSOR_MANAGER_H
+#define WLR_TYPES_WLR_XCURSOR_MANAGER_H
+
+#include <wayland-server.h>
+#include <wlr/types/wlr_cursor.h>
+#include <wlr/xcursor.h>
+
+/**
+ * A scaled XCursor theme.
+ */
+struct wlr_xcursor_manager_theme {
+ uint32_t scale;
+ struct wlr_xcursor_theme *theme;
+ struct wl_list link;
+};
+
+/**
+ * Manage multiple XCursor themes with different scales and set `wlr_cursor`
+ * images.
+ *
+ * This manager can be used to display cursor images on multiple outputs having
+ * different scale factors.
+ */
+struct wlr_xcursor_manager {
+ char *name;
+ uint32_t size;
+ struct wl_list scaled_themes; // wlr_xcursor_manager_theme::link
+};
+
+/**
+ * Create a new XCursor manager. After initialization, scaled themes need to be
+ * loaded with `wlr_xcursor_manager_load`. `size` is the unscaled cursor theme
+ * size.
+ */
+struct wlr_xcursor_manager *wlr_xcursor_manager_create(const char *name,
+ uint32_t size);
+
+void wlr_xcursor_manager_destroy(struct wlr_xcursor_manager *manager);
+
+int wlr_xcursor_manager_load(struct wlr_xcursor_manager *manager,
+ uint32_t scale);
+
+struct wlr_xcursor *wlr_xcursor_manager_get_xcursor(
+ struct wlr_xcursor_manager *manager, const char *name, uint32_t scale);
+
+/**
+ * Set a `wlr_cursor` image. The manager uses all currently loaded scaled
+ * themes.
+ */
+void wlr_xcursor_manager_set_cursor_image(struct wlr_xcursor_manager *manager,
+ const char *name, struct wlr_cursor *cursor);
+
+#endif
diff --git a/include/wlr/xcursor.h b/include/wlr/xcursor.h
index c12d5405..b6362b06 100644
--- a/include/wlr/xcursor.h
+++ b/include/wlr/xcursor.h
@@ -61,7 +61,7 @@ struct wlr_xcursor_theme *wlr_xcursor_theme_load(const char *name, int size);
void wlr_xcursor_theme_destroy(struct wlr_xcursor_theme *theme);
struct wlr_xcursor *wlr_xcursor_theme_get_cursor(
- struct wlr_xcursor_theme *theme, const char *name);
+ struct wlr_xcursor_theme *theme, const char *name);
int wlr_xcursor_frame(struct wlr_xcursor *cursor, uint32_t time);