seat: Move the keyboard resource creation over to MetaWaylandKeyboard
This commit is contained in:
parent
5d43e33032
commit
7c6c4d63c5
@ -60,6 +60,12 @@
|
||||
|
||||
#include "meta-wayland-private.h"
|
||||
|
||||
static void
|
||||
unbind_resource (struct wl_resource *resource)
|
||||
{
|
||||
wl_list_remove (wl_resource_get_link (resource));
|
||||
}
|
||||
|
||||
static int
|
||||
create_anonymous_file (off_t size,
|
||||
GError **error)
|
||||
@ -551,3 +557,36 @@ meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard)
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_release (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_interface keyboard_interface = {
|
||||
keyboard_release,
|
||||
};
|
||||
|
||||
void
|
||||
meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
||||
struct wl_client *client,
|
||||
struct wl_resource *seat_resource,
|
||||
uint32_t id)
|
||||
{
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, &wl_keyboard_interface,
|
||||
MIN (META_WL_KEYBOARD_VERSION, wl_resource_get_version (seat_resource)), id);
|
||||
wl_resource_set_implementation (cr, NULL, keyboard, unbind_resource);
|
||||
wl_list_insert (&keyboard->resource_list, wl_resource_get_link (cr));
|
||||
|
||||
wl_keyboard_send_keymap (cr,
|
||||
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
||||
keyboard->xkb_info.keymap_fd,
|
||||
keyboard->xkb_info.keymap_size);
|
||||
|
||||
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
||||
meta_wayland_keyboard_set_focus (keyboard, keyboard->focus_surface);
|
||||
}
|
||||
|
@ -143,4 +143,10 @@ meta_wayland_keyboard_set_keymap_names (MetaWaylandKeyboard *keyboard,
|
||||
struct wl_client *
|
||||
meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard);
|
||||
|
||||
void
|
||||
meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
||||
struct wl_client *client,
|
||||
struct wl_resource *seat_resource,
|
||||
uint32_t id);
|
||||
|
||||
#endif /* __META_WAYLAND_KEYBOARD_H__ */
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "meta-wayland-private.h"
|
||||
#include "meta-wayland-keyboard.h"
|
||||
#include "meta-wayland-pointer.h"
|
||||
#include "meta-wayland-data-device.h"
|
||||
#include "meta-window-actor-private.h"
|
||||
#include "meta/meta-shaped-texture.h"
|
||||
#include "meta-shaped-texture-private.h"
|
||||
@ -56,17 +55,6 @@ seat_get_pointer (struct wl_client *client,
|
||||
meta_wayland_pointer_create_new_resource (pointer, client, resource, id);
|
||||
}
|
||||
|
||||
static void
|
||||
keyboard_release (struct wl_client *client,
|
||||
struct wl_resource *resource)
|
||||
{
|
||||
wl_resource_destroy (resource);
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_interface keyboard_interface = {
|
||||
keyboard_release,
|
||||
};
|
||||
|
||||
static void
|
||||
seat_get_keyboard (struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
@ -74,20 +62,8 @@ seat_get_keyboard (struct wl_client *client,
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
||||
MetaWaylandKeyboard *keyboard = &seat->keyboard;
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, &wl_keyboard_interface,
|
||||
MIN (META_WL_KEYBOARD_VERSION, wl_resource_get_version (resource)), id);
|
||||
wl_resource_set_implementation (cr, NULL, seat, unbind_resource);
|
||||
wl_list_insert (&keyboard->resource_list, wl_resource_get_link (cr));
|
||||
|
||||
wl_keyboard_send_keymap (cr,
|
||||
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
||||
keyboard->xkb_info.keymap_fd,
|
||||
keyboard->xkb_info.keymap_size);
|
||||
|
||||
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
||||
meta_wayland_keyboard_set_focus (keyboard, keyboard->focus_surface);
|
||||
meta_wayland_keyboard_create_new_resource (keyboard, client, resource, id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user