aboutsummaryrefslogtreecommitdiff
path: root/rootston/xcursor.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-10-27 13:42:53 -0400
committerGitHub <noreply@github.com>2017-10-27 13:42:53 -0400
commit9f1ed70b81adc0680ba796a5545709036bc54408 (patch)
treeda33a734e90c78467ed838506f86d392305d6500 /rootston/xcursor.c
parent0572abbb252edfc27232c08893b7440561ca171d (diff)
parentec5beeb8b8eec615f74f640f84e8fa8e451ba3bb (diff)
Merge pull request #344 from emersion/compositor-action-cursors
Set compositor cursor for move, resize and rotate
Diffstat (limited to 'rootston/xcursor.c')
-rw-r--r--rootston/xcursor.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/rootston/xcursor.c b/rootston/xcursor.c
new file mode 100644
index 00000000..43cbfc51
--- /dev/null
+++ b/rootston/xcursor.c
@@ -0,0 +1,42 @@
+#include <wlr/types/wlr_cursor.h>
+#include "rootston/input.h"
+
+struct wlr_xcursor *get_default_xcursor(struct wlr_xcursor_theme *theme) {
+ return wlr_xcursor_theme_get_cursor(theme, "left_ptr");
+}
+
+struct wlr_xcursor *get_move_xcursor(struct wlr_xcursor_theme *theme) {
+ return wlr_xcursor_theme_get_cursor(theme, "grabbing");
+}
+
+static const char *get_resize_xcursor_name(uint32_t edges) {
+ if (edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) {
+ if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
+ return "ne-resize";
+ } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) {
+ return "nw-resize";
+ }
+ return "n-resize";
+ } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) {
+ if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
+ return "se-resize";
+ } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) {
+ return "sw-resize";
+ }
+ return "s-resize";
+ } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
+ return "e-resize";
+ } else if (edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) {
+ return "w-resize";
+ }
+ return "se-resize"; // fallback
+}
+
+struct wlr_xcursor *get_resize_xcursor(struct wlr_xcursor_theme *theme,
+ uint32_t edges) {
+ return wlr_xcursor_theme_get_cursor(theme, get_resize_xcursor_name(edges));
+}
+
+struct wlr_xcursor *get_rotate_xcursor(struct wlr_xcursor_theme *theme) {
+ return wlr_xcursor_theme_get_cursor(theme, "grabbing");
+}