input: Use slightly less obscure logic in evdev_notify_keyboard_focus()

While the test is actually correct (for non-negative numbers), it's not
at all clear and seems to be an accidental order of operations mistake.

Also, add an assert() to make sure this number is never negative.

Closes bug 86346 - https://bugs.freedesktop.org/show_bug.cgi?id=86346

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
This commit is contained in:
Derek Foreman 2014-11-19 11:04:12 -06:00 committed by Pekka Paalanen
parent 8b5211835f
commit d621df2dee
2 changed files with 2 additions and 1 deletions

View file

@ -2168,6 +2168,7 @@ WL_EXPORT void
weston_seat_release_keyboard(struct weston_seat *seat)
{
seat->keyboard_device_count--;
assert(seat->keyboard_device_count >= 0);
if (seat->keyboard_device_count == 0) {
weston_keyboard_set_focus(seat->keyboard, NULL);
weston_keyboard_cancel_grab(seat->keyboard);

View file

@ -470,7 +470,7 @@ evdev_notify_keyboard_focus(struct weston_seat *seat,
{
struct wl_array keys;
if (!seat->keyboard_device_count > 0)
if (seat->keyboard_device_count == 0)
return;
wl_array_init(&keys);