mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
wayland: Simplify slave version management
Slave objects should always be the same version as their parent constructor, except for the generic wl_registry.bind.
This commit is contained in:
parent
c2fe6a18ad
commit
ab53c0e943
@ -125,14 +125,9 @@ meta_wayland_data_source_send_offer (MetaWaylandDataSource *source,
|
||||
offer->source = source;
|
||||
offer->source_destroy_listener.notify = destroy_offer_data_source;
|
||||
|
||||
offer->resource = wl_resource_create (wl_resource_get_client (target),
|
||||
&wl_data_offer_interface,
|
||||
MIN (META_WL_DATA_OFFER_VERSION,
|
||||
wl_resource_get_version (target)), 0);
|
||||
wl_resource_set_implementation (offer->resource, &data_offer_interface,
|
||||
offer, destroy_data_offer);
|
||||
wl_resource_add_destroy_listener (source->resource,
|
||||
&offer->source_destroy_listener);
|
||||
offer->resource = wl_resource_create (wl_resource_get_client (target), &wl_data_offer_interface, wl_resource_get_version (target), 0);
|
||||
wl_resource_set_implementation (offer->resource, &data_offer_interface, offer, destroy_data_offer);
|
||||
wl_resource_add_destroy_listener (source->resource, &offer->source_destroy_listener);
|
||||
|
||||
wl_data_device_send_data_offer (target, offer->resource);
|
||||
|
||||
@ -484,11 +479,8 @@ create_data_source (struct wl_client *client,
|
||||
{
|
||||
MetaWaylandDataSource *source = g_slice_new0 (MetaWaylandDataSource);
|
||||
|
||||
source->resource = wl_resource_create (client, &wl_data_source_interface,
|
||||
MIN (META_WL_DATA_SOURCE_VERSION,
|
||||
wl_resource_get_version (resource)), id);
|
||||
wl_resource_set_implementation (source->resource, &data_source_interface,
|
||||
source, destroy_data_source);
|
||||
source->resource = wl_resource_create (client, &wl_data_source_interface, wl_resource_get_version (resource), id);
|
||||
wl_resource_set_implementation (source->resource, &data_source_interface, source, destroy_data_source);
|
||||
|
||||
wl_array_init (&source->mime_types);
|
||||
}
|
||||
@ -501,8 +493,7 @@ get_data_device (struct wl_client *client,
|
||||
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, &wl_data_device_interface,
|
||||
MIN (META_WL_DATA_DEVICE_VERSION, wl_resource_get_version (manager_resource)), id);
|
||||
cr = wl_resource_create (client, &wl_data_device_interface, wl_resource_get_version (manager_resource), id);
|
||||
wl_resource_set_implementation (cr, &data_device_interface, &seat->data_device, unbind_resource);
|
||||
wl_list_insert (&seat->data_device.resource_list, wl_resource_get_link (cr));
|
||||
}
|
||||
|
@ -641,8 +641,7 @@ meta_wayland_keyboard_create_new_resource (MetaWaylandKeyboard *keyboard,
|
||||
{
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, &wl_keyboard_interface,
|
||||
MIN (META_WL_KEYBOARD_VERSION, wl_resource_get_version (seat_resource)), id);
|
||||
cr = wl_resource_create (client, &wl_keyboard_interface, wl_resource_get_version (seat_resource), id);
|
||||
wl_resource_set_implementation (cr, &keyboard_interface, keyboard, unbind_resource);
|
||||
wl_list_insert (&keyboard->resource_list, wl_resource_get_link (cr));
|
||||
|
||||
|
@ -802,8 +802,7 @@ meta_wayland_pointer_create_new_resource (MetaWaylandPointer *pointer,
|
||||
{
|
||||
struct wl_resource *cr;
|
||||
|
||||
cr = wl_resource_create (client, &wl_pointer_interface,
|
||||
MIN (META_WL_POINTER_VERSION, wl_resource_get_version (seat_resource)), id);
|
||||
cr = wl_resource_create (client, &wl_pointer_interface, wl_resource_get_version (seat_resource), id);
|
||||
wl_resource_set_implementation (cr, &pointer_interface, pointer, unbind_resource);
|
||||
wl_list_insert (&pointer->resource_list, wl_resource_get_link (cr));
|
||||
|
||||
|
@ -696,8 +696,7 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
||||
surface->compositor = compositor;
|
||||
surface->scale = 1;
|
||||
|
||||
surface->resource = wl_resource_create (client, &wl_surface_interface,
|
||||
MIN (META_WL_SURFACE_VERSION, wl_resource_get_version (compositor_resource)), id);
|
||||
surface->resource = wl_resource_create (client, &wl_surface_interface, wl_resource_get_version (compositor_resource), id);
|
||||
wl_resource_set_implementation (surface->resource, &meta_wayland_wl_surface_interface, surface, wl_surface_destructor);
|
||||
|
||||
surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
|
||||
@ -715,7 +714,6 @@ destroy_surface_extension (MetaWaylandSurfaceExtension *extension)
|
||||
|
||||
static gboolean
|
||||
create_surface_extension (MetaWaylandSurfaceExtension *extension,
|
||||
int max_version,
|
||||
const struct wl_interface *interface,
|
||||
const void *implementation,
|
||||
wl_resource_destroy_func_t destructor,
|
||||
@ -729,8 +727,7 @@ create_surface_extension (MetaWaylandSurfaceExtension *extension,
|
||||
return FALSE;
|
||||
|
||||
client = wl_resource_get_client (surface->resource);
|
||||
extension->resource = wl_resource_create (client, interface,
|
||||
MIN (max_version, wl_resource_get_version (master_resource)), id);
|
||||
extension->resource = wl_resource_create (client, interface, wl_resource_get_version (master_resource), id);
|
||||
wl_resource_set_implementation (extension->resource, implementation, surface, destructor);
|
||||
|
||||
return TRUE;
|
||||
@ -1004,7 +1001,6 @@ xdg_shell_get_xdg_surface (struct wl_client *client,
|
||||
MetaWindow *window;
|
||||
|
||||
if (!create_surface_extension (&surface->xdg_surface,
|
||||
META_XDG_SURFACE_VERSION,
|
||||
&xdg_surface_interface,
|
||||
&meta_wayland_xdg_surface_interface,
|
||||
xdg_surface_destructor,
|
||||
@ -1061,7 +1057,6 @@ xdg_shell_get_xdg_popup (struct wl_client *client,
|
||||
return;
|
||||
|
||||
if (!create_surface_extension (&surface->xdg_popup,
|
||||
META_XDG_POPUP_VERSION,
|
||||
&xdg_popup_interface,
|
||||
&meta_wayland_xdg_popup_interface,
|
||||
xdg_popup_destructor,
|
||||
@ -1363,7 +1358,6 @@ wl_shell_get_shell_surface (struct wl_client *client,
|
||||
MetaWindow *window;
|
||||
|
||||
if (!create_surface_extension (&surface->wl_shell_surface,
|
||||
META_WL_SHELL_SURFACE_VERSION,
|
||||
&wl_shell_surface_interface,
|
||||
&meta_wayland_wl_shell_surface_interface,
|
||||
wl_shell_surface_destructor,
|
||||
@ -1445,7 +1439,6 @@ get_gtk_surface (struct wl_client *client,
|
||||
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
||||
|
||||
if (!create_surface_extension (&surface->gtk_surface,
|
||||
META_GTK_SURFACE_VERSION,
|
||||
>k_surface_interface,
|
||||
&meta_wayland_gtk_surface_interface,
|
||||
gtk_surface_destructor,
|
||||
@ -1719,7 +1712,6 @@ wl_subcompositor_get_subsurface (struct wl_client *client,
|
||||
MetaWaylandSurface *parent = wl_resource_get_user_data (parent_resource);
|
||||
|
||||
if (!create_surface_extension (&surface->subsurface,
|
||||
META_GTK_SURFACE_VERSION,
|
||||
&wl_subsurface_interface,
|
||||
&meta_wayland_subsurface_interface,
|
||||
wl_subsurface_destructor,
|
||||
|
@ -554,8 +554,7 @@ meta_wayland_touch_create_new_resource (MetaWaylandTouch *touch,
|
||||
return;
|
||||
}
|
||||
|
||||
cr = wl_resource_create (client, &wl_touch_interface,
|
||||
MIN (META_WL_TOUCH_VERSION, wl_resource_get_version (seat_resource)), id);
|
||||
cr = wl_resource_create (client, &wl_touch_interface, wl_resource_get_version (seat_resource), id);
|
||||
wl_resource_set_implementation (cr, &touch_interface, touch, unbind_resource);
|
||||
wl_list_insert (&touch->resource_list, wl_resource_get_link (cr));
|
||||
}
|
||||
|
@ -45,19 +45,4 @@
|
||||
#define META_GTK_SHELL_VERSION 1
|
||||
#define META_WL_SUBCOMPOSITOR_VERSION 1
|
||||
|
||||
/* Slave objects (version inherited from a master object) */
|
||||
#define META_WL_DATA_OFFER_VERSION 1 /* from wl_data_device */
|
||||
#define META_WL_DATA_SOURCE_VERSION 1 /* from wl_data_device */
|
||||
#define META_WL_DATA_DEVICE_VERSION 1 /* from wl_data_device_manager */
|
||||
#define META_WL_SURFACE_VERSION 3 /* from wl_compositor */
|
||||
#define META_WL_POINTER_VERSION 3 /* from wl_seat */
|
||||
#define META_WL_KEYBOARD_VERSION 4 /* from wl_seat */
|
||||
#define META_WL_TOUCH_VERSION 3 /* from wl_seat */
|
||||
#define META_WL_REGION_VERSION 1 /* from wl_compositor */
|
||||
#define META_XDG_SURFACE_VERSION 1 /* from xdg_shell */
|
||||
#define META_XDG_POPUP_VERSION 1 /* from xdg_shell */
|
||||
#define META_WL_SHELL_SURFACE_VERSION 1 /* from wl_shell */
|
||||
#define META_GTK_SURFACE_VERSION 1 /* from gtk_shell */
|
||||
#define META_WL_SUBSURFACE_VERSION 1 /* from wl_subcompositor */
|
||||
|
||||
#endif
|
||||
|
@ -257,20 +257,14 @@ meta_wayland_region_resource_destroy_cb (struct wl_resource *resource)
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_compositor_create_region (struct wl_client *wayland_client,
|
||||
meta_wayland_compositor_create_region (struct wl_client *client,
|
||||
struct wl_resource *compositor_resource,
|
||||
uint32_t id)
|
||||
{
|
||||
MetaWaylandRegion *region = g_slice_new0 (MetaWaylandRegion);
|
||||
|
||||
region->resource = wl_resource_create (wayland_client,
|
||||
&wl_region_interface,
|
||||
MIN (META_WL_REGION_VERSION,
|
||||
wl_resource_get_version (compositor_resource)),
|
||||
id);
|
||||
wl_resource_set_implementation (region->resource,
|
||||
&meta_wayland_region_interface, region,
|
||||
meta_wayland_region_resource_destroy_cb);
|
||||
region->resource = wl_resource_create (client, &wl_region_interface, wl_resource_get_version (compositor_resource), id);
|
||||
wl_resource_set_implementation (region->resource, &meta_wayland_region_interface, region, meta_wayland_region_resource_destroy_cb);
|
||||
|
||||
region->region = cairo_region_create ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user