1
0
Fork 0

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:
Jasper St. Pierre 2014-09-05 16:29:24 -07:00
parent 1ed607f398
commit e19516ec5a
2 changed files with 34 additions and 22 deletions

View file

@ -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
meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
MetaWaylandSurface *surface)
{
if (keyboard->focus_surface == surface && !wl_list_empty (&keyboard->focus_resource_list))
if (keyboard->focus_surface == surface)
return;
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_display *display = wl_client_get_display (client);
struct xkb_state *state = keyboard->xkb_info.state;
uint32_t serial = wl_display_next_serial (display);
keyboard->focus_serial = wl_display_next_serial (display);
wl_resource_for_each (resource, l)
{
wl_keyboard_send_modifiers (resource, 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, serial, keyboard->focus_surface->resource,
&keyboard->pressed_keys);
broadcast_focus (keyboard, resource);
}
keyboard->focus_serial = serial;
}
}
}
@ -604,5 +611,5 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
notify_key_repeat_for_resource (keyboard, cr);
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);
}

View file

@ -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
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface)
{
if (pointer->focus_surface == surface && !wl_list_empty (&pointer->focus_resource_list))
if (pointer->focus_surface == surface)
return;
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_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_fixed_t sx, sy;
meta_wayland_pointer_get_relative_coordinates (pointer, pointer->focus_surface, &sx, &sy);
wl_pointer_send_enter (resource, serial, pointer->focus_surface->resource, sx, sy);
broadcast_focus (pointer, resource);
}
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));
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