[mutter] seat: Move the keyboard resource creation over to MetaWaylandKeyboard
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] seat: Move the keyboard resource creation over to MetaWaylandKeyboard
- Date: Thu, 17 Apr 2014 23:18:02 +0000 (UTC)
commit 7c6c4d63c59880d13f1032604a3afc45c8fe40ef
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Apr 17 18:22:26 2014 -0400
seat: Move the keyboard resource creation over to MetaWaylandKeyboard
src/wayland/meta-wayland-keyboard.c | 39 +++++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-keyboard.h | 6 +++++
src/wayland/meta-wayland-seat.c | 26 +----------------------
3 files changed, 46 insertions(+), 25 deletions(-)
---
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 3801e0b..d4c43ad 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -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);
+}
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index 17bd1be..3f88b35 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -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__ */
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index 27d9ef7..b85eed0 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -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"
@@ -57,37 +56,14 @@ seat_get_pointer (struct wl_client *client,
}
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,
uint32_t id)
{
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]