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

(cherry picked from commit 16eb461054)
This commit is contained in:
Carlos Garnacho 2019-10-23 13:14:30 +02:00 committed by Robert Mader
parent 4cc5b85c5d
commit e18aa564b0

View File

@ -1741,16 +1741,7 @@ meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
struct wl_client *focus_client; struct wl_client *focus_client;
MetaSelectionSource *selection_source; MetaSelectionSource *selection_source;
if (META_IS_WAYLAND_DATA_SOURCE_PRIMARY (source)) g_assert (!source || 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;
}
if (data_device->primary_data_source && if (data_device->primary_data_source &&
data_device->primary_serial - serial < UINT32_MAX / 2) data_device->primary_serial - serial < UINT32_MAX / 2)
@ -1805,10 +1796,16 @@ primary_device_set_selection (struct wl_client *client,
uint32_t serial) uint32_t serial)
{ {
MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource); MetaWaylandDataDevice *data_device = wl_resource_get_user_data (resource);
MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device);
MetaWaylandDataSource *source = NULL; MetaWaylandDataSource *source = NULL;
if (source_resource) if (source_resource)
source = wl_resource_get_user_data (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); meta_wayland_data_device_set_primary (data_device, source, serial);
} }