aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-10-29 20:58:58 +0100
committeremersion <contact@emersion.fr>2017-10-31 12:30:57 +0100
commit6a74a3586fba7b8c3592d2a94d6b06190c3165b1 (patch)
tree7f40a1051b0b0468cb8451337e5f378f9d28f18c /examples
parent044173d1dfbce7bdc3ae134a829f2bb0d88d208b (diff)
Fix wlr_cursor_destroy, handle device remove in examples/multi-cursor
Diffstat (limited to 'examples')
-rw-r--r--examples/multi-pointer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/multi-pointer.c b/examples/multi-pointer.c
index c3a02cc7..3cfa3910 100644
--- a/examples/multi-pointer.c
+++ b/examples/multi-pointer.c
@@ -134,6 +134,7 @@ static void handle_input_add(struct compositor_state *state,
struct sample_cursor *cursor = calloc(1, sizeof(struct sample_cursor));
cursor->state = sample;
+ cursor->device = device;
cursor->cursor = wlr_cursor_create();
wlr_cursor_attach_output_layout(cursor->cursor, sample->layout);
@@ -156,6 +157,22 @@ static void handle_input_add(struct compositor_state *state,
wl_list_insert(&sample->cursors, &cursor->link);
}
+static void handle_input_remove(struct compositor_state *state,
+ struct wlr_input_device *device) {
+ struct sample_state *sample = state->data;
+ struct sample_cursor *cursor;
+ wl_list_for_each(cursor, &sample->cursors, link) {
+ if (cursor->device == device) {
+ wl_list_remove(&cursor->link);
+ wl_list_remove(&cursor->cursor_motion.link);
+ wl_list_remove(&cursor->cursor_motion_absolute.link);
+ wlr_cursor_destroy(cursor->cursor);
+ free(cursor);
+ break;
+ }
+ }
+}
+
int main(int argc, char *argv[]) {
struct sample_state state = {
.default_color = { 0.25f, 0.25f, 0.25f, 1 },
@@ -173,6 +190,7 @@ int main(int argc, char *argv[]) {
compositor.output_remove_cb = handle_output_remove;
compositor.output_frame_cb = handle_output_frame;
compositor.input_add_cb = handle_input_add;
+ compositor.input_remove_cb = handle_input_remove;
state.compositor = &compositor;