wayland: Fix possibly out of sync primary selections
Replace the sync_focus() calls with a set_focus() do-it function taking a surface. This is in line with the rest of the things that happen at the default MetaWaylandEventInterface.focus implementation, and will make these correctly observe the presence of grabs, since meta_wayland_seat_get_input_focus() will return the would-be focus in these cases. This change makes the "focused" client selection truly in sync with the keyboard focus. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3498 Fixes:9bdb00c459
("wayland: Follow seat's input focus client for primary selections") Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3789> (cherry picked from commit9dab806a18
)
This commit is contained in:
parent
2fca52fb91
commit
73cab26d0f
3 changed files with 11 additions and 15 deletions
|
@ -181,8 +181,7 @@ primary_device_set_selection (struct wl_client *client,
|
|||
if (source_resource)
|
||||
source = wl_resource_get_user_data (source_resource);
|
||||
|
||||
if (wl_resource_get_client (resource) !=
|
||||
meta_wayland_seat_get_input_focus_client (seat))
|
||||
if (wl_resource_get_client (resource) != data_device->focus_client)
|
||||
{
|
||||
if (source)
|
||||
meta_wayland_data_source_cancel (source);
|
||||
|
@ -203,16 +202,9 @@ owner_changed_cb (MetaSelection *selection,
|
|||
MetaSelectionSource *new_owner,
|
||||
MetaWaylandDataDevicePrimary *data_device)
|
||||
{
|
||||
MetaDisplay *display = meta_selection_get_display (selection);
|
||||
MetaContext *context = meta_display_get_context (display);
|
||||
MetaWaylandCompositor *compositor =
|
||||
meta_context_get_wayland_compositor (context);
|
||||
MetaWaylandSeat *seat = compositor->seat;
|
||||
struct wl_resource *data_device_resource;
|
||||
struct wl_client *focus_client;
|
||||
|
||||
focus_client = meta_wayland_seat_get_input_focus_client (seat);
|
||||
if (!focus_client)
|
||||
if (!data_device->focus_client)
|
||||
return;
|
||||
|
||||
if (selection_type == META_SELECTION_PRIMARY)
|
||||
|
@ -348,13 +340,15 @@ create_and_send_primary_offer (MetaWaylandDataDevicePrimary *data_device,
|
|||
}
|
||||
|
||||
void
|
||||
meta_wayland_data_device_primary_sync_focus (MetaWaylandDataDevicePrimary *data_device)
|
||||
meta_wayland_data_device_primary_set_focus (MetaWaylandDataDevicePrimary *data_device,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
MetaWaylandSeat *seat = wl_container_of (data_device, seat, primary_data_device);
|
||||
struct wl_client *focus_client;
|
||||
struct wl_client *focus_client = NULL;
|
||||
struct wl_resource *data_device_resource;
|
||||
|
||||
focus_client = meta_wayland_seat_get_input_focus_client (seat);
|
||||
if (surface)
|
||||
focus_client = wl_resource_get_client (surface->resource);
|
||||
|
||||
if (focus_client == data_device->focus_client)
|
||||
return;
|
||||
|
|
|
@ -52,4 +52,5 @@ void meta_wayland_data_device_primary_manager_init (MetaWaylandCompositor *compo
|
|||
void meta_wayland_data_device_primary_init (MetaWaylandDataDevicePrimary *data_device,
|
||||
MetaWaylandSeat *seat);
|
||||
|
||||
void meta_wayland_data_device_primary_sync_focus (MetaWaylandDataDevicePrimary *data_device);
|
||||
void meta_wayland_data_device_primary_set_focus (MetaWaylandDataDevicePrimary *data_device,
|
||||
MetaWaylandSurface *surface);
|
||||
|
|
|
@ -225,7 +225,8 @@ default_focus (MetaWaylandEventHandler *handler,
|
|||
meta_wayland_keyboard_set_focus (seat->keyboard, surface);
|
||||
|
||||
meta_wayland_data_device_sync_focus (&seat->data_device);
|
||||
meta_wayland_data_device_primary_sync_focus (&seat->primary_data_device);
|
||||
meta_wayland_data_device_primary_set_focus (&seat->primary_data_device,
|
||||
surface);
|
||||
meta_wayland_tablet_seat_set_pad_focus (seat->tablet_seat, surface);
|
||||
meta_wayland_text_input_set_focus (seat->text_input, surface);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue