[mutter] data-device: Don't poke into MetaWaylandKeyboard
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] data-device: Don't poke into MetaWaylandKeyboard
- Date: Wed, 16 Apr 2014 19:32:27 +0000 (UTC)
commit 2bcd4ab15947b224bb09482aa8afd87cc7e0dcd1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Apr 16 15:20:07 2014 -0400
data-device: Don't poke into MetaWaylandKeyboard
It needs to know the wl_client that has keyboard focus, so add a simple
getter for that.
src/wayland/meta-wayland-data-device.c | 32 +++++++++++++-------------------
src/wayland/meta-wayland-keyboard.c | 8 ++++++++
src/wayland/meta-wayland-keyboard.h | 3 +++
3 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index c454761..46f9a40 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -360,17 +360,14 @@ destroy_selection_data_source (struct wl_listener *listener, void *data)
MetaWaylandSeat *seat =
wl_container_of (listener, seat, selection_data_source_listener);
struct wl_resource *data_device;
- struct wl_resource *focus = NULL;
+ struct wl_client *focus_client = NULL;
seat->selection_data_source = NULL;
- focus = seat->keyboard.focus_resource;
-
- if (focus)
+ focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
+ if (focus_client)
{
- data_device =
- wl_resource_find_for_client (&seat->data_device_resource_list,
- wl_resource_get_client (focus));
+ data_device = wl_resource_find_for_client (&seat->data_device_resource_list, focus_client);
if (data_device)
wl_data_device_send_selection (data_device, NULL);
}
@@ -382,7 +379,7 @@ meta_wayland_seat_set_selection (MetaWaylandSeat *seat,
guint32 serial)
{
struct wl_resource *data_device, *offer;
- struct wl_resource *focus = NULL;
+ struct wl_client *focus_client;
if (seat->selection_data_source &&
seat->selection_serial - serial < UINT32_MAX / 2)
@@ -398,13 +395,10 @@ meta_wayland_seat_set_selection (MetaWaylandSeat *seat,
seat->selection_data_source = source;
seat->selection_serial = serial;
- focus = seat->keyboard.focus_resource;
-
- if (focus)
+ focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
+ if (focus_client)
{
- data_device =
- wl_resource_find_for_client (&seat->data_device_resource_list,
- wl_resource_get_client (focus));
+ data_device = wl_resource_find_for_client (&seat->data_device_resource_list, focus_client);
if (data_device && source)
{
offer =
@@ -515,15 +509,15 @@ bind_manager (struct wl_client *client,
void
meta_wayland_data_device_set_keyboard_focus (MetaWaylandSeat *seat)
{
- struct wl_resource *data_device, *focus, *offer;
+ struct wl_client *focus_client;
+ struct wl_resource *data_device, *offer;
MetaWaylandDataSource *source;
- focus = seat->keyboard.focus_resource;
- if (!focus)
+ focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
+ if (!focus_client)
return;
- data_device = wl_resource_find_for_client (&seat->data_device_resource_list,
- wl_resource_get_client (focus));
+ data_device = wl_resource_find_for_client (&seat->data_device_resource_list, focus_client);
if (!data_device)
return;
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 5aac8fb..302b579 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -532,3 +532,11 @@ meta_wayland_keyboard_set_keymap_names (MetaWaylandKeyboard *keyboard,
flags);
}
+struct wl_client *
+meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard)
+{
+ if (keyboard->focus_surface)
+ return wl_resource_get_client (keyboard->focus_surface->resource);
+ else
+ return NULL;
+}
diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h
index 13fbf0a..d2c71ff 100644
--- a/src/wayland/meta-wayland-keyboard.h
+++ b/src/wayland/meta-wayland-keyboard.h
@@ -140,4 +140,7 @@ void
meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
const ClutterKeyEvent *event);
+struct wl_client *
+meta_wayland_keyboard_get_focus_client (MetaWaylandKeyboard *keyboard);
+
#endif /* __META_WAYLAND_KEYBOARD_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]