wayland: globals: destroy: seat: use keyboard/pointer listener interfaces

This commit is contained in:
Daniel Eklöf 2020-07-09 08:52:39 +02:00
parent b6342bb36d
commit a6da07b3dd
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -859,27 +859,19 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
LOG_INFO("seat destroyed: %s", seat->name); LOG_INFO("seat destroyed: %s", seat->name);
if (seat->kbd_focus != NULL) { if (seat->kbd_focus != NULL) {
LOG_WARN("compositor destroyed seat '%s' "
"without sending keyboard/pointer leave events",
seat->name);
struct terminal *term = seat->kbd_focus; struct terminal *term = seat->kbd_focus;
/* Clear this seat's focus */ if (seat->wl_keyboard != NULL)
seat->kbd_focus = NULL; keyboard_listener.leave(
seat, seat->wl_keyboard, -1, term->window->surface);
/* Check if term is focused by *another* seat */ if (seat->wl_pointer != NULL)
bool term_has_other_focus = false; pointer_listener.leave(
tll_foreach(wayl->seats, s) { seat, seat->wl_pointer, -1, term->window->surface);
if (&s->item == seat)
continue;
if (s->item.kbd_focus == term) {
term_has_other_focus = true;
break;
}
}
/* No other seat has it focused - tell it it was unfocused */
if (!term_has_other_focus)
term_kbd_focus_out(term);
} }
seat_destroy(seat); seat_destroy(seat);