aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-11-02 10:18:31 -0400
committerGitHub <noreply@github.com>2017-11-02 10:18:31 -0400
commit2d4e02969dd5ec208bbd36adab0ae1e6fc028638 (patch)
tree2d49c933db8c67b997e62be2ecc9a31ee827e1ee
parent63a46c6550cd43c528148391a8cbe20112361166 (diff)
parentb46d2a8b33a798b42deee2a822dac004364e8337 (diff)
Merge pull request #381 from emersion/fix-disabled-cursors
Fix disabled cursors
-rw-r--r--include/wlr/types/wlr_output.h2
-rw-r--r--types/wlr_output.c22
2 files changed, 15 insertions, 9 deletions
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index b5523100..e6323f9c 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -15,10 +15,12 @@ struct wlr_output_mode {
struct wlr_output_cursor {
struct wlr_output *output;
int32_t x, y;
+ bool enabled;
uint32_t width, height;
int32_t hotspot_x, hotspot_y;
struct wl_list link;
+ // only when using a software cursor without a surface
struct wlr_renderer *renderer;
struct wlr_texture *texture;
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 85e3d05e..c4589487 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -253,10 +253,6 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) {
struct wlr_texture *texture = cursor->texture;
struct wlr_renderer *renderer = cursor->renderer;
if (cursor->surface != NULL) {
- // Some clients commit a cursor surface with a NULL buffer to hide it.
- if (!wlr_surface_has_buffer(cursor->surface)) {
- return;
- }
texture = cursor->surface->texture;
renderer = cursor->surface->renderer;
}
@@ -295,7 +291,7 @@ void wlr_output_swap_buffers(struct wlr_output *output) {
struct wlr_output_cursor *cursor;
wl_list_for_each(cursor, &output->cursors, link) {
- if (output->hardware_cursor == cursor) {
+ if (!cursor->enabled || output->hardware_cursor == cursor) {
continue;
}
output_cursor_render(cursor);
@@ -353,6 +349,11 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
wlr_log(L_INFO, "Falling back to software cursor");
cursor->output->needs_swap = true;
+ cursor->enabled = pixels != NULL;
+ if (!cursor->enabled) {
+ return true;
+ }
+
if (cursor->renderer == NULL) {
cursor->renderer = wlr_gles2_renderer_create(cursor->output->backend);
if (cursor->renderer == NULL) {
@@ -372,6 +373,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
}
static void output_cursor_commit(struct wlr_output_cursor *cursor) {
+ // Some clients commit a cursor surface with a NULL buffer to hide it.
+ cursor->enabled = wlr_surface_has_buffer(cursor->surface);
cursor->width = cursor->surface->current->width;
cursor->height = cursor->surface->current->height;
@@ -418,10 +421,6 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
return;
}
- if (surface) {
- cursor->width = surface->current->width;
- cursor->height = surface->current->height;
- }
cursor->hotspot_x = hotspot_x;
cursor->hotspot_y = hotspot_y;
@@ -454,6 +453,10 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
wl_signal_add(&surface->events.destroy, &cursor->surface_destroy);
output_cursor_commit(cursor);
} else {
+ cursor->enabled = false;
+ cursor->width = 0;
+ cursor->height = 0;
+
// TODO: if hardware cursor, disable cursor
}
}
@@ -463,6 +466,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
cursor->y = y;
if (cursor->output->hardware_cursor != cursor) {
+ cursor->output->needs_swap = true;
return true;
}