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>
dev
Derek Foreman 10 years ago committed by Pekka Paalanen
parent 8b5211835f
commit d621df2dee
  1. 1
      src/input.c
  2. 2
      src/libinput-device.c

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

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

Loading…
Cancel
Save