[PATCH weston 15/17] desktop-shell: Check for device presence properly

Derek Foreman derekf at osg.samsung.com
Wed Jul 15 11:00:46 PDT 2015


We should be testing device counts, not pointers.  The pointers are
persistent state that never gets freed, and are an inaccurate indicator
of device presence after a release.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 desktop-shell/shell.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index d0dda84..3555e72 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -3104,20 +3104,20 @@ shell_seat_caps_changed(struct wl_listener *listener, void *data)
 
 	seat = container_of(listener, struct shell_seat, caps_changed_listener);
 
-	if (seat->seat->keyboard &&
+	if (seat->seat->keyboard_device_count &&
 	    wl_list_empty(&seat->keyboard_focus_listener.link)) {
 		wl_signal_add(&seat->seat->keyboard->focus_signal,
 			      &seat->keyboard_focus_listener);
-	} else if (!seat->seat->keyboard) {
+	} else if (!seat->seat->keyboard_device_count) {
 		wl_list_remove(&seat->keyboard_focus_listener.link);
 		wl_list_init(&seat->keyboard_focus_listener.link);
 	}
 
-	if (seat->seat->pointer &&
+	if (seat->seat->pointer_device_count &&
 	    wl_list_empty(&seat->pointer_focus_listener.link)) {
 		wl_signal_add(&seat->seat->pointer->focus_signal,
 			      &seat->pointer_focus_listener);
-	} else if (!seat->seat->pointer) {
+	} else if (!seat->seat->pointer_device_count) {
 		wl_list_remove(&seat->pointer_focus_listener.link);
 		wl_list_init(&seat->pointer_focus_listener.link);
 	}
-- 
2.1.4



More information about the wayland-devel mailing list