mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:03:40 +00:00
[client] clipboard/wayland: support keyboard capability hotplug
This commit is contained in:
parent
c73d50f56a
commit
fb7ee16f7b
@ -200,7 +200,19 @@ static const struct wl_keyboard_listener keyboard_listener = {
|
||||
static void seat_capabilities_handler(void * data, struct wl_seat * seat,
|
||||
uint32_t capabilities)
|
||||
{
|
||||
this->capabilities = capabilities;
|
||||
this->capabilities = capabilities;
|
||||
|
||||
bool has_keyboard = capabilities & WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
if (!has_keyboard && this->keyboard)
|
||||
{
|
||||
wl_keyboard_destroy(this->keyboard);
|
||||
this->keyboard = NULL;
|
||||
}
|
||||
else if (has_keyboard && !this->keyboard)
|
||||
{
|
||||
this->keyboard = wl_seat_get_keyboard(this->seat);
|
||||
wl_keyboard_add_listener(this->keyboard, &keyboard_listener, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void seat_name_handler(void * data, struct wl_seat * seat,
|
||||
@ -375,15 +387,6 @@ static bool wayland_cb_init(
|
||||
// Wait for the compositor to let us know of capabilities.
|
||||
wl_seat_add_listener(this->seat, &seat_listener, NULL);
|
||||
wl_display_roundtrip(this->display);
|
||||
if (!(this->capabilities & WL_SEAT_CAPABILITY_KEYBOARD))
|
||||
{
|
||||
// TODO: keyboard hotplug support.
|
||||
DEBUG_ERROR("no keyboard");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->keyboard = wl_seat_get_keyboard(this->seat);
|
||||
wl_keyboard_add_listener(this->keyboard, &keyboard_listener, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -467,6 +470,10 @@ static void wayland_cb_notice(LG_ClipboardRequestFn requestFn, LG_ClipboardData
|
||||
if (!this->requestFn)
|
||||
return;
|
||||
|
||||
// Won't have a keyboard enter serial if we don't have the keyboard capability.
|
||||
if (!this->keyboard)
|
||||
return;
|
||||
|
||||
this->requestFn(wayland_cb_reply_fn, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user