[PATCH v2 weston] input: Don't test keyboard/pointer/touch pointers

Bill Spitzak spitzak at gmail.com
Mon Feb 2 11:40:20 PST 2015

Is there a reason it does not just clear the pointer when 
keyboard_device_count is changed to zero? That would seem like a smaller 

Assuming there is a good reason there seem to be some errors. At first I 
thought there were just redundant checks for seat being null, which I 
think should be removed, but I then found that most of them were actual 
errors. For instance right at the end:

> @@ -1270,13 +1274,14 @@ weston_wm_window_handle_moveresize(struct weston_wm_window *window,
>   	struct weston_wm *wm = window->wm;
>   	struct weston_seat *seat = weston_wm_pick_seat_for_window(window);
> +	struct weston_pointer *pointer = weston_seat_get_pointer(seat);
>   	int detail;
>   	struct weston_shell_interface *shell_interface =
>   		&wm->server->compositor->shell_interface;
> -	if (seat == NULL || seat->pointer->button_count != 1
> -	    || !seat->pointer->focus
> -	    || seat->pointer->focus->surface != window->surface)
> +	if (seat == NULL || pointer->button_count != 1
> +	    || !pointer->focus
> +	    || pointer->focus->surface != window->surface)
>   		return;
>   	detail = client_message->data.data32[2];

That will crash if the pointer count is zero. The correct if statement, 
which also removes the redundant check for seat being null, is (I think):

	if (!pointer || pointer->button_count != 1
	    || !pointer->focus
	    || pointer->focus->surface != window->surface)

I then started looking backwards through the code and spotted these:

setup_output_seat_constraint which is passing &seat->base to 
weston_seat_get_pointer, followed by a test of (seat && pointer). That 
will not work if seat is null, so either you must test that first or the 
test for seat is irrelevant and should be removed.

force_kill_binding() appears to have deleted the setting of the 
focus_surface variable.

Several other functions look like they should take a 
pointer/keyboard/touch as an argument instead of a seat, as the only 
thing they do is extract the pointer and then act like it is never going 
to be null. Examples are click_to_activate_binding, rotate_binding, 

More information about the wayland-devel mailing list