2013-08-30 16:26:18 +00:00
|
|
|
/*
|
|
|
|
* Wayland Support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012,2013 Intel Corporation
|
|
|
|
* 2013 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include <clutter/wayland/clutter-wayland-compositor.h>
|
|
|
|
#include <clutter/wayland/clutter-wayland-surface.h>
|
2013-09-03 10:00:29 +00:00
|
|
|
#include <cogl/cogl-wayland-server.h>
|
2013-08-30 16:26:18 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <wayland-server.h>
|
2013-08-30 07:40:36 +00:00
|
|
|
#include "gtk-shell-server-protocol.h"
|
2013-11-08 22:05:07 +00:00
|
|
|
#include "xdg-shell-server-protocol.h"
|
2013-08-30 16:26:18 +00:00
|
|
|
|
|
|
|
#include "meta-wayland-private.h"
|
|
|
|
#include "meta-xwayland-private.h"
|
|
|
|
#include "meta-wayland-stage.h"
|
2014-01-22 14:16:56 +00:00
|
|
|
#include "meta-surface-actor.h"
|
2013-08-30 16:26:18 +00:00
|
|
|
#include "meta-wayland-seat.h"
|
|
|
|
#include "meta-wayland-keyboard.h"
|
|
|
|
#include "meta-wayland-pointer.h"
|
|
|
|
#include "meta-wayland-data-device.h"
|
|
|
|
#include "meta-cursor-tracker-private.h"
|
|
|
|
#include "display-private.h"
|
|
|
|
#include "window-private.h"
|
|
|
|
#include <meta/types.h>
|
|
|
|
#include <meta/main.h>
|
|
|
|
#include "frame.h"
|
|
|
|
#include "meta-idle-monitor-private.h"
|
|
|
|
#include "monitor-private.h"
|
|
|
|
|
2014-01-12 22:24:00 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
META_WAYLAND_SUBSURFACE_PLACEMENT_ABOVE,
|
|
|
|
META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW
|
|
|
|
} MetaWaylandSubsurfacePlacement;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
MetaWaylandSubsurfacePlacement placement;
|
|
|
|
MetaWaylandSurface *sibling;
|
|
|
|
struct wl_listener sibling_destroy_listener;
|
|
|
|
} MetaWaylandSubsurfacePlacementOp;
|
|
|
|
|
2014-02-03 23:36:46 +00:00
|
|
|
static void
|
|
|
|
surface_handle_buffer_destroy (struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (listener, surface, buffer_destroy_listener);
|
|
|
|
|
|
|
|
wl_resource_post_error (surface->resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"Destroyed buffer while it was attached to the surface");
|
|
|
|
surface->buffer = NULL;
|
|
|
|
wl_list_remove (&surface->buffer_destroy_listener.link);
|
|
|
|
}
|
|
|
|
|
2014-02-01 22:45:51 +00:00
|
|
|
static void
|
|
|
|
surface_set_buffer (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandBuffer *buffer)
|
|
|
|
{
|
|
|
|
if (surface->buffer == buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (surface->buffer)
|
2014-02-03 23:36:46 +00:00
|
|
|
{
|
|
|
|
meta_wayland_buffer_unref (surface->buffer);
|
|
|
|
wl_list_remove (&surface->buffer_destroy_listener.link);
|
|
|
|
}
|
2014-02-01 22:45:51 +00:00
|
|
|
|
|
|
|
surface->buffer = buffer;
|
|
|
|
|
|
|
|
if (surface->buffer)
|
2014-02-03 23:36:46 +00:00
|
|
|
{
|
|
|
|
meta_wayland_buffer_ref (surface->buffer);
|
|
|
|
wl_signal_add (&surface->buffer->destroy_signal, &surface->buffer_destroy_listener);
|
|
|
|
}
|
2014-02-01 22:45:51 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
static void
|
|
|
|
surface_process_damage (MetaWaylandSurface *surface,
|
|
|
|
cairo_region_t *region)
|
|
|
|
{
|
2013-11-25 22:40:21 +00:00
|
|
|
int i, n_rectangles = cairo_region_num_rectangles (region);
|
2013-09-03 10:00:29 +00:00
|
|
|
|
2013-11-25 22:40:21 +00:00
|
|
|
for (i = 0; i < n_rectangles; i++)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-25 22:40:21 +00:00
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
cairo_region_get_rectangle (region, i, &rect);
|
2014-01-22 14:16:56 +00:00
|
|
|
meta_surface_actor_damage_area (surface->surface_actor,
|
2014-02-05 19:06:32 +00:00
|
|
|
rect.x, rect.y, rect.width, rect.height);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-31 16:38:37 +00:00
|
|
|
meta_wayland_surface_destroy (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2014-01-31 16:38:37 +00:00
|
|
|
wl_resource_destroy (resource);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-31 16:38:37 +00:00
|
|
|
meta_wayland_surface_attach (struct wl_client *client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *buffer_resource,
|
2013-09-03 10:00:29 +00:00
|
|
|
gint32 dx, gint32 dy)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface =
|
2014-01-31 16:38:37 +00:00
|
|
|
wl_resource_get_user_data (surface_resource);
|
2013-08-30 16:26:18 +00:00
|
|
|
MetaWaylandBuffer *buffer;
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
2014-01-31 16:38:37 +00:00
|
|
|
if (buffer_resource)
|
|
|
|
buffer = meta_wayland_buffer_from_resource (buffer_resource);
|
2013-08-30 16:26:18 +00:00
|
|
|
else
|
|
|
|
buffer = NULL;
|
|
|
|
|
|
|
|
/* Attach without commit in between does not send wl_buffer.release */
|
|
|
|
if (surface->pending.buffer)
|
|
|
|
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
|
|
|
|
|
2013-09-03 10:00:29 +00:00
|
|
|
surface->pending.dx = dx;
|
|
|
|
surface->pending.dy = dy;
|
2013-08-30 16:26:18 +00:00
|
|
|
surface->pending.buffer = buffer;
|
|
|
|
surface->pending.newly_attached = TRUE;
|
|
|
|
|
|
|
|
if (buffer)
|
|
|
|
wl_signal_add (&buffer->destroy_signal,
|
|
|
|
&surface->pending.buffer_destroy_listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_damage (struct wl_client *client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
gint32 x,
|
|
|
|
gint32 y,
|
|
|
|
gint32 width,
|
|
|
|
gint32 height)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
cairo_rectangle_int_t rectangle = { x, y, width, height };
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cairo_region_union_rectangle (surface->pending.damage, &rectangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_frame_callback (struct wl_resource *callback_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandFrameCallback *callback =
|
|
|
|
wl_resource_get_user_data (callback_resource);
|
|
|
|
|
|
|
|
wl_list_remove (&callback->link);
|
|
|
|
g_slice_free (MetaWaylandFrameCallback, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_frame (struct wl_client *client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
guint32 callback_id)
|
|
|
|
{
|
|
|
|
MetaWaylandFrameCallback *callback;
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
callback = g_slice_new0 (MetaWaylandFrameCallback);
|
|
|
|
callback->compositor = surface->compositor;
|
2014-01-31 21:40:40 +00:00
|
|
|
callback->resource = wl_resource_create (client, &wl_callback_interface, META_WL_CALLBACK_VERSION, callback_id);
|
|
|
|
wl_resource_set_implementation (callback->resource, NULL, callback, destroy_frame_callback);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
|
|
|
wl_list_insert (surface->pending.frame_callback_list.prev, &callback->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_set_opaque_region (struct wl_client *client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *region_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_pointer (&surface->pending.opaque_region, cairo_region_destroy);
|
2013-11-05 23:00:48 +00:00
|
|
|
if (region_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
|
|
|
surface->pending.opaque_region = cairo_region_copy (region->region);
|
|
|
|
}
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_set_input_region (struct wl_client *client,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *region_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_clear_pointer (&surface->pending.input_region, cairo_region_destroy);
|
2013-11-05 23:00:48 +00:00
|
|
|
if (region_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandRegion *region = wl_resource_get_user_data (region_resource);
|
|
|
|
surface->pending.input_region = cairo_region_copy (region->region);
|
|
|
|
}
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
empty_region (cairo_region_t *region)
|
|
|
|
{
|
|
|
|
cairo_rectangle_int_t rectangle = { 0, 0, 0, 0 };
|
|
|
|
cairo_region_intersect_rectangle (region, &rectangle);
|
|
|
|
}
|
|
|
|
|
2013-11-19 17:47:50 +00:00
|
|
|
static void
|
|
|
|
ensure_buffer_texture (MetaWaylandBuffer *buffer)
|
|
|
|
{
|
|
|
|
CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
|
|
|
CoglError *catch_error = NULL;
|
|
|
|
CoglTexture *texture;
|
|
|
|
|
2013-11-25 21:03:25 +00:00
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
|
2013-11-19 17:47:50 +00:00
|
|
|
texture = COGL_TEXTURE (cogl_wayland_texture_2d_new_from_buffer (ctx,
|
|
|
|
buffer->resource,
|
|
|
|
&catch_error));
|
|
|
|
if (!texture)
|
|
|
|
{
|
|
|
|
cogl_error_free (catch_error);
|
|
|
|
meta_warning ("Could not import pending buffer, ignoring commit\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer->texture = texture;
|
|
|
|
buffer->width = cogl_texture_get_width (texture);
|
|
|
|
buffer->height = cogl_texture_get_height (texture);
|
|
|
|
}
|
|
|
|
|
2013-11-25 20:50:05 +00:00
|
|
|
static void
|
2014-02-01 21:24:43 +00:00
|
|
|
cursor_surface_commit (MetaWaylandSurface *surface,
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
MetaWaylandDoubleBufferedState *pending,
|
|
|
|
gboolean buffer_changed)
|
2013-11-25 20:50:05 +00:00
|
|
|
{
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
if (buffer_changed)
|
2014-02-01 22:55:03 +00:00
|
|
|
meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
|
2013-11-25 20:50:05 +00:00
|
|
|
}
|
|
|
|
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
static void
|
2014-02-01 21:24:43 +00:00
|
|
|
actor_surface_commit (MetaWaylandSurface *surface,
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
MetaWaylandDoubleBufferedState *pending,
|
|
|
|
gboolean buffer_changed)
|
2013-11-25 20:50:05 +00:00
|
|
|
{
|
2013-11-22 20:24:06 +00:00
|
|
|
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
2014-01-13 22:31:25 +00:00
|
|
|
MetaWaylandBuffer *buffer = pending->buffer;
|
2013-11-25 20:50:05 +00:00
|
|
|
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
if (buffer_changed)
|
2013-11-25 20:50:05 +00:00
|
|
|
{
|
|
|
|
ensure_buffer_texture (buffer);
|
2014-01-22 14:16:56 +00:00
|
|
|
meta_surface_actor_attach_wayland_buffer (surface_actor, buffer);
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
2013-11-25 20:50:05 +00:00
|
|
|
|
2014-01-13 22:31:25 +00:00
|
|
|
surface_process_damage (surface, pending->damage);
|
2013-11-26 17:32:41 +00:00
|
|
|
|
2014-01-13 22:31:25 +00:00
|
|
|
if (pending->opaque_region)
|
|
|
|
meta_surface_actor_set_opaque_region (surface_actor, pending->opaque_region);
|
|
|
|
if (pending->input_region)
|
|
|
|
meta_surface_actor_set_input_region (surface_actor, pending->input_region);
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-01 21:24:43 +00:00
|
|
|
toplevel_surface_commit (MetaWaylandSurface *surface,
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
MetaWaylandDoubleBufferedState *pending,
|
|
|
|
gboolean buffer_changed)
|
2013-11-25 21:26:02 +00:00
|
|
|
{
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
actor_surface_commit (surface, pending, buffer_changed);
|
|
|
|
|
|
|
|
if (buffer_changed)
|
2013-11-25 21:26:02 +00:00
|
|
|
{
|
|
|
|
MetaWindow *window = surface->window;
|
2014-02-01 21:24:43 +00:00
|
|
|
MetaWaylandBuffer *buffer = pending->buffer;
|
2013-11-25 20:50:05 +00:00
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
meta_window_set_surface_mapped (window, buffer != NULL);
|
2013-11-25 22:35:44 +00:00
|
|
|
/* We resize X based surfaces according to X events */
|
|
|
|
if (buffer != NULL && window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
|
2013-11-25 20:50:05 +00:00
|
|
|
{
|
2013-11-25 22:35:44 +00:00
|
|
|
int new_width;
|
|
|
|
int new_height;
|
|
|
|
|
2014-02-01 22:45:51 +00:00
|
|
|
new_width = surface->buffer->width;
|
|
|
|
new_height = surface->buffer->height;
|
2013-11-25 22:35:44 +00:00
|
|
|
if (new_width != window->rect.width ||
|
|
|
|
new_height != window->rect.height ||
|
2014-02-01 21:24:43 +00:00
|
|
|
pending->dx != 0 ||
|
|
|
|
pending->dy != 0)
|
|
|
|
meta_window_move_resize_wayland (window, new_width, new_height, pending->dx, pending->dy);
|
2013-11-25 20:50:05 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-09 23:23:07 +00:00
|
|
|
|
2014-02-10 19:16:06 +00:00
|
|
|
if (pending->frame_extents_changed)
|
|
|
|
meta_window_set_custom_frame_extents (surface->window, &pending->frame_extents);
|
|
|
|
|
2014-02-09 23:23:07 +00:00
|
|
|
if (pending->maximized.changed)
|
|
|
|
{
|
|
|
|
if (pending->maximized.value)
|
|
|
|
meta_window_maximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
|
|
|
|
else
|
|
|
|
meta_window_unmaximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pending->fullscreen.changed)
|
|
|
|
{
|
|
|
|
if (pending->fullscreen.value)
|
|
|
|
meta_window_make_fullscreen (surface->window);
|
|
|
|
else
|
|
|
|
meta_window_unmake_fullscreen (surface->window);
|
|
|
|
}
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
2013-11-25 20:50:05 +00:00
|
|
|
|
2014-01-13 22:31:25 +00:00
|
|
|
static void
|
|
|
|
surface_handle_pending_buffer_destroy (struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
MetaWaylandDoubleBufferedState *state =
|
|
|
|
wl_container_of (listener, state, buffer_destroy_listener);
|
|
|
|
|
|
|
|
state->buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
double_buffered_state_init (MetaWaylandDoubleBufferedState *state)
|
|
|
|
{
|
|
|
|
state->newly_attached = FALSE;
|
|
|
|
state->buffer = NULL;
|
|
|
|
state->dx = 0;
|
|
|
|
state->dy = 0;
|
|
|
|
|
|
|
|
state->damage = cairo_region_create ();
|
|
|
|
state->buffer_destroy_listener.notify =
|
|
|
|
surface_handle_pending_buffer_destroy;
|
|
|
|
wl_list_init (&state->frame_callback_list);
|
2014-02-09 23:23:07 +00:00
|
|
|
|
2014-02-10 19:16:06 +00:00
|
|
|
state->frame_extents_changed = FALSE;
|
2014-02-09 23:23:07 +00:00
|
|
|
state->maximized.changed = FALSE;
|
|
|
|
state->fullscreen.changed = FALSE;
|
2014-01-13 22:31:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
double_buffered_state_destroy (MetaWaylandDoubleBufferedState *state)
|
|
|
|
{
|
|
|
|
MetaWaylandFrameCallback *cb, *next;
|
|
|
|
|
|
|
|
g_clear_pointer (&state->damage, cairo_region_destroy);
|
|
|
|
g_clear_pointer (&state->input_region, cairo_region_destroy);
|
|
|
|
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
|
|
|
|
|
|
|
|
if (state->buffer)
|
|
|
|
wl_list_remove (&state->buffer_destroy_listener.link);
|
|
|
|
wl_list_for_each_safe (cb, next, &state->frame_callback_list, link)
|
|
|
|
wl_resource_destroy (cb->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
double_buffered_state_reset (MetaWaylandDoubleBufferedState *state)
|
|
|
|
{
|
|
|
|
double_buffered_state_destroy (state);
|
|
|
|
double_buffered_state_init (state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
move_double_buffered_state (MetaWaylandDoubleBufferedState *from,
|
|
|
|
MetaWaylandDoubleBufferedState *to)
|
|
|
|
{
|
|
|
|
if (from->buffer)
|
|
|
|
wl_list_remove (&from->buffer_destroy_listener.link);
|
|
|
|
|
|
|
|
to->newly_attached = from->newly_attached;
|
|
|
|
from->newly_attached = FALSE;
|
|
|
|
|
|
|
|
to->buffer = from->buffer;
|
|
|
|
from->buffer = NULL;
|
|
|
|
if (to->buffer)
|
|
|
|
wl_signal_add (&to->buffer->destroy_signal, &to->buffer_destroy_listener);
|
|
|
|
|
|
|
|
to->dx = from->dx;
|
|
|
|
to->dy = from->dy;
|
|
|
|
from->dx = from->dy = 0;
|
|
|
|
|
|
|
|
empty_region (to->damage);
|
|
|
|
cairo_region_union (to->damage, from->damage);
|
|
|
|
empty_region (from->damage);
|
|
|
|
|
|
|
|
g_clear_pointer (&to->input_region, cairo_region_destroy);
|
|
|
|
g_clear_pointer (&to->opaque_region, cairo_region_destroy);
|
|
|
|
to->input_region = from->input_region;
|
|
|
|
to->opaque_region = from->opaque_region;
|
|
|
|
from->input_region = from->opaque_region = NULL;
|
|
|
|
|
|
|
|
wl_list_init (&to->frame_callback_list);
|
|
|
|
wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
|
|
|
|
wl_list_init (&from->frame_callback_list);
|
|
|
|
}
|
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
static void
|
2014-02-01 21:24:43 +00:00
|
|
|
subsurface_surface_commit (MetaWaylandSurface *surface,
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
MetaWaylandDoubleBufferedState *pending,
|
|
|
|
gboolean buffer_changed)
|
2013-11-25 21:26:02 +00:00
|
|
|
{
|
2014-01-13 22:31:25 +00:00
|
|
|
/*
|
|
|
|
* If the sub-surface is in synchronous mode, post-pone the commit of its
|
|
|
|
* state until the sub-surface parent commits.
|
|
|
|
*
|
|
|
|
* This is done by moving the various states (damage, input region, buffer
|
|
|
|
* etc.) from the buffered state pending commit to the sub-surface's pending
|
|
|
|
* buffered state.
|
|
|
|
*
|
|
|
|
* The sub-surface's pending buffered state will be committed to the
|
|
|
|
* associated surface when its parent surface is committed, or if the user
|
|
|
|
* issues a wl_subsurface.set_desync request.
|
|
|
|
*/
|
|
|
|
if (surface->sub.synchronous)
|
|
|
|
{
|
2014-02-01 21:24:43 +00:00
|
|
|
move_double_buffered_state (pending, &surface->sub.pending_surface_state);
|
2014-01-13 22:31:25 +00:00
|
|
|
}
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
else
|
2013-11-25 21:26:02 +00:00
|
|
|
{
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
actor_surface_commit (surface, pending, buffer_changed);
|
2013-11-25 21:26:02 +00:00
|
|
|
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
if (buffer_changed)
|
|
|
|
{
|
|
|
|
MetaSurfaceActor *surface_actor = surface->surface_actor;
|
|
|
|
MetaWaylandBuffer *buffer = pending->buffer;
|
|
|
|
float x, y;
|
|
|
|
|
|
|
|
if (buffer != NULL)
|
|
|
|
clutter_actor_show (CLUTTER_ACTOR (surface_actor));
|
|
|
|
else
|
|
|
|
clutter_actor_hide (CLUTTER_ACTOR (surface_actor));
|
|
|
|
|
|
|
|
clutter_actor_get_position (CLUTTER_ACTOR (surface_actor), &x, &y);
|
|
|
|
x += pending->dx;
|
|
|
|
y += pending->dy;
|
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR (surface_actor), x, y);
|
|
|
|
}
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
2013-11-25 20:50:05 +00:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:17:29 +00:00
|
|
|
static void
|
2014-02-01 21:19:47 +00:00
|
|
|
subsurface_parent_surface_committed (MetaWaylandSurface *surface);
|
2014-01-13 22:31:25 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
parent_surface_committed (gpointer data, gpointer user_data)
|
|
|
|
{
|
2014-02-01 21:19:47 +00:00
|
|
|
subsurface_parent_surface_committed (data);
|
2014-01-13 22:31:25 +00:00
|
|
|
}
|
2014-01-12 22:17:29 +00:00
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
static void
|
2014-02-01 21:24:43 +00:00
|
|
|
commit_double_buffered_state (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandDoubleBufferedState *pending)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2014-02-01 21:24:43 +00:00
|
|
|
MetaWaylandCompositor *compositor = surface->compositor;
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
gboolean buffer_changed = FALSE;
|
|
|
|
|
|
|
|
/* wl_surface.attach */
|
2014-02-01 22:45:51 +00:00
|
|
|
if (pending->newly_attached && surface->buffer != pending->buffer)
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
{
|
2014-02-01 22:45:51 +00:00
|
|
|
surface_set_buffer (surface, pending->buffer);
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
buffer_changed = TRUE;
|
|
|
|
}
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2014-02-01 22:55:03 +00:00
|
|
|
if (surface == compositor->seat->cursor_surface)
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
cursor_surface_commit (surface, pending, buffer_changed);
|
2013-09-03 10:00:29 +00:00
|
|
|
else if (surface->window)
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
toplevel_surface_commit (surface, pending, buffer_changed);
|
2013-11-25 21:26:02 +00:00
|
|
|
else if (surface->subsurface.resource)
|
wayland-surface: Attach the buffer to a surface, even if it doesn't have a role
Currently, set_cursor isn't properly working. Often, the requests look
like this:
cursor_surface = wl_compositor.create_surface()
cursor_buffer = create_cursor_buffer()
cursor_surface.attach(cursor_buffer, 0, 0)
cursor_surface.commit()
wl_pointer.set_cursor(cursor_surface, 7, 14)
But since the surface doesn't "have a role" when the commit comes in,
we ignore it, and don't do anything with the pending buffer. When
set_cursor is called, however, we don't immediately update anything
since it doesn't have a buffer.
This effectively means that set_cursor has unpredictable side effects.
Weston's toy toolkit reuses the same surface for every buffer, so it
only fails the first time. In clients that use a new surface for every
cursor sprite, the cursor is effectively invisible.
To solve this, change the code to always set the buffer for a surface,
even if it doesn't have any real role.
2014-02-01 22:05:14 +00:00
|
|
|
subsurface_surface_commit (surface, pending, buffer_changed);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2014-01-12 22:17:29 +00:00
|
|
|
g_list_foreach (surface->subsurfaces,
|
2014-01-13 22:31:25 +00:00
|
|
|
parent_surface_committed,
|
2014-01-12 22:17:29 +00:00
|
|
|
NULL);
|
|
|
|
|
2014-02-01 21:24:43 +00:00
|
|
|
if (pending->buffer)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2014-02-01 21:24:43 +00:00
|
|
|
wl_list_remove (&pending->buffer_destroy_listener.link);
|
|
|
|
pending->buffer = NULL;
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
2013-11-15 02:55:37 +00:00
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
/* wl_surface.frame */
|
2014-02-01 21:24:43 +00:00
|
|
|
wl_list_insert_list (&compositor->frame_callbacks, &pending->frame_callback_list);
|
|
|
|
wl_list_init (&pending->frame_callback_list);
|
|
|
|
|
|
|
|
double_buffered_state_reset (pending);
|
|
|
|
}
|
2014-01-13 22:31:25 +00:00
|
|
|
|
2014-02-01 21:24:43 +00:00
|
|
|
static void
|
|
|
|
meta_wayland_surface_commit (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
|
|
|
|
|
|
|
/* X11 unmanaged window */
|
|
|
|
if (!surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
commit_double_buffered_state (surface, &surface->pending);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_set_buffer_transform (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t transform)
|
|
|
|
{
|
|
|
|
g_warning ("TODO: support set_buffer_transform request");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_wayland_surface_set_buffer_scale (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int scale)
|
|
|
|
{
|
2013-11-19 18:00:34 +00:00
|
|
|
if (scale != 1)
|
|
|
|
g_warning ("TODO: support set_buffer_scale request");
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct wl_surface_interface meta_wayland_surface_interface = {
|
|
|
|
meta_wayland_surface_destroy,
|
|
|
|
meta_wayland_surface_attach,
|
|
|
|
meta_wayland_surface_damage,
|
|
|
|
meta_wayland_surface_frame,
|
|
|
|
meta_wayland_surface_set_opaque_region,
|
|
|
|
meta_wayland_surface_set_input_region,
|
|
|
|
meta_wayland_surface_commit,
|
|
|
|
meta_wayland_surface_set_buffer_transform,
|
|
|
|
meta_wayland_surface_set_buffer_scale
|
|
|
|
};
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
2013-08-30 16:26:18 +00:00
|
|
|
meta_wayland_surface_free (MetaWaylandSurface *surface)
|
|
|
|
{
|
|
|
|
MetaWaylandCompositor *compositor = surface->compositor;
|
|
|
|
|
|
|
|
compositor->surfaces = g_list_remove (compositor->surfaces, surface);
|
|
|
|
|
2014-02-01 22:45:51 +00:00
|
|
|
surface_set_buffer (surface, NULL);
|
2014-01-13 22:31:25 +00:00
|
|
|
double_buffered_state_destroy (&surface->pending);
|
2013-11-26 18:04:37 +00:00
|
|
|
g_object_unref (surface->surface_actor);
|
2013-08-30 16:26:18 +00:00
|
|
|
if (surface->resource)
|
|
|
|
wl_resource_set_user_data (surface->resource, NULL);
|
|
|
|
g_slice_free (MetaWaylandSurface, surface);
|
2014-02-01 21:29:36 +00:00
|
|
|
|
|
|
|
meta_wayland_compositor_repick (compositor);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
|
|
|
unparent_actor (MetaWaylandSurface *surface)
|
|
|
|
{
|
|
|
|
ClutterActor *parent_actor;
|
|
|
|
|
|
|
|
parent_actor = clutter_actor_get_parent (CLUTTER_ACTOR (surface->surface_actor));
|
|
|
|
clutter_actor_remove_child (parent_actor, CLUTTER_ACTOR (surface->surface_actor));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_window (MetaWaylandSurface *surface)
|
|
|
|
{
|
|
|
|
MetaDisplay *display = meta_get_display ();
|
|
|
|
guint32 timestamp = meta_display_get_current_time_roundtrip (display);
|
|
|
|
|
|
|
|
/* Remove our actor from the parent, so it doesn't get destroyed when
|
|
|
|
* the MetaWindowActor is destroyed. */
|
|
|
|
unparent_actor (surface);
|
|
|
|
|
|
|
|
g_assert (surface->window != NULL);
|
|
|
|
meta_window_unmanage (surface->window, timestamp);
|
|
|
|
surface->window = NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
static void
|
|
|
|
meta_wayland_surface_resource_destroy_cb (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
|
|
|
|
|
|
|
|
/* There are four cases here:
|
|
|
|
- An X11 unmanaged window -> surface is NULL, nothing to do
|
|
|
|
- An X11 unmanaged window, but we got the wayland event first ->
|
|
|
|
just clear the resource pointer
|
|
|
|
- A wayland surface without window (destroyed before set_toplevel) ->
|
|
|
|
need to free the surface itself
|
|
|
|
- A wayland window -> need to unmanage
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (surface)
|
|
|
|
{
|
|
|
|
surface->resource = NULL;
|
|
|
|
|
|
|
|
/* NB: If the surface corresponds to an X window then we will be
|
|
|
|
* sure to free the MetaWindow according to some X event. */
|
2013-11-26 18:04:37 +00:00
|
|
|
if (surface->window && surface->window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND)
|
|
|
|
destroy_window (surface);
|
|
|
|
|
|
|
|
meta_wayland_surface_free (surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaWaylandSurface *
|
|
|
|
meta_wayland_surface_create (MetaWaylandCompositor *compositor,
|
2014-01-31 16:38:37 +00:00
|
|
|
struct wl_client *client,
|
2013-08-30 16:26:18 +00:00
|
|
|
guint32 id,
|
|
|
|
guint32 version)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = g_slice_new0 (MetaWaylandSurface);
|
|
|
|
|
|
|
|
surface->compositor = compositor;
|
|
|
|
|
2014-01-31 16:38:37 +00:00
|
|
|
surface->resource = wl_resource_create (client, &wl_surface_interface, version, id);
|
2013-08-30 16:26:18 +00:00
|
|
|
wl_resource_set_implementation (surface->resource, &meta_wayland_surface_interface, surface,
|
|
|
|
meta_wayland_surface_resource_destroy_cb);
|
|
|
|
|
2014-01-13 22:31:25 +00:00
|
|
|
double_buffered_state_init (&surface->pending);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2014-02-03 23:36:46 +00:00
|
|
|
surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
|
|
|
|
|
2014-01-22 14:16:56 +00:00
|
|
|
surface->surface_actor = g_object_ref_sink (meta_surface_actor_new ());
|
2013-08-30 16:26:18 +00:00
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
static void
|
2013-11-26 18:04:37 +00:00
|
|
|
destroy_surface_extension (MetaWaylandSurfaceExtension *extension)
|
2013-11-19 22:32:59 +00:00
|
|
|
{
|
|
|
|
wl_list_remove (&extension->surface_destroy_listener.link);
|
|
|
|
extension->resource = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
extension_handle_surface_destroy (struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *extension = wl_container_of (listener, extension, surface_destroy_listener);
|
|
|
|
wl_resource_destroy (extension->resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
get_resource_version (struct wl_resource *master_resource,
|
|
|
|
int max_version)
|
|
|
|
{
|
|
|
|
return MIN (max_version, wl_resource_get_version (master_resource));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
create_surface_extension (MetaWaylandSurfaceExtension *extension,
|
|
|
|
struct wl_client *client,
|
|
|
|
struct wl_resource *master_resource,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
guint32 id,
|
|
|
|
int max_version,
|
|
|
|
const struct wl_interface *interface,
|
2013-11-26 18:04:37 +00:00
|
|
|
const void *implementation,
|
|
|
|
wl_resource_destroy_func_t destructor)
|
2013-11-19 22:32:59 +00:00
|
|
|
{
|
|
|
|
if (extension->resource != NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-01-31 21:40:40 +00:00
|
|
|
extension->resource = wl_resource_create (client, interface, get_resource_version (master_resource, max_version), id);
|
|
|
|
wl_resource_set_implementation (extension->resource, implementation, extension, destructor);
|
2013-11-19 22:32:59 +00:00
|
|
|
|
|
|
|
extension->surface_destroy_listener.notify = extension_handle_surface_destroy;
|
|
|
|
wl_resource_add_destroy_listener (surface_resource, &extension->surface_destroy_listener);
|
2014-01-31 21:40:40 +00:00
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-02-15 15:02:04 +00:00
|
|
|
static void
|
|
|
|
xdg_shell_use_unstable_version (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t version)
|
|
|
|
{
|
2014-02-15 15:02:48 +00:00
|
|
|
if (version != XDG_SHELL_VERSION_CURRENT)
|
2014-02-15 15:02:04 +00:00
|
|
|
g_warning ("Bad xdg_shell version: %d", version);
|
|
|
|
}
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
|
|
|
xdg_surface_destructor (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
|
|
|
|
|
|
|
destroy_window (surface);
|
|
|
|
destroy_surface_extension (xdg_surface);
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_destroy (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
2013-11-20 04:33:46 +00:00
|
|
|
wl_resource_destroy (resource);
|
2013-11-08 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_surface_set_transient_for (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
2013-11-21 18:09:13 +00:00
|
|
|
struct wl_resource *parent_resource)
|
2013-11-08 22:05:07 +00:00
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-11-21 18:09:13 +00:00
|
|
|
MetaWindow *transient_for = NULL;
|
2013-11-08 22:05:07 +00:00
|
|
|
|
2013-11-21 18:09:13 +00:00
|
|
|
if (parent_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *parent_surface = wl_resource_get_user_data (parent_resource);
|
|
|
|
transient_for = parent_surface->window;
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_window_set_transient_for (surface->window, transient_for);
|
2013-11-08 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 22:29:35 +00:00
|
|
|
static void
|
|
|
|
xdg_surface_set_margin (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t left_margin,
|
|
|
|
int32_t right_margin,
|
|
|
|
int32_t top_margin,
|
|
|
|
int32_t bottom_margin)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
|
|
|
|
2014-02-10 19:16:06 +00:00
|
|
|
surface->pending.frame_extents_changed = TRUE;
|
|
|
|
surface->pending.frame_extents.left = left_margin;
|
|
|
|
surface->pending.frame_extents.right = right_margin;
|
|
|
|
surface->pending.frame_extents.top = top_margin;
|
|
|
|
surface->pending.frame_extents.bottom = bottom_margin;
|
2014-02-07 22:29:35 +00:00
|
|
|
}
|
|
|
|
|
2013-11-08 22:05:07 +00:00
|
|
|
static void
|
|
|
|
xdg_surface_set_title (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *title)
|
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-11-08 22:05:07 +00:00
|
|
|
|
2013-11-19 21:04:14 +00:00
|
|
|
meta_window_set_title (surface->window, title);
|
2013-11-08 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_surface_set_app_id (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *app_id)
|
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-11-08 22:05:07 +00:00
|
|
|
|
2013-11-19 21:04:14 +00:00
|
|
|
meta_window_set_wm_class (surface->window, app_id, app_id);
|
2013-11-08 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_surface_pong (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
guint32 serial)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-21 19:20:52 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
|
|
|
|
2014-02-15 16:33:12 +00:00
|
|
|
meta_display_pong_for_serial (surface->window->display, serial);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 02:45:34 +00:00
|
|
|
static gboolean
|
|
|
|
begin_grab_op_on_surface (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSeat *seat,
|
|
|
|
MetaGrabOp grab_op)
|
|
|
|
{
|
|
|
|
MetaWindow *window = surface->window;
|
|
|
|
|
|
|
|
if (grab_op == META_GRAB_OP_NONE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return meta_display_begin_grab_op (window->display,
|
|
|
|
window->screen,
|
|
|
|
window,
|
|
|
|
grab_op,
|
|
|
|
TRUE, /* pointer_already_grabbed */
|
|
|
|
FALSE, /* frame_action */
|
|
|
|
1, /* button. XXX? */
|
|
|
|
0, /* modmask */
|
|
|
|
meta_display_get_current_time_roundtrip (window->display),
|
|
|
|
wl_fixed_to_int (seat->pointer.grab_x),
|
|
|
|
wl_fixed_to_int (seat->pointer.grab_y));
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_move (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
guint32 serial)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
|
|
|
if (seat->pointer.button_count == 0 ||
|
|
|
|
seat->pointer.grab_serial != serial ||
|
2013-11-19 22:32:59 +00:00
|
|
|
seat->pointer.focus != surface)
|
2013-08-30 16:26:18 +00:00
|
|
|
return;
|
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
begin_grab_op_on_surface (surface, seat, META_GRAB_OP_MOVING);
|
2013-11-15 02:45:34 +00:00
|
|
|
}
|
2013-09-11 12:06:05 +00:00
|
|
|
|
2013-11-15 02:45:34 +00:00
|
|
|
static MetaGrabOp
|
|
|
|
grab_op_for_edge (int edge)
|
|
|
|
{
|
|
|
|
switch (edge)
|
|
|
|
{
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_TOP_LEFT:
|
|
|
|
return META_GRAB_OP_RESIZING_NW;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_TOP:
|
|
|
|
return META_GRAB_OP_RESIZING_N;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT:
|
|
|
|
return META_GRAB_OP_RESIZING_NE;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_RIGHT:
|
|
|
|
return META_GRAB_OP_RESIZING_E;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT:
|
|
|
|
return META_GRAB_OP_RESIZING_SE;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_BOTTOM:
|
|
|
|
return META_GRAB_OP_RESIZING_S;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT:
|
|
|
|
return META_GRAB_OP_RESIZING_SW;
|
|
|
|
case XDG_SURFACE_RESIZE_EDGE_LEFT:
|
|
|
|
return META_GRAB_OP_RESIZING_W;
|
|
|
|
default:
|
|
|
|
g_warning ("invalid edge: %d", edge);
|
|
|
|
return META_GRAB_OP_NONE;
|
|
|
|
}
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_resize (struct wl_client *client,
|
2013-11-15 02:45:34 +00:00
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
guint32 serial,
|
|
|
|
guint32 edges)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-15 02:45:34 +00:00
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-11-15 02:45:34 +00:00
|
|
|
|
|
|
|
if (seat->pointer.button_count == 0 ||
|
|
|
|
seat->pointer.grab_serial != serial ||
|
2013-11-19 22:32:59 +00:00
|
|
|
seat->pointer.focus != surface)
|
2013-11-15 02:45:34 +00:00
|
|
|
return;
|
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
begin_grab_op_on_surface (surface, seat, grab_op_for_edge (edges));
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_set_output (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *output)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
g_warning ("TODO: support xdg_surface.set_output");
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_set_fullscreen (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2014-02-09 23:23:07 +00:00
|
|
|
surface->pending.fullscreen.changed = TRUE;
|
|
|
|
surface->pending.fullscreen.value = TRUE;
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_unset_fullscreen (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-09-10 13:53:31 +00:00
|
|
|
|
2014-02-09 23:23:07 +00:00
|
|
|
surface->pending.fullscreen.changed = TRUE;
|
|
|
|
surface->pending.fullscreen.value = FALSE;
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_set_maximized (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-09-16 11:42:59 +00:00
|
|
|
|
2014-02-09 23:23:07 +00:00
|
|
|
surface->pending.maximized.changed = TRUE;
|
|
|
|
surface->pending.maximized.value = TRUE;
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_unset_maximized (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2014-02-09 23:23:07 +00:00
|
|
|
surface->pending.maximized.changed = TRUE;
|
|
|
|
surface->pending.maximized.value = FALSE;
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_set_minimized (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-08 22:05:07 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_surface = wl_resource_get_user_data (resource);
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_surface, surface, xdg_surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
|
2013-11-19 22:33:57 +00:00
|
|
|
meta_window_minimize (surface->window);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 02:49:51 +00:00
|
|
|
static const struct xdg_surface_interface meta_wayland_xdg_surface_interface = {
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_destroy,
|
|
|
|
xdg_surface_set_transient_for,
|
2014-02-07 22:29:35 +00:00
|
|
|
xdg_surface_set_margin,
|
2013-11-08 22:05:07 +00:00
|
|
|
xdg_surface_set_title,
|
|
|
|
xdg_surface_set_app_id,
|
|
|
|
xdg_surface_pong,
|
|
|
|
xdg_surface_move,
|
|
|
|
xdg_surface_resize,
|
|
|
|
xdg_surface_set_output,
|
|
|
|
xdg_surface_set_fullscreen,
|
|
|
|
xdg_surface_unset_fullscreen,
|
|
|
|
xdg_surface_set_maximized,
|
|
|
|
xdg_surface_unset_maximized,
|
|
|
|
xdg_surface_set_minimized,
|
2013-08-30 16:26:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2014-02-15 15:02:04 +00:00
|
|
|
xdg_shell_get_xdg_surface (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
guint32 id,
|
|
|
|
struct wl_resource *surface_resource)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
if (!create_surface_extension (&surface->xdg_surface, client, surface_resource, resource, id,
|
|
|
|
META_XDG_SURFACE_VERSION,
|
|
|
|
&xdg_surface_interface,
|
2013-11-26 18:04:37 +00:00
|
|
|
&meta_wayland_xdg_surface_interface,
|
|
|
|
xdg_surface_destructor))
|
2013-11-25 23:15:03 +00:00
|
|
|
{
|
|
|
|
wl_resource_post_error (surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"xdg_shell::get_xdg_surface already requested");
|
|
|
|
return;
|
|
|
|
}
|
2013-11-19 22:33:57 +00:00
|
|
|
|
2014-02-02 00:19:22 +00:00
|
|
|
surface->window = meta_window_wayland_new (meta_get_display (), surface);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
|
|
|
xdg_popup_destructor (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *xdg_popup = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_popup, surface, xdg_popup);
|
|
|
|
|
|
|
|
destroy_window (surface);
|
|
|
|
destroy_surface_extension (xdg_popup);
|
|
|
|
}
|
|
|
|
|
2013-11-15 02:55:37 +00:00
|
|
|
static void
|
|
|
|
xdg_popup_destroy (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
2013-11-20 04:33:46 +00:00
|
|
|
wl_resource_destroy (resource);
|
2013-11-15 02:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xdg_popup_pong (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
2013-11-21 19:20:52 +00:00
|
|
|
MetaWaylandSurfaceExtension *xdg_popup = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (xdg_popup, surface, xdg_popup);
|
|
|
|
|
2014-02-15 16:33:12 +00:00
|
|
|
meta_display_pong_for_serial (surface->window->display, serial);
|
2013-11-15 02:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct xdg_popup_interface meta_wayland_xdg_popup_interface = {
|
|
|
|
xdg_popup_destroy,
|
|
|
|
xdg_popup_pong,
|
|
|
|
};
|
|
|
|
|
2013-11-08 22:05:07 +00:00
|
|
|
static void
|
2014-02-15 15:02:04 +00:00
|
|
|
xdg_shell_get_xdg_popup (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *parent_resource,
|
|
|
|
struct wl_resource *seat_resource,
|
|
|
|
uint32_t serial,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
uint32_t flags)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
2013-11-15 02:55:37 +00:00
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
MetaWaylandSurface *parent_surf = wl_resource_get_user_data (parent_resource);
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
|
|
|
|
MetaRectangle parent_rect;
|
|
|
|
|
|
|
|
if (parent_surf == NULL || parent_surf->window == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
meta_window_get_frame_rect (parent_surf->window, &parent_rect);
|
|
|
|
|
|
|
|
if (!create_surface_extension (&surface->xdg_popup, client, surface_resource, resource, id,
|
|
|
|
META_XDG_POPUP_VERSION,
|
|
|
|
&xdg_popup_interface,
|
2013-11-26 18:04:37 +00:00
|
|
|
&meta_wayland_xdg_popup_interface,
|
|
|
|
xdg_popup_destructor))
|
2013-11-25 23:15:03 +00:00
|
|
|
{
|
|
|
|
wl_resource_post_error (surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
2013-11-25 23:15:19 +00:00
|
|
|
"xdg_shell::get_xdg_popup already requested");
|
2013-11-25 23:15:03 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-11-15 02:55:37 +00:00
|
|
|
|
2014-02-02 00:19:22 +00:00
|
|
|
surface->window = meta_window_wayland_new (meta_get_display (), surface);
|
2013-11-15 02:55:37 +00:00
|
|
|
surface->window->rect.x = parent_rect.x + x;
|
|
|
|
surface->window->rect.y = parent_rect.y + y;
|
2013-12-04 15:41:30 +00:00
|
|
|
surface->window->showing_for_first_time = FALSE;
|
2013-11-15 02:55:37 +00:00
|
|
|
surface->window->placed = TRUE;
|
2013-12-03 15:53:48 +00:00
|
|
|
meta_window_set_transient_for (surface->window, parent_surf->window);
|
2013-11-15 02:55:37 +00:00
|
|
|
|
2013-12-04 15:41:30 +00:00
|
|
|
surface->window->type = META_WINDOW_DROPDOWN_MENU;
|
|
|
|
meta_window_type_changed (surface->window);
|
|
|
|
|
2013-11-15 02:55:37 +00:00
|
|
|
meta_wayland_pointer_start_popup_grab (&seat->pointer, surface);
|
2013-11-08 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 02:49:51 +00:00
|
|
|
static const struct xdg_shell_interface meta_wayland_xdg_shell_interface = {
|
2014-02-15 15:02:04 +00:00
|
|
|
xdg_shell_use_unstable_version,
|
|
|
|
xdg_shell_get_xdg_surface,
|
|
|
|
xdg_shell_get_xdg_popup,
|
2013-08-30 16:26:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2013-11-08 22:05:07 +00:00
|
|
|
bind_xdg_shell (struct wl_client *client,
|
|
|
|
void *data,
|
|
|
|
guint32 version,
|
|
|
|
guint32 id)
|
2013-08-30 16:26:18 +00:00
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2014-02-15 15:02:48 +00:00
|
|
|
if (version != 1)
|
|
|
|
{
|
|
|
|
g_warning ("using xdg-shell without stable version 1\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
resource = wl_resource_create (client, &xdg_shell_interface, 1, id);
|
2013-11-08 22:05:07 +00:00
|
|
|
wl_resource_set_implementation (resource, &meta_wayland_xdg_shell_interface, data, NULL);
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
|
|
|
gtk_surface_destructor (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *gtk_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (gtk_surface, surface, gtk_surface);
|
|
|
|
|
|
|
|
destroy_surface_extension (gtk_surface);
|
|
|
|
}
|
|
|
|
|
2013-08-30 07:40:36 +00:00
|
|
|
static void
|
|
|
|
set_dbus_properties (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
const char *application_id,
|
|
|
|
const char *app_menu_path,
|
|
|
|
const char *menubar_path,
|
|
|
|
const char *window_object_path,
|
|
|
|
const char *application_object_path,
|
|
|
|
const char *unique_bus_name)
|
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
MetaWaylandSurfaceExtension *gtk_surface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (gtk_surface, surface, gtk_surface);
|
2013-08-30 07:40:36 +00:00
|
|
|
|
2014-02-16 15:15:14 +00:00
|
|
|
/* Broken client, let it die instead of us */
|
|
|
|
if (!surface->window)
|
|
|
|
{
|
|
|
|
meta_warning ("meta-wayland-surface: set_dbus_properties called with invalid window!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-19 21:04:14 +00:00
|
|
|
meta_window_set_gtk_dbus_properties (surface->window,
|
|
|
|
application_id,
|
|
|
|
unique_bus_name,
|
|
|
|
app_menu_path,
|
|
|
|
menubar_path,
|
|
|
|
application_object_path,
|
|
|
|
window_object_path);
|
2013-08-30 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 02:49:51 +00:00
|
|
|
static const struct gtk_surface_interface meta_wayland_gtk_surface_interface = {
|
2013-08-30 07:40:36 +00:00
|
|
|
set_dbus_properties
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_gtk_surface (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
guint32 id,
|
|
|
|
struct wl_resource *surface_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
|
2013-11-19 22:32:59 +00:00
|
|
|
if (!create_surface_extension (&surface->gtk_surface, client, surface_resource, resource, id,
|
|
|
|
META_GTK_SURFACE_VERSION,
|
|
|
|
>k_surface_interface,
|
2013-11-26 18:04:37 +00:00
|
|
|
&meta_wayland_gtk_surface_interface,
|
|
|
|
gtk_surface_destructor))
|
2013-11-25 23:15:03 +00:00
|
|
|
{
|
|
|
|
wl_resource_post_error (surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"gtk_shell::get_gtk_surface already requested");
|
|
|
|
return;
|
|
|
|
}
|
2013-08-30 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2013-11-15 02:49:51 +00:00
|
|
|
static const struct gtk_shell_interface meta_wayland_gtk_shell_interface = {
|
2013-08-30 07:40:36 +00:00
|
|
|
get_gtk_surface
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_gtk_shell (struct wl_client *client,
|
|
|
|
void *data,
|
|
|
|
guint32 version,
|
|
|
|
guint32 id)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2013-09-10 11:45:27 +00:00
|
|
|
resource = wl_resource_create (client, >k_shell_interface,
|
|
|
|
MIN (META_GTK_SHELL_VERSION, version), id);
|
2013-08-30 07:40:36 +00:00
|
|
|
wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL);
|
|
|
|
|
|
|
|
/* FIXME: ask the plugin */
|
|
|
|
gtk_shell_send_capabilities (resource, GTK_SHELL_CAPABILITY_GLOBAL_APP_MENU);
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:17:29 +00:00
|
|
|
static void
|
2014-02-01 21:19:47 +00:00
|
|
|
subsurface_parent_surface_committed (MetaWaylandSurface *surface)
|
2014-01-12 22:17:29 +00:00
|
|
|
{
|
2014-02-01 21:24:43 +00:00
|
|
|
MetaWaylandDoubleBufferedState *pending_surface_state = &surface->sub.pending_surface_state;
|
2014-01-12 22:17:29 +00:00
|
|
|
|
|
|
|
if (surface->sub.pending_pos)
|
|
|
|
{
|
|
|
|
clutter_actor_set_position (CLUTTER_ACTOR (surface->surface_actor),
|
|
|
|
surface->sub.pending_x,
|
|
|
|
surface->sub.pending_y);
|
|
|
|
surface->sub.pending_pos = FALSE;
|
|
|
|
}
|
2014-01-12 22:24:00 +00:00
|
|
|
|
|
|
|
if (surface->sub.pending_placement_ops)
|
|
|
|
{
|
|
|
|
GSList *it;
|
|
|
|
for (it = surface->sub.pending_placement_ops; it; it = it->next)
|
|
|
|
{
|
|
|
|
MetaWaylandSubsurfacePlacementOp *op = it->data;
|
|
|
|
ClutterActor *surface_actor;
|
|
|
|
ClutterActor *parent_actor;
|
|
|
|
ClutterActor *sibling_actor;
|
|
|
|
|
|
|
|
if (!op->sibling)
|
|
|
|
{
|
|
|
|
g_slice_free (MetaWaylandSubsurfacePlacementOp, op);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_actor = CLUTTER_ACTOR (surface->surface_actor);
|
|
|
|
parent_actor = clutter_actor_get_parent (CLUTTER_ACTOR (surface->sub.parent));
|
|
|
|
sibling_actor = CLUTTER_ACTOR (op->sibling->surface_actor);
|
|
|
|
|
|
|
|
switch (op->placement)
|
|
|
|
{
|
|
|
|
case META_WAYLAND_SUBSURFACE_PLACEMENT_ABOVE:
|
|
|
|
clutter_actor_set_child_above_sibling (parent_actor, surface_actor, sibling_actor);
|
|
|
|
break;
|
|
|
|
case META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW:
|
|
|
|
clutter_actor_set_child_below_sibling (parent_actor, surface_actor, sibling_actor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_list_remove (&op->sibling_destroy_listener.link);
|
|
|
|
g_slice_free (MetaWaylandSubsurfacePlacementOp, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (surface->sub.pending_placement_ops);
|
|
|
|
surface->sub.pending_placement_ops = NULL;
|
|
|
|
}
|
2014-01-13 22:31:25 +00:00
|
|
|
|
|
|
|
if (surface->sub.synchronous)
|
2014-02-01 21:24:43 +00:00
|
|
|
commit_double_buffered_state (surface, pending_surface_state);
|
2014-01-13 22:31:25 +00:00
|
|
|
|
2014-02-01 21:24:43 +00:00
|
|
|
double_buffered_state_reset (pending_surface_state);
|
2014-01-12 22:17:29 +00:00
|
|
|
}
|
|
|
|
|
2013-11-26 18:04:37 +00:00
|
|
|
static void
|
|
|
|
wl_subsurface_destructor (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (subsurface, surface, subsurface);
|
|
|
|
|
2014-01-12 21:02:09 +00:00
|
|
|
if (surface->sub.parent)
|
|
|
|
{
|
|
|
|
wl_list_remove (&surface->sub.parent_destroy_listener.link);
|
|
|
|
surface->sub.parent->subsurfaces =
|
|
|
|
g_list_remove (surface->sub.parent->subsurfaces, surface);
|
|
|
|
unparent_actor (surface);
|
|
|
|
surface->sub.parent = NULL;
|
|
|
|
}
|
2014-01-13 22:31:25 +00:00
|
|
|
|
|
|
|
double_buffered_state_destroy (&surface->sub.pending_surface_state);
|
2013-11-26 18:04:37 +00:00
|
|
|
destroy_surface_extension (subsurface);
|
|
|
|
}
|
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
static void
|
|
|
|
wl_subsurface_destroy (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy (resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_subsurface_set_position (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x,
|
|
|
|
int32_t y)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (subsurface, surface, subsurface);
|
|
|
|
|
2014-01-12 22:17:29 +00:00
|
|
|
surface->sub.pending_x = x;
|
|
|
|
surface->sub.pending_y = y;
|
|
|
|
surface->sub.pending_pos = TRUE;
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
2014-01-12 21:02:09 +00:00
|
|
|
static gboolean
|
|
|
|
is_valid_sibling (MetaWaylandSurface *surface, MetaWaylandSurface *sibling)
|
|
|
|
{
|
|
|
|
if (surface->sub.parent == sibling)
|
|
|
|
return TRUE;
|
|
|
|
if (surface->sub.parent == sibling->sub.parent)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:24:00 +00:00
|
|
|
static void
|
|
|
|
subsurface_handle_pending_sibling_destroyed (struct wl_listener *listener, void *data)
|
|
|
|
{
|
|
|
|
MetaWaylandSubsurfacePlacementOp *op =
|
|
|
|
wl_container_of (listener, op, sibling_destroy_listener);
|
|
|
|
|
|
|
|
op->sibling = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
queue_subsurface_placement (MetaWaylandSurface *surface,
|
|
|
|
MetaWaylandSurface *sibling,
|
|
|
|
MetaWaylandSubsurfacePlacement placement)
|
|
|
|
{
|
|
|
|
MetaWaylandSubsurfacePlacementOp *op =
|
|
|
|
g_slice_new (MetaWaylandSubsurfacePlacementOp);
|
|
|
|
|
|
|
|
op->placement = placement;
|
|
|
|
op->sibling = sibling;
|
|
|
|
op->sibling_destroy_listener.notify =
|
|
|
|
subsurface_handle_pending_sibling_destroyed;
|
|
|
|
wl_resource_add_destroy_listener (sibling->resource,
|
|
|
|
&op->sibling_destroy_listener);
|
|
|
|
|
|
|
|
surface->sub.pending_placement_ops =
|
|
|
|
g_slist_append (surface->sub.pending_placement_ops, op);
|
|
|
|
}
|
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
static void
|
|
|
|
wl_subsurface_place_above (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *sibling_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (subsurface, surface, subsurface);
|
|
|
|
MetaWaylandSurface *sibling = wl_resource_get_user_data (sibling_resource);
|
|
|
|
|
2014-01-12 21:02:09 +00:00
|
|
|
if (!is_valid_sibling (surface, sibling))
|
|
|
|
{
|
|
|
|
wl_resource_post_error (resource, WL_SUBSURFACE_ERROR_BAD_SURFACE,
|
|
|
|
"wl_subsurface::place_above: wl_surface@%d is "
|
|
|
|
"not a valid parent or sibling",
|
|
|
|
wl_resource_get_id (sibling->resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:24:00 +00:00
|
|
|
queue_subsurface_placement (surface,
|
|
|
|
sibling,
|
|
|
|
META_WAYLAND_SUBSURFACE_PLACEMENT_ABOVE);
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_subsurface_place_below (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *sibling_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurfaceExtension *subsurface = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (subsurface, surface, subsurface);
|
|
|
|
MetaWaylandSurface *sibling = wl_resource_get_user_data (sibling_resource);
|
|
|
|
|
2014-01-12 21:02:09 +00:00
|
|
|
if (!is_valid_sibling (surface, sibling))
|
|
|
|
{
|
|
|
|
wl_resource_post_error (resource, WL_SUBSURFACE_ERROR_BAD_SURFACE,
|
|
|
|
"wl_subsurface::place_below: wl_surface@%d is "
|
|
|
|
"not a valid parent or sibling",
|
|
|
|
wl_resource_get_id (sibling->resource));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:24:00 +00:00
|
|
|
queue_subsurface_placement (surface,
|
|
|
|
sibling,
|
|
|
|
META_WAYLAND_SUBSURFACE_PLACEMENT_BELOW);
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_subsurface_set_sync (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
2014-01-13 22:31:25 +00:00
|
|
|
MetaWaylandSurfaceExtension *subsurface =
|
|
|
|
wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
wl_container_of (subsurface, surface, subsurface);
|
|
|
|
|
|
|
|
surface->sub.synchronous = TRUE;
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_subsurface_set_desync (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
2014-01-13 22:31:25 +00:00
|
|
|
MetaWaylandSurfaceExtension *subsurface =
|
|
|
|
wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface =
|
|
|
|
wl_container_of (subsurface, surface, subsurface);
|
|
|
|
|
|
|
|
if (surface->sub.synchronous)
|
2014-02-01 21:19:47 +00:00
|
|
|
subsurface_parent_surface_committed (surface);
|
2014-01-13 22:31:25 +00:00
|
|
|
|
|
|
|
surface->sub.synchronous = FALSE;
|
2013-11-25 21:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_subsurface_interface meta_wayland_subsurface_interface = {
|
|
|
|
wl_subsurface_destroy,
|
|
|
|
wl_subsurface_set_position,
|
|
|
|
wl_subsurface_place_above,
|
|
|
|
wl_subsurface_place_below,
|
|
|
|
wl_subsurface_set_sync,
|
|
|
|
wl_subsurface_set_desync,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
wl_subcompositor_destroy (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy (resource);
|
|
|
|
}
|
|
|
|
|
2014-01-12 21:02:09 +00:00
|
|
|
static void
|
|
|
|
surface_handle_parent_surface_destroyed (struct wl_listener *listener,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_container_of (listener,
|
|
|
|
surface,
|
|
|
|
sub.parent_destroy_listener);
|
|
|
|
|
|
|
|
surface->sub.parent = NULL;
|
|
|
|
unparent_actor (surface);
|
|
|
|
}
|
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
static void
|
|
|
|
wl_subcompositor_get_subsurface (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
guint32 id,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
struct wl_resource *parent_resource)
|
|
|
|
{
|
|
|
|
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
|
|
|
|
MetaWaylandSurface *parent = wl_resource_get_user_data (parent_resource);
|
|
|
|
|
|
|
|
if (!create_surface_extension (&surface->subsurface, client, surface_resource, resource, id,
|
|
|
|
META_GTK_SURFACE_VERSION,
|
|
|
|
&wl_subsurface_interface,
|
2013-11-26 18:04:37 +00:00
|
|
|
&meta_wayland_subsurface_interface,
|
|
|
|
wl_subsurface_destructor))
|
2013-11-25 21:26:02 +00:00
|
|
|
{
|
|
|
|
wl_resource_post_error (surface_resource,
|
|
|
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
|
|
|
"wl_subcompositor::get_subsurface already requested");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-13 22:31:25 +00:00
|
|
|
double_buffered_state_init (&surface->sub.pending_surface_state);
|
2014-01-12 21:02:09 +00:00
|
|
|
surface->sub.parent = parent;
|
|
|
|
surface->sub.parent_destroy_listener.notify =
|
|
|
|
surface_handle_parent_surface_destroyed;
|
|
|
|
wl_resource_add_destroy_listener (parent->resource,
|
|
|
|
&surface->sub.parent_destroy_listener);
|
|
|
|
parent->subsurfaces = g_list_append (parent->subsurfaces, surface);
|
|
|
|
|
2013-11-25 21:26:02 +00:00
|
|
|
clutter_actor_add_child (CLUTTER_ACTOR (parent->surface_actor),
|
|
|
|
CLUTTER_ACTOR (surface->surface_actor));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_subcompositor_interface meta_wayland_subcompositor_interface = {
|
|
|
|
wl_subcompositor_destroy,
|
|
|
|
wl_subcompositor_get_subsurface,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_subcompositor (struct wl_client *client,
|
|
|
|
void *data,
|
|
|
|
guint32 version,
|
|
|
|
guint32 id)
|
|
|
|
{
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
|
|
|
resource = wl_resource_create (client, &wl_subcompositor_interface,
|
|
|
|
MIN (META_WL_SUBCOMPOSITOR_VERSION, version), id);
|
|
|
|
wl_resource_set_implementation (resource, &meta_wayland_subcompositor_interface, data, NULL);
|
|
|
|
}
|
|
|
|
|
2013-08-30 16:26:18 +00:00
|
|
|
void
|
|
|
|
meta_wayland_init_shell (MetaWaylandCompositor *compositor)
|
|
|
|
{
|
|
|
|
if (wl_global_create (compositor->wayland_display,
|
2014-02-15 15:02:48 +00:00
|
|
|
&xdg_shell_interface, 1,
|
2013-11-08 22:05:07 +00:00
|
|
|
compositor, bind_xdg_shell) == NULL)
|
|
|
|
g_error ("Failed to register a global xdg-shell object");
|
2013-08-30 07:40:36 +00:00
|
|
|
|
|
|
|
if (wl_global_create (compositor->wayland_display,
|
2013-09-10 11:45:27 +00:00
|
|
|
>k_shell_interface,
|
|
|
|
META_GTK_SHELL_VERSION,
|
2013-08-30 07:40:36 +00:00
|
|
|
compositor, bind_gtk_shell) == NULL)
|
|
|
|
g_error ("Failed to register a global gtk-shell object");
|
2013-11-25 21:26:02 +00:00
|
|
|
|
|
|
|
if (wl_global_create (compositor->wayland_display,
|
|
|
|
&wl_subcompositor_interface,
|
|
|
|
META_WL_SUBCOMPOSITOR_VERSION,
|
|
|
|
compositor, bind_subcompositor) == NULL)
|
|
|
|
g_error ("Failed to register a global wl-subcompositor object");
|
2013-08-30 16:26:18 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 10:00:29 +00:00
|
|
|
void
|
|
|
|
meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
|
|
|
|
int new_width,
|
2014-02-07 22:23:17 +00:00
|
|
|
int new_height)
|
2013-09-03 10:00:29 +00:00
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
if (surface->xdg_surface.resource)
|
|
|
|
xdg_surface_send_configure (surface->xdg_surface.resource,
|
2014-02-07 22:23:17 +00:00
|
|
|
new_width, new_height);
|
2013-09-03 10:00:29 +00:00
|
|
|
}
|
2013-11-08 22:05:07 +00:00
|
|
|
|
2013-11-12 20:52:03 +00:00
|
|
|
void
|
|
|
|
meta_wayland_surface_focused_set (MetaWaylandSurface *surface)
|
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
if (surface->xdg_surface.resource)
|
|
|
|
xdg_surface_send_focused_set (surface->xdg_surface.resource);
|
2013-11-12 20:52:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_surface_focused_unset (MetaWaylandSurface *surface)
|
|
|
|
{
|
2013-11-19 22:32:59 +00:00
|
|
|
if (surface->xdg_surface.resource)
|
|
|
|
xdg_surface_send_focused_unset (surface->xdg_surface.resource);
|
2013-11-12 20:52:03 +00:00
|
|
|
}
|
2013-11-21 19:20:52 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_surface_ping (MetaWaylandSurface *surface,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
|
|
|
if (surface->xdg_surface.resource)
|
|
|
|
xdg_surface_send_ping (surface->xdg_surface.resource, timestamp);
|
|
|
|
else if (surface->xdg_popup.resource)
|
|
|
|
xdg_popup_send_ping (surface->xdg_popup.resource, timestamp);
|
|
|
|
}
|
2014-02-07 22:28:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_surface_delete (MetaWaylandSurface *surface)
|
|
|
|
{
|
|
|
|
if (surface->xdg_surface.resource)
|
|
|
|
xdg_surface_send_delete (surface->xdg_surface.resource);
|
|
|
|
}
|