wayland: Introduce XWayland surface role

Being a "XWayland window" should be considered equivalent to a role,
even though it is not part of any protocol anywhere. The commit doesn't
have any functional difference, but just makes it clear that an
wl_surface managed by XWayland have the same type of special casing as
surface roles as defined by the Wayland protocol.

As the semantics are more explicit given the role is defined, a comment
explaining why the semantics need to be how they are was added.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
This commit is contained in:
Jonas Ådahl 2015-08-20 16:54:45 +08:00
parent 443d579d40
commit dece49b53d
3 changed files with 24 additions and 0 deletions

View File

@ -543,6 +543,18 @@ apply_pending_state (MetaWaylandSurface *surface,
switch (surface->role)
{
case META_WAYLAND_SURFACE_ROLE_NONE:
case META_WAYLAND_SURFACE_ROLE_XWAYLAND:
/* For Xwayland windows, throttling frames when the window isn't actually
* drawn is less useful, because Xwayland still has to do the drawing
* sent from the application - the throttling would only be of sending us
* damage messages, so we simplify and send frame callbacks after the
* next paint of the screen, whether the window was drawn or not.
*
* Currently it may take a few frames before we draw the window, for not
* completely understood reasons, and in that case, not thottling frame
* callbacks to drawing has the happy side effect that we avoid showing
* the user the initial black frame from when the window is mapped empty.
*/
case META_WAYLAND_SURFACE_ROLE_CURSOR:
case META_WAYLAND_SURFACE_ROLE_DND:
wl_list_insert_list (&compositor->frame_callbacks, &pending->frame_callback_list);
@ -560,6 +572,7 @@ apply_pending_state (MetaWaylandSurface *surface,
switch (surface->role)
{
case META_WAYLAND_SURFACE_ROLE_NONE:
case META_WAYLAND_SURFACE_ROLE_XWAYLAND:
break;
case META_WAYLAND_SURFACE_ROLE_CURSOR:
cursor_surface_commit (surface, pending);

View File

@ -51,6 +51,7 @@ typedef enum
META_WAYLAND_SURFACE_ROLE_WL_SHELL_SURFACE,
META_WAYLAND_SURFACE_ROLE_CURSOR,
META_WAYLAND_SURFACE_ROLE_DND,
META_WAYLAND_SURFACE_ROLE_XWAYLAND,
} MetaWaylandSurfaceRole;
typedef struct

View File

@ -45,6 +45,16 @@ associate_window_with_surface (MetaWindow *window,
if (window->surface)
window->surface->window = NULL;
if (!meta_wayland_surface_assign_role (surface,
META_WAYLAND_SURFACE_ROLE_XWAYLAND))
{
wl_resource_post_error (surface->resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"wl_surface@%d already has a different role",
wl_resource_get_id (surface->resource));
return;
}
meta_wayland_surface_set_window (surface, window);
window->surface = surface;