[mutter/wip/carlosg/check-selection-request-focus: 16/17] wayland: Clean up meta_wayland_data_device_set_primary()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/check-selection-request-focus: 16/17] wayland: Clean up meta_wayland_data_device_set_primary()
- Date: Wed, 23 Oct 2019 18:11:15 +0000 (UTC)
commit 71315af12dce5a2010b8e4d184589992410ea9a7
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Oct 23 13:14:30 2019 +0200
wayland: Clean up meta_wayland_data_device_set_primary()
This function is already checking for the focus surface client
matching the requestor. The type check was slightly bogus though
as it'd be an screwup in our code, make it an assert instead.
Also, move the check for the client having the focus into the
upper call, so this and wl_data_device.set_selection code can
get more in line.
https://gitlab.gnome.org/GNOME/mutter/issues/878
src/wayland/meta-wayland-data-device.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 897f3c782..53b81a7c2 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -1734,16 +1734,7 @@ meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
struct wl_client *focus_client;
MetaSelectionSource *selection_source;
- if (META_IS_WAYLAND_DATA_SOURCE_PRIMARY (source))
- {
- struct wl_resource *resource;
-
- resource = meta_wayland_data_source_get_resource (source);
-
- if (wl_resource_get_client (resource) !=
- meta_wayland_keyboard_get_focus_client (seat->keyboard))
- return;
- }
+ g_assert (!source || META_IS_WAYLAND_DATA_SOURCE_PRIMARY (source));
if (data_device->primary_data_source &&
data_device->primary_serial - serial < UINT32_MAX / 2)
@@ -1800,10 +1791,16 @@ primary_device_set_selection (struct wl_client *client,
uint32_t serial)
{
MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource);
+ MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
MetaWaylandDataSource *source = NULL;
if (source_resource)
source = wl_resource_get_user_data (source_resource);
+
+ if (wl_resource_get_client (resource) !=
+ meta_wayland_keyboard_get_focus_client (seat->keyboard))
+ return;
+
meta_wayland_data_device_set_primary (data_device, source, serial);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]