aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-11 05:14:40 -0500
committerGitHub <noreply@github.com>2017-12-11 05:14:40 -0500
commit301850ec5d1a65aed87734583ed0868694f1913a (patch)
treeb5cc088bb7e6e97e1a9c43ee6d1a955b95bdd27d
parent8ccb5b0b6674999f83775cd583cc610a2e03fb54 (diff)
parent925497fbeaed9a2eb8420490e6cdfa4fd162e79e (diff)
Merge pull request #480 from emersion/default-cursor-image
Set default cursor image in rootston
-rw-r--r--include/rootston/config.h1
-rw-r--r--include/rootston/cursor.h2
-rw-r--r--rootston/config.c4
-rw-r--r--rootston/cursor.c3
-rw-r--r--rootston/desktop.c6
-rw-r--r--rootston/seat.c5
6 files changed, 18 insertions, 3 deletions
diff --git a/include/rootston/config.h b/include/rootston/config.h
index 233692dc..1d54314e 100644
--- a/include/rootston/config.h
+++ b/include/rootston/config.h
@@ -51,6 +51,7 @@ struct roots_cursor_config {
char *mapped_output;
struct wlr_box *mapped_box;
char *theme;
+ char *default_image;
struct wl_list link;
};
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
index 2d9a9215..de6b7b92 100644
--- a/include/rootston/cursor.h
+++ b/include/rootston/cursor.h
@@ -20,6 +20,8 @@ struct roots_cursor {
struct roots_seat *seat;
struct wlr_cursor *cursor;
+ const char *default_xcursor;
+
enum roots_cursor_mode mode;
// state from input (review if this is necessary)
diff --git a/rootston/config.c b/rootston/config.c
index 6e596852..db77506f 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -176,6 +176,9 @@ static void config_handle_cursor(struct roots_config *config,
} else if (strcmp(name, "theme") == 0) {
free(cc->theme);
cc->theme = strdup(value);
+ } else if (strcmp(name, "default-image") == 0) {
+ free(cc->default_image);
+ cc->default_image = strdup(value);
} else {
wlr_log(L_ERROR, "got unknown cursor config: %s", name);
}
@@ -454,6 +457,7 @@ void roots_config_destroy(struct roots_config *config) {
free(cc->mapped_output);
free(cc->mapped_box);
free(cc->theme);
+ free(cc->default_image);
free(cc);
}
diff --git a/rootston/cursor.c b/rootston/cursor.c
index d38e40a1..95e8ce2a 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -22,6 +22,7 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat) {
free(cursor);
return NULL;
}
+ cursor->default_xcursor = ROOTS_XCURSOR_DEFAULT;
return cursor;
}
@@ -48,7 +49,7 @@ static void roots_cursor_update_position(struct roots_cursor *cursor,
}
if (set_compositor_cursor) {
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
- ROOTS_XCURSOR_DEFAULT, cursor->cursor);
+ cursor->default_xcursor, cursor->cursor);
cursor->cursor_client = NULL;
}
if (view) {
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 244f7c94..ef459e69 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -408,10 +408,14 @@ struct roots_desktop *desktop_create(struct roots_server *server,
desktop->config = config;
const char *cursor_theme = NULL;
+ const char *cursor_default = ROOTS_XCURSOR_DEFAULT;
struct roots_cursor_config *cc =
roots_config_get_cursor(config, ROOTS_CONFIG_DEFAULT_SEAT_NAME);
if (cc != NULL) {
cursor_theme = cc->theme;
+ if (cc->default_image != NULL) {
+ cursor_default = cc->default_image;
+ }
}
desktop->xcursor_manager = wlr_xcursor_manager_create(cursor_theme,
@@ -449,7 +453,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
wlr_log(L_ERROR, "Cannot load XWayland XCursor theme");
}
struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor(
- desktop->xcursor_manager, ROOTS_XCURSOR_DEFAULT, 1);
+ desktop->xcursor_manager, cursor_default, 1);
if (xcursor != NULL) {
struct wlr_xcursor_image *image = xcursor->images[0];
wlr_xwayland_set_cursor(desktop->xwayland, image->buffer,
diff --git a/rootston/seat.c b/rootston/seat.c
index cb245ca8..8a581157 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -442,6 +442,9 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) {
roots_config_get_cursor(seat->input->config, seat->seat->name);
if (cc != NULL) {
cursor_theme = cc->theme;
+ if (cc->default_image != NULL) {
+ seat->cursor->default_xcursor = cc->default_image;
+ }
}
if (!seat->cursor->xcursor_manager) {
@@ -465,7 +468,7 @@ void roots_seat_configure_xcursor(struct roots_seat *seat) {
}
wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
- ROOTS_XCURSOR_DEFAULT, seat->cursor->cursor);
+ seat->cursor->default_xcursor, seat->cursor->cursor);
wlr_cursor_warp(seat->cursor->cursor, NULL, seat->cursor->cursor->x,
seat->cursor->cursor->y);
}