wayland: Don't set_focus for new resources
Otherwise, we can re-add the destroy listener, which can cause corruption. Instead, split out the broadcast function, and use that.
This commit is contained in:
parent
1ed607f398
commit
e19516ec5a
@ -497,11 +497,27 @@ move_resources_for_client (struct wl_list *destination,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
broadcast_focus (MetaWaylandKeyboard *keyboard,
|
||||||
|
struct wl_resource *resource)
|
||||||
|
{
|
||||||
|
struct xkb_state *state = keyboard->xkb_info.state;
|
||||||
|
|
||||||
|
wl_keyboard_send_modifiers (resource, keyboard->focus_serial,
|
||||||
|
xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
|
||||||
|
xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
|
||||||
|
xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
|
||||||
|
xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
|
||||||
|
wl_keyboard_send_enter (resource, keyboard->focus_serial,
|
||||||
|
keyboard->focus_surface->resource,
|
||||||
|
&keyboard->pressed_keys);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
|
meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
|
||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
if (keyboard->focus_surface == surface && !wl_list_empty (&keyboard->focus_resource_list))
|
if (keyboard->focus_surface == surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (keyboard->focus_surface != NULL)
|
if (keyboard->focus_surface != NULL)
|
||||||
@ -545,21 +561,12 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
|
|||||||
{
|
{
|
||||||
struct wl_client *client = wl_resource_get_client (keyboard->focus_surface->resource);
|
struct wl_client *client = wl_resource_get_client (keyboard->focus_surface->resource);
|
||||||
struct wl_display *display = wl_client_get_display (client);
|
struct wl_display *display = wl_client_get_display (client);
|
||||||
struct xkb_state *state = keyboard->xkb_info.state;
|
keyboard->focus_serial = wl_display_next_serial (display);
|
||||||
uint32_t serial = wl_display_next_serial (display);
|
|
||||||
|
|
||||||
wl_resource_for_each (resource, l)
|
wl_resource_for_each (resource, l)
|
||||||
{
|
{
|
||||||
wl_keyboard_send_modifiers (resource, serial,
|
broadcast_focus (keyboard, resource);
|
||||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_DEPRESSED),
|
|
||||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LATCHED),
|
|
||||||
xkb_state_serialize_mods (state, XKB_STATE_MODS_LOCKED),
|
|
||||||
xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE));
|
|
||||||
wl_keyboard_send_enter (resource, serial, keyboard->focus_surface->resource,
|
|
||||||
&keyboard->pressed_keys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard->focus_serial = serial;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,5 +611,5 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
|||||||
notify_key_repeat_for_resource (keyboard, cr);
|
notify_key_repeat_for_resource (keyboard, cr);
|
||||||
|
|
||||||
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
if (keyboard->focus_surface && wl_resource_get_client (keyboard->focus_surface->resource) == client)
|
||||||
meta_wayland_keyboard_set_focus (keyboard, keyboard->focus_surface);
|
broadcast_focus (keyboard, cr);
|
||||||
}
|
}
|
||||||
|
@ -462,11 +462,21 @@ move_resources_for_client (struct wl_list *destination,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
broadcast_focus (MetaWaylandPointer *pointer,
|
||||||
|
struct wl_resource *resource)
|
||||||
|
{
|
||||||
|
wl_fixed_t sx, sy;
|
||||||
|
|
||||||
|
meta_wayland_pointer_get_relative_coordinates (pointer, pointer->focus_surface, &sx, &sy);
|
||||||
|
wl_pointer_send_enter (resource, pointer->focus_serial, pointer->focus_surface->resource, sx, sy);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
|
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
|
||||||
MetaWaylandSurface *surface)
|
MetaWaylandSurface *surface)
|
||||||
{
|
{
|
||||||
if (pointer->focus_surface == surface && !wl_list_empty (&pointer->focus_resource_list))
|
if (pointer->focus_surface == surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pointer->focus_surface)
|
if (pointer->focus_surface)
|
||||||
@ -518,17 +528,12 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
|
|||||||
{
|
{
|
||||||
struct wl_client *client = wl_resource_get_client (pointer->focus_surface->resource);
|
struct wl_client *client = wl_resource_get_client (pointer->focus_surface->resource);
|
||||||
struct wl_display *display = wl_client_get_display (client);
|
struct wl_display *display = wl_client_get_display (client);
|
||||||
uint32_t serial = wl_display_next_serial (display);
|
pointer->focus_serial = wl_display_next_serial (display);
|
||||||
|
|
||||||
wl_resource_for_each (resource, l)
|
wl_resource_for_each (resource, l)
|
||||||
{
|
{
|
||||||
wl_fixed_t sx, sy;
|
broadcast_focus (pointer, resource);
|
||||||
|
|
||||||
meta_wayland_pointer_get_relative_coordinates (pointer, pointer->focus_surface, &sx, &sy);
|
|
||||||
wl_pointer_send_enter (resource, serial, pointer->focus_surface->resource, sx, sy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer->focus_serial = serial;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,7 +815,7 @@ meta_wayland_pointer_create_new_resource (MetaWaylandPointer *pointer,
|
|||||||
wl_list_insert (&pointer->resource_list, wl_resource_get_link (cr));
|
wl_list_insert (&pointer->resource_list, wl_resource_get_link (cr));
|
||||||
|
|
||||||
if (pointer->focus_surface && wl_resource_get_client (pointer->focus_surface->resource) == client)
|
if (pointer->focus_surface && wl_resource_get_client (pointer->focus_surface->resource) == client)
|
||||||
meta_wayland_pointer_set_focus (pointer, pointer->focus_surface);
|
broadcast_focus (pointer, cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
x
Reference in New Issue
Block a user