commit 1c1bc11
Michael Forney
·
2013-09-03 23:24:05 +0000 UTC
parent 9f45312
pointer: Handle cursor surface destroys
2 files changed,
+17,
-0
+16,
-0
1@@ -41,6 +41,15 @@ static void leave(struct swc_input_focus_handler * handler,
2 wl_pointer_send_leave(resource, serial, surface->resource);
3 }
4
5+static void handle_cursor_surface_destroy(struct wl_listener * listener,
6+ void * data)
7+{
8+ struct swc_pointer * pointer = swc_container_of(listener, typeof(*pointer),
9+ cursor.destroy_listener);
10+
11+ pointer->cursor.surface = NULL;
12+}
13+
14 bool swc_pointer_initialize(struct swc_pointer * pointer)
15 {
16 wl_signal_init(&pointer->event_signal);
17@@ -51,6 +60,8 @@ bool swc_pointer_initialize(struct swc_pointer * pointer)
18 pointer->focus_handler.enter = &enter;
19 pointer->focus_handler.leave = &leave;
20
21+ pointer->cursor.destroy_listener.notify = &handle_cursor_surface_destroy;
22+
23 swc_input_focus_initialize(&pointer->focus, &pointer->focus_handler);
24
25 return true;
26@@ -80,6 +91,9 @@ static void set_cursor(struct wl_client * client,
27
28 printf("set_cursor\n");
29
30+ if (pointer->cursor.surface)
31+ wl_list_remove(&pointer->cursor.destroy_listener.link);
32+
33 surface = surface_resource ? wl_resource_get_user_data(surface_resource)
34 : NULL;
35
36@@ -87,6 +101,8 @@ static void set_cursor(struct wl_client * client,
37 {
38 surface->geometry.x = wl_fixed_to_int(pointer->x) - hotspot_x;
39 surface->geometry.y = wl_fixed_to_int(pointer->y) - hotspot_y;
40+ wl_resource_add_destroy_listener(surface->resource,
41+ &pointer->cursor.destroy_listener);
42 }
43
44 pointer->cursor.surface = surface;
+1,
-0
1@@ -32,6 +32,7 @@ struct swc_pointer
2 {
3 struct swc_surface * surface;
4 int32_t hotspot_x, hotspot_y;
5+ struct wl_listener destroy_listener;
6 } cursor;
7
8 struct swc_pointer_handler * handler;