wayland: Replace make_toplevel / window_unmanaging with set_window

The make_toplevel / window_unmanaging interface has never made
a lot of sense to me. Replace it with set_window, which does
effectively the same thing.

It's still not perfect in the case of XWayland, but I don't think
XWayland will ever make me happy.
This commit is contained in:
Jasper St. Pierre 2014-04-02 10:37:08 -04:00
parent e4cd000cef
commit 3c404c5db3
4 changed files with 24 additions and 26 deletions

View File

@ -1468,7 +1468,7 @@ meta_window_unmanage (MetaWindow *window,
/* This needs to happen for both Wayland and XWayland clients, /* This needs to happen for both Wayland and XWayland clients,
* so it can't be in MetaWindowWayland. */ * so it can't be in MetaWindowWayland. */
if (window->surface) if (window->surface)
meta_wayland_surface_window_unmanaged (window->surface); meta_wayland_surface_set_window (window->surface, NULL);
if (window->visible_to_compositor) if (window->visible_to_compositor)
{ {

View File

@ -549,16 +549,13 @@ const struct wl_surface_interface meta_wayland_surface_interface = {
}; };
void void
meta_wayland_surface_make_toplevel (MetaWaylandSurface *surface) meta_wayland_surface_set_window (MetaWaylandSurface *surface,
MetaWindow *window)
{ {
clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), TRUE); gboolean has_window = (window != NULL);
}
void clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), has_window);
meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface) surface->window = window;
{
clutter_actor_set_reactive (CLUTTER_ACTOR (surface->surface_actor), FALSE);
surface->window = NULL;
} }
static void static void
@ -909,6 +906,7 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWindow *window;
if (!create_surface_extension (&surface->xdg_surface, if (!create_surface_extension (&surface->xdg_surface,
META_XDG_SURFACE_VERSION, META_XDG_SURFACE_VERSION,
@ -923,8 +921,8 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
return; return;
} }
meta_wayland_surface_make_toplevel (surface); window = meta_window_wayland_new (meta_get_display (), surface);
surface->window = meta_window_wayland_new (meta_get_display (), surface); meta_wayland_surface_set_window (surface, window);
} }
static void static void
@ -962,6 +960,7 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource); MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
MetaWindow *window;
if (parent_surf == NULL || parent_surf->window == NULL) if (parent_surf == NULL || parent_surf->window == NULL)
return; return;
@ -979,15 +978,15 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
return; return;
} }
meta_wayland_surface_make_toplevel (surface); window = meta_window_wayland_new (meta_get_display (), surface);
surface->window = meta_window_wayland_new (meta_get_display (), surface); window->rect.x = parent_surf->window->rect.x + x;
surface->window->rect.x = parent_surf->window->rect.x + x; window->rect.y = parent_surf->window->rect.y + y;
surface->window->rect.y = parent_surf->window->rect.y + y; window->showing_for_first_time = FALSE;
surface->window->showing_for_first_time = FALSE; window->placed = TRUE;
surface->window->placed = TRUE; meta_window_set_transient_for (window, parent_surf->window);
meta_window_set_transient_for (surface->window, parent_surf->window); meta_window_set_type (window, META_WINDOW_DROPDOWN_MENU);
meta_window_set_type (surface->window, META_WINDOW_DROPDOWN_MENU); meta_wayland_surface_set_window (surface, window);
meta_wayland_pointer_start_popup_grab (&seat->pointer, surface); meta_wayland_pointer_start_popup_grab (&seat->pointer, surface);
} }
@ -1270,6 +1269,7 @@ wl_shell_get_shell_surface (struct wl_client *client,
struct wl_resource *surface_resource) struct wl_resource *surface_resource)
{ {
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWindow *window;
if (!create_surface_extension (&surface->wl_shell_surface, if (!create_surface_extension (&surface->wl_shell_surface,
META_WL_SHELL_SURFACE_VERSION, META_WL_SHELL_SURFACE_VERSION,
@ -1284,8 +1284,8 @@ wl_shell_get_shell_surface (struct wl_client *client,
return; return;
} }
meta_wayland_surface_make_toplevel (surface); window = meta_window_wayland_new (meta_get_display (), surface);
surface->window = meta_window_wayland_new (meta_get_display (), surface); meta_wayland_surface_set_window (surface, window);
} }
static const struct wl_shell_interface meta_wayland_wl_shell_interface = { static const struct wl_shell_interface meta_wayland_wl_shell_interface = {

View File

@ -111,8 +111,8 @@ MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *composit
guint32 id, guint32 id,
guint32 version); guint32 version);
void meta_wayland_surface_make_toplevel (MetaWaylandSurface *surface); void meta_wayland_surface_set_window (MetaWaylandSurface *surface,
void meta_wayland_surface_window_unmanaged (MetaWaylandSurface *surface); MetaWindow *window);
void meta_wayland_surface_configure_notify (MetaWaylandSurface *surface, void meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
int width, int width,

View File

@ -54,9 +54,7 @@ xserver_set_window_id (struct wl_client *client,
if (window->surface) if (window->surface)
window->surface->window = NULL; window->surface->window = NULL;
meta_wayland_surface_make_toplevel (surface); meta_wayland_surface_set_window (surface, window);
surface->window = window;
window->surface = surface; window->surface = surface;
meta_compositor_window_surface_changed (display->compositor, window); meta_compositor_window_surface_changed (display->compositor, window);