[mutter] wayland: Introduce XWayland surface role



commit dece49b53dcefc59c199850e543eba99a2e5d27a
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Aug 20 16:54:45 2015 +0800

    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

 src/wayland/meta-wayland-surface.c |   13 +++++++++++++
 src/wayland/meta-wayland-surface.h |    1 +
 src/wayland/meta-xwayland.c        |   10 ++++++++++
 3 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 369d01d..1495686 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -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);
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 7efb65f..3ac2834 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -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
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index cb70724..ba2c191 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]