diff options
author | emersion <contact@emersion.fr> | 2017-10-08 23:39:38 +0200 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-10-08 23:39:38 +0200 |
commit | c7a4346bfc5db9e0af070271ff12dad25f6bddd3 (patch) | |
tree | 3e5c95d278e7a9e32f8efd8506b7aec2e27cf33c | |
parent | bceaee6eb78f9c1f5693703adc94b863940c3aa4 (diff) |
Hide cursor when surface == NULL
-rw-r--r-- | types/wlr_output.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/types/wlr_output.c b/types/wlr_output.c index 2b78f728..fbecbb2e 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -135,8 +135,6 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf, output->cursor.is_sw = true; output->cursor.width = width; output->cursor.height = height; - output->cursor.hotspot_x = hotspot_x; - output->cursor.hotspot_y = hotspot_y; if (!output->cursor.renderer) { /* NULL egl is okay given that we are only using pixel buffers */ @@ -167,6 +165,9 @@ bool wlr_output_set_cursor(struct wlr_output *output, output->cursor.surface = NULL; } + output->cursor.hotspot_x = hotspot_x; + output->cursor.hotspot_y = hotspot_y; + return set_cursor(output, buf, stride, width, height, hotspot_x, hotspot_y); } @@ -199,25 +200,22 @@ static void handle_cursor_surface_destroy(struct wl_listener *listener, void *data) { struct wlr_output *output = wl_container_of(listener, output, cursor.surface_destroy); - struct wlr_surface *surface = data; - if (output->cursor.surface == surface) { - wl_list_remove(&output->cursor.surface_commit.link); - wl_list_remove(&output->cursor.surface_destroy.link); - output->cursor.surface = NULL; - } + wl_list_remove(&output->cursor.surface_commit.link); + wl_list_remove(&output->cursor.surface_destroy.link); + output->cursor.surface = NULL; } void wlr_output_set_cursor_surface(struct wlr_output *output, struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y) { - if (strcmp(surface->role, "cursor") != 0) { + if (surface && strcmp(surface->role, "cursor") != 0) { return; } output->cursor.hotspot_x = hotspot_x; output->cursor.hotspot_y = hotspot_y; - if (output->cursor.surface == surface) { + if (surface && output->cursor.surface == surface) { return; } output->cursor.surface = surface; @@ -231,6 +229,8 @@ void wlr_output_set_cursor_surface(struct wlr_output *output, if (surface != NULL) { wl_signal_add(&surface->events.commit, &output->cursor.surface_commit); wl_signal_add(&surface->events.destroy, &output->cursor.surface_destroy); + } else { + set_cursor(output, NULL, 0, 0, 0, hotspot_x, hotspot_y); } } |