wayland: refactor window destruction and focus

The previous code was leaving focus fields dirty in MetaWaylandPointer
and MetaWaylandKeyboard at time (which could crash the X server
because of invalid object IDs)
The new code is more tighly integrated in the normal X11 code
for handling keyboard focus (meaning that the core idea of input
focus is also correct now), so that meta_window_unmanage() can
do the right thing. As a side benefit, clicking on wayland clients
now unfocus X11 clients.
For the mouse focus, we need to clear the surface pointer when
the metawindowactor is destroyed (even if the actual actor is
kept alive for effects), so that a repick finds a different pointer
focus.

https://bugzilla.gnome.org/show_bug.cgi?id=705859
This commit is contained in:
Giovanni Campagna
2013-08-12 18:04:34 +02:00
parent 03f55b9485
commit 9a5f243f73
6 changed files with 108 additions and 65 deletions

View File

@ -60,6 +60,7 @@ lose_pointer_focus (struct wl_listener *listener, void *data)
wl_container_of (listener, pointer, focus_listener);
pointer->focus_resource = NULL;
pointer->focus = NULL;
}
static void
@ -138,6 +139,9 @@ meta_wayland_pointer_release (MetaWaylandPointer *pointer)
/* XXX: What about pointer->resource_list? */
if (pointer->focus_resource)
wl_list_remove (&pointer->focus_listener.link);
pointer->focus = NULL;
pointer->focus_resource = NULL;
}
static struct wl_resource *
@ -148,9 +152,7 @@ find_resource_for_surface (struct wl_list *list, MetaWaylandSurface *surface)
if (!surface)
return NULL;
if (!surface->resource)
return NULL;
g_assert (surface->resource);
client = wl_resource_get_client (surface->resource);
return wl_resource_find_for_client (list, client);