[mutter] wayland: Introduce MetaWaylandSurfaceRole
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Introduce MetaWaylandSurfaceRole
- Date: Tue, 17 Feb 2015 14:17:01 +0000 (UTC)
commit 945bf626c697dafb59703f46c5ebc821235dbd01
Author: Jonas Ådahl <jadahl gmail com>
Date: Fri Feb 6 16:12:21 2015 +0800
wayland: Introduce MetaWaylandSurfaceRole
Introduce surface roles and use it to ensure a surface never changes
role.
https://bugzilla.gnome.org/show_bug.cgi?id=744452
src/wayland/meta-wayland-data-device.c | 6 ++++
src/wayland/meta-wayland-pointer.c | 9 ++++++
src/wayland/meta-wayland-surface.c | 45 ++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-surface.h | 17 ++++++++++++
4 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index 36675a5..13ea84f 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -410,6 +410,12 @@ data_device_start_drag (struct wl_client *client,
seat->pointer.grab != &seat->pointer.default_grab)
return;
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_DND,
+ resource,
+ WL_DATA_DEVICE_ERROR_ROLE) != 0)
+ return;
+
data_device->current_grab = drag_grab = g_slice_new0 (MetaWaylandDragGrab);
drag_grab->generic.interface = &drag_grab_interface;
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index b74842a..d2227ab 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -786,6 +786,15 @@ pointer_set_cursor (struct wl_client *client,
if (pointer->focus_serial - serial > G_MAXUINT32 / 2)
return;
+ if (surface)
+ {
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_CURSOR,
+ resource,
+ WL_POINTER_ERROR_ROLE) != 0)
+ return;
+ }
+
pointer->hotspot_x = x;
pointer->hotspot_y = y;
set_cursor_surface (pointer, surface);
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 2d806b7..e5960bd 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -63,6 +63,27 @@ typedef struct
struct wl_listener sibling_destroy_listener;
} MetaWaylandSubsurfacePlacementOp;
+int
+meta_wayland_surface_set_role (MetaWaylandSurface *surface,
+ MetaWaylandSurfaceRole role,
+ struct wl_resource *error_resource,
+ uint32_t error_code)
+{
+ if (surface->role == META_WAYLAND_SURFACE_ROLE_NONE ||
+ surface->role == role)
+ {
+ surface->role = role;
+ return 0;
+ }
+ else
+ {
+ wl_resource_post_error (error_resource, error_code,
+ "wl_surface %d already has a different role",
+ wl_resource_get_id (surface->resource));
+ return -1;
+ }
+}
+
static void
surface_set_buffer (MetaWaylandSurface *surface,
MetaWaylandBuffer *buffer)
@@ -979,6 +1000,12 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
return;
}
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_XDG_SURFACE,
+ surface_resource,
+ XDG_SHELL_ERROR_ROLE) != 0)
+ return;
+
surface->xdg_surface = wl_resource_create (client, &xdg_surface_interface, wl_resource_get_version
(resource), id);
wl_resource_set_implementation (surface->xdg_surface, &meta_wayland_xdg_surface_interface, surface,
xdg_surface_destructor);
@@ -1036,6 +1063,12 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
return;
}
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_XDG_POPUP,
+ surface_resource,
+ XDG_SHELL_ERROR_ROLE) != 0)
+ return;
+
surface->xdg_popup = wl_resource_create (client, &xdg_popup_interface, wl_resource_get_version (resource),
id);
wl_resource_set_implementation (surface->xdg_popup, &meta_wayland_xdg_popup_interface, surface,
xdg_popup_destructor);
@@ -1303,6 +1336,12 @@ wl_shell_get_shell_surface (struct wl_client *client,
return;
}
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_WL_SHELL_SURFACE,
+ surface_resource,
+ WL_SHELL_ERROR_ROLE) != 0)
+ return;
+
surface->wl_shell_surface = wl_resource_create (client, &wl_shell_surface_interface,
wl_resource_get_version (resource), id);
wl_resource_set_implementation (surface->wl_shell_surface, &meta_wayland_wl_shell_surface_interface,
surface, wl_shell_surface_destructor);
@@ -1656,6 +1695,12 @@ wl_subcompositor_get_subsurface (struct wl_client *client,
return;
}
+ if (meta_wayland_surface_set_role (surface,
+ META_WAYLAND_SURFACE_ROLE_SUBSURFACE,
+ surface_resource,
+ WL_SHELL_ERROR_ROLE) != 0)
+ return;
+
surface->wl_subsurface = wl_resource_create (client, &wl_subsurface_interface, wl_resource_get_version
(resource), id);
wl_resource_set_implementation (surface->wl_subsurface, &meta_wayland_wl_subsurface_interface, surface,
wl_subsurface_destructor);
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 6288d67..dd8497a 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -36,6 +36,17 @@ struct _MetaWaylandSerial {
uint32_t value;
};
+typedef enum
+{
+ META_WAYLAND_SURFACE_ROLE_NONE,
+ META_WAYLAND_SURFACE_ROLE_SUBSURFACE,
+ META_WAYLAND_SURFACE_ROLE_XDG_SURFACE,
+ META_WAYLAND_SURFACE_ROLE_XDG_POPUP,
+ META_WAYLAND_SURFACE_ROLE_WL_SHELL_SURFACE,
+ META_WAYLAND_SURFACE_ROLE_CURSOR,
+ META_WAYLAND_SURFACE_ROLE_DND,
+} MetaWaylandSurfaceRole;
+
typedef struct
{
/* wl_surface.attach */
@@ -66,6 +77,7 @@ struct _MetaWaylandSurface
struct wl_resource *resource;
MetaWaylandCompositor *compositor;
MetaSurfaceActor *surface_actor;
+ MetaWaylandSurfaceRole role;
MetaWindow *window;
MetaWaylandBuffer *buffer;
struct wl_listener buffer_destroy_listener;
@@ -118,6 +130,11 @@ MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *composit
struct wl_resource *compositor_resource,
guint32 id);
+int meta_wayland_surface_set_role (MetaWaylandSurface *surface,
+ MetaWaylandSurfaceRole role,
+ struct wl_resource *error_resource,
+ uint32_t error_code);
+
void meta_wayland_surface_set_window (MetaWaylandSurface *surface,
MetaWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]