2013-05-03 13:51:22 -04:00
|
|
|
/*
|
|
|
|
* Wayland Support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Intel Corporation
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
2012-01-18 18:03:23 -05:00
|
|
|
#include <cogl/cogl-wayland-server.h>
|
2013-05-03 13:51:22 -04:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
#include <clutter/wayland/clutter-wayland-compositor.h>
|
|
|
|
#include <clutter/wayland/clutter-wayland-surface.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "meta-wayland-seat.h"
|
|
|
|
#include "meta-wayland-private.h"
|
|
|
|
#include "meta-wayland-keyboard.h"
|
|
|
|
#include "meta-wayland-pointer.h"
|
|
|
|
#include "meta-wayland-data-device.h"
|
|
|
|
#include "meta-window-actor-private.h"
|
|
|
|
#include "meta/meta-shaped-texture.h"
|
2013-08-16 08:23:40 -04:00
|
|
|
#include "meta-shaped-texture-private.h"
|
2012-01-18 18:03:23 -05:00
|
|
|
#include "meta-wayland-stage.h"
|
2013-08-13 06:57:41 -04:00
|
|
|
#include "meta-cursor-tracker-private.h"
|
window-actor: Split into two subclasses of MetaSurfaceActor
The rendering logic before was somewhat complex. We had three independent
cases to take into account when doing rendering:
* X11 compositor. In this case, we're a traditional X11 compositor,
not a Wayland compositor. We use XCompositeNameWindowPixmap to get
the backing pixmap for the window, and deal with the COMPOSITE
extension messiness.
In this case, meta_is_wayland_compositor() is FALSE.
* Wayland clients. In this case, we're a Wayland compositor managing
Wayland surfaces. The rendering for this is fairly straightforward,
as Cogl handles most of the complexity with EGL and SHM buffers...
Wayland clients give us the input and opaque regions through
wl_surface.
In this case, meta_is_wayland_compositor() is TRUE and
priv->window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND.
* XWayland clients. In this case, we're a Wayland compositor, like
above, and XWayland hands us Wayland surfaces. XWayland handles
the COMPOSITE extension messiness for us, and hands us a buffer
like any other Wayland client. We have to fetch the input and
opaque regions from the X11 window ourselves.
In this case, meta_is_wayland_compositor() is TRUE and
priv->window->client_type == META_WINDOW_CLIENT_TYPE_X11.
We now split the rendering logic into two subclasses, which are:
* MetaSurfaceActorX11, which handles the X11 compositor case, in that
it uses XCompositeNameWindowPixmap to get the backing pixmap, and
deal with all the COMPOSITE extension messiness.
* MetaSurfaceActorWayland, which handles the Wayland compositor case
for both native Wayland clients and XWayland clients. XWayland handles
COMPOSITE for us, and handles pushing a surface over through the
xf86-video-wayland DDX.
Frame sync is still in MetaWindowActor, as it needs to work for both the
X11 compositor and XWayland client cases. When Wayland's video display
protocol lands, this will need to be significantly overhauled, as it would
have to work for any wl_surface, including subsurfaces, so we would need
surface-level discretion.
https://bugzilla.gnome.org/show_bug.cgi?id=720631
2014-02-01 17:21:11 -05:00
|
|
|
#include "meta-surface-actor-wayland.h"
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10)
|
|
|
|
|
|
|
|
static void
|
|
|
|
unbind_resource (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_list_remove (wl_resource_get_link (resource));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-01 17:18:21 -05:00
|
|
|
set_cursor_surface (MetaWaylandSeat *seat,
|
|
|
|
MetaWaylandSurface *surface)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2014-02-01 17:55:03 -05:00
|
|
|
if (seat->cursor_surface == surface)
|
2014-02-01 17:18:21 -05:00
|
|
|
return;
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-02-01 17:55:03 -05:00
|
|
|
if (seat->cursor_surface)
|
|
|
|
wl_list_remove (&seat->cursor_surface_destroy_listener.link);
|
2014-02-01 17:18:21 -05:00
|
|
|
|
2014-02-01 17:55:03 -05:00
|
|
|
seat->cursor_surface = surface;
|
2014-02-01 17:18:21 -05:00
|
|
|
|
2014-02-01 17:55:03 -05:00
|
|
|
if (seat->cursor_surface)
|
|
|
|
wl_resource_add_destroy_listener (seat->cursor_surface->resource,
|
|
|
|
&seat->cursor_surface_destroy_listener);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
2012-01-18 18:03:23 -05:00
|
|
|
void
|
2014-02-01 17:55:03 -05:00
|
|
|
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
2012-01-18 18:03:23 -05:00
|
|
|
{
|
2014-03-31 16:50:15 -04:00
|
|
|
MetaCursorReference *cursor;
|
2013-08-13 06:57:41 -04:00
|
|
|
|
|
|
|
if (seat->cursor_tracker == NULL)
|
|
|
|
return;
|
|
|
|
|
2014-02-01 17:45:51 -05:00
|
|
|
if (seat->cursor_surface && seat->cursor_surface->buffer)
|
2014-03-31 16:50:15 -04:00
|
|
|
{
|
|
|
|
struct wl_resource *buffer = seat->cursor_surface->buffer->resource;
|
|
|
|
cursor = meta_cursor_reference_from_buffer (seat->cursor_tracker,
|
|
|
|
buffer,
|
|
|
|
seat->hotspot_x,
|
|
|
|
seat->hotspot_y);
|
|
|
|
}
|
2013-11-25 16:03:25 -05:00
|
|
|
else
|
2014-03-31 16:50:15 -04:00
|
|
|
cursor = NULL;
|
2013-11-25 16:03:25 -05:00
|
|
|
|
2014-03-31 16:50:15 -04:00
|
|
|
meta_cursor_tracker_set_window_cursor (seat->cursor_tracker, cursor);
|
|
|
|
|
|
|
|
if (cursor)
|
|
|
|
meta_cursor_reference_unref (cursor);
|
2012-01-18 18:03:23 -05:00
|
|
|
}
|
|
|
|
|
2013-05-03 13:51:22 -04:00
|
|
|
static void
|
|
|
|
pointer_set_cursor (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_resource *surface_resource,
|
|
|
|
int32_t x, int32_t y)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
|
|
|
MetaWaylandSurface *surface;
|
|
|
|
|
2014-02-01 17:18:21 -05:00
|
|
|
surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-02-18 18:00:26 -05:00
|
|
|
if (seat->pointer.focus_surface == NULL)
|
2013-05-03 13:51:22 -04:00
|
|
|
return;
|
2014-02-18 18:00:26 -05:00
|
|
|
if (wl_resource_get_client (seat->pointer.focus_surface->resource) != client)
|
2013-05-03 13:51:22 -04:00
|
|
|
return;
|
|
|
|
if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2)
|
|
|
|
return;
|
|
|
|
|
2012-01-18 18:03:23 -05:00
|
|
|
seat->hotspot_x = x;
|
|
|
|
seat->hotspot_y = y;
|
2014-02-01 17:18:21 -05:00
|
|
|
set_cursor_surface (seat, surface);
|
2014-02-01 17:55:03 -05:00
|
|
|
meta_wayland_seat_update_cursor_surface (seat);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
2014-04-02 11:38:21 -04:00
|
|
|
static void
|
|
|
|
pointer_release (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy (resource);
|
|
|
|
}
|
|
|
|
|
2014-02-01 17:18:21 -05:00
|
|
|
static const struct wl_pointer_interface pointer_interface = {
|
2014-04-02 11:38:21 -04:00
|
|
|
pointer_set_cursor,
|
|
|
|
pointer_release,
|
2014-02-01 17:18:21 -05:00
|
|
|
};
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
seat_get_pointer (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
|
|
|
struct wl_resource *cr;
|
|
|
|
|
2013-09-10 07:03:37 -04:00
|
|
|
cr = wl_resource_create (client, &wl_pointer_interface,
|
2013-09-10 07:45:27 -04:00
|
|
|
MIN (META_WL_POINTER_VERSION, wl_resource_get_version (resource)), id);
|
2013-09-10 07:03:37 -04:00
|
|
|
wl_resource_set_implementation (cr, &pointer_interface, seat, unbind_resource);
|
2013-05-03 13:51:22 -04:00
|
|
|
wl_list_insert (&seat->pointer.resource_list, wl_resource_get_link (cr));
|
|
|
|
|
2014-02-18 18:00:26 -05:00
|
|
|
if (seat->pointer.focus_surface &&
|
|
|
|
wl_resource_get_client (seat->pointer.focus_surface->resource) == client)
|
|
|
|
meta_wayland_pointer_set_focus (&seat->pointer, seat->pointer.focus_surface);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
2014-04-02 11:38:21 -04:00
|
|
|
static void
|
|
|
|
keyboard_release (struct wl_client *client,
|
|
|
|
struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_resource_destroy (resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_keyboard_interface keyboard_interface = {
|
|
|
|
keyboard_release,
|
|
|
|
};
|
|
|
|
|
2013-05-03 13:51:22 -04:00
|
|
|
static void
|
|
|
|
seat_get_keyboard (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
|
|
|
struct wl_resource *cr;
|
|
|
|
|
2013-09-10 07:03:37 -04:00
|
|
|
cr = wl_resource_create (client, &wl_keyboard_interface,
|
2013-09-10 07:45:27 -04:00
|
|
|
MIN (META_WL_KEYBOARD_VERSION, wl_resource_get_version (resource)), id);
|
2013-09-10 07:03:37 -04:00
|
|
|
wl_resource_set_implementation (cr, NULL, seat, unbind_resource);
|
2013-05-03 13:51:22 -04:00
|
|
|
wl_list_insert (&seat->keyboard.resource_list, wl_resource_get_link (cr));
|
|
|
|
|
|
|
|
wl_keyboard_send_keymap (cr,
|
|
|
|
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
|
|
|
seat->keyboard.xkb_info.keymap_fd,
|
|
|
|
seat->keyboard.xkb_info.keymap_size);
|
|
|
|
|
2014-02-18 18:00:26 -05:00
|
|
|
if (seat->keyboard.focus_surface &&
|
|
|
|
wl_resource_get_client (seat->keyboard.focus_surface->resource) == client)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2014-02-18 18:00:26 -05:00
|
|
|
meta_wayland_keyboard_set_focus (&seat->keyboard, seat->keyboard.focus_surface);
|
2013-05-03 13:51:22 -04:00
|
|
|
meta_wayland_data_device_set_keyboard_focus (seat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
seat_get_touch (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
/* Touch not supported */
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_seat_interface
|
|
|
|
seat_interface =
|
|
|
|
{
|
|
|
|
seat_get_pointer,
|
|
|
|
seat_get_keyboard,
|
|
|
|
seat_get_touch
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
bind_seat (struct wl_client *client,
|
|
|
|
void *data,
|
|
|
|
guint32 version,
|
|
|
|
guint32 id)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = data;
|
|
|
|
struct wl_resource *resource;
|
|
|
|
|
2013-09-10 07:45:27 -04:00
|
|
|
resource = wl_resource_create (client, &wl_seat_interface,
|
|
|
|
MIN (META_WL_SEAT_VERSION, version), id);
|
2013-09-10 07:03:37 -04:00
|
|
|
wl_resource_set_implementation (resource, &seat_interface, seat, unbind_resource);
|
2013-05-03 13:51:22 -04:00
|
|
|
wl_list_insert (&seat->base_resource_list, wl_resource_get_link (resource));
|
|
|
|
|
|
|
|
wl_seat_send_capabilities (resource,
|
|
|
|
WL_SEAT_CAPABILITY_POINTER |
|
|
|
|
WL_SEAT_CAPABILITY_KEYBOARD);
|
2013-09-10 07:03:37 -04:00
|
|
|
|
2013-09-10 07:45:27 -04:00
|
|
|
if (version >= META_WL_SEAT_HAS_NAME)
|
2013-09-10 07:03:37 -04:00
|
|
|
wl_seat_send_name (resource, "seat0");
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-01 17:55:03 -05:00
|
|
|
pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2014-02-01 17:55:03 -05:00
|
|
|
MetaWaylandSeat *seat = wl_container_of (listener, seat, cursor_surface_destroy_listener);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-02-01 17:18:21 -05:00
|
|
|
set_cursor_surface (seat, NULL);
|
2014-02-01 17:55:03 -05:00
|
|
|
meta_wayland_seat_update_cursor_surface (seat);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaWaylandSeat *
|
2014-02-17 20:49:04 -05:00
|
|
|
meta_wayland_seat_new (struct wl_display *display)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = g_new0 (MetaWaylandSeat, 1);
|
|
|
|
|
|
|
|
seat->selection_data_source = NULL;
|
|
|
|
wl_list_init (&seat->base_resource_list);
|
2013-09-11 08:06:05 -04:00
|
|
|
wl_list_init (&seat->data_device_resource_list);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-02-17 20:49:04 -05:00
|
|
|
meta_wayland_pointer_init (&seat->pointer);
|
|
|
|
meta_wayland_keyboard_init (&seat->keyboard, display);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
seat->display = display;
|
|
|
|
|
|
|
|
seat->current_stage = 0;
|
|
|
|
|
2014-02-01 17:55:03 -05:00
|
|
|
seat->cursor_surface = NULL;
|
|
|
|
seat->cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
|
2013-05-03 13:51:22 -04:00
|
|
|
seat->hotspot_x = 16;
|
|
|
|
seat->hotspot_y = 16;
|
|
|
|
|
2013-09-10 07:45:27 -04:00
|
|
|
wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
return seat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-11 08:06:05 -04:00
|
|
|
notify_motion (MetaWaylandSeat *seat,
|
2013-05-03 13:51:22 -04:00
|
|
|
const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
MetaWaylandPointer *pointer = &seat->pointer;
|
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
meta_wayland_seat_repick (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
pointer->grab->interface->motion (pointer->grab, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_motion_event (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2013-09-11 08:06:05 -04:00
|
|
|
notify_motion (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_button_event (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
|
|
|
MetaWaylandPointer *pointer = &seat->pointer;
|
2013-11-12 15:42:31 -05:00
|
|
|
gboolean implicit_grab;
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
notify_motion (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-11-12 15:42:31 -05:00
|
|
|
implicit_grab = (event->type == CLUTTER_BUTTON_PRESS) && (pointer->button_count == 1);
|
|
|
|
if (implicit_grab)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2013-10-16 00:06:45 -04:00
|
|
|
pointer->grab_button = clutter_event_get_button (event);
|
2013-09-11 08:06:05 -04:00
|
|
|
pointer->grab_time = clutter_event_get_time (event);
|
2013-08-16 06:13:26 -04:00
|
|
|
pointer->grab_x = pointer->x;
|
|
|
|
pointer->grab_y = pointer->y;
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
pointer->grab->interface->button (pointer->grab, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-11-12 15:42:31 -05:00
|
|
|
if (implicit_grab)
|
2013-05-03 13:51:22 -04:00
|
|
|
pointer->grab_serial = wl_display_get_serial (seat->display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_scroll_event (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2014-03-10 11:09:20 -04:00
|
|
|
wl_fixed_t x_value = 0, y_value = 0;
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
notify_motion (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-03-10 11:08:01 -04:00
|
|
|
if (!seat->pointer.focus_resource)
|
|
|
|
return;
|
|
|
|
|
2014-03-10 11:10:36 -04:00
|
|
|
if (clutter_event_is_pointer_emulated (event))
|
|
|
|
return;
|
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
switch (clutter_event_get_scroll_direction (event))
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
|
|
|
case CLUTTER_SCROLL_UP:
|
2014-03-10 11:09:20 -04:00
|
|
|
y_value = -DEFAULT_AXIS_STEP_DISTANCE;
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL_DOWN:
|
2014-03-10 11:09:20 -04:00
|
|
|
y_value = DEFAULT_AXIS_STEP_DISTANCE;
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL_LEFT:
|
2014-03-10 11:09:20 -04:00
|
|
|
x_value = -DEFAULT_AXIS_STEP_DISTANCE;
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL_RIGHT:
|
2014-03-10 11:09:20 -04:00
|
|
|
x_value = DEFAULT_AXIS_STEP_DISTANCE;
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
2014-03-10 11:10:36 -04:00
|
|
|
case CLUTTER_SCROLL_SMOOTH:
|
|
|
|
{
|
|
|
|
double dx, dy;
|
|
|
|
clutter_event_get_scroll_delta (event, &dx, &dy);
|
|
|
|
x_value = wl_fixed_from_double (dx);
|
|
|
|
y_value = wl_fixed_from_double (dy);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-05-03 13:51:22 -04:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-10 11:09:20 -04:00
|
|
|
if (x_value)
|
|
|
|
wl_pointer_send_axis (seat->pointer.focus_resource, clutter_event_get_time (event),
|
|
|
|
WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
|
|
|
|
if (y_value)
|
|
|
|
wl_pointer_send_axis (seat->pointer.focus_resource, clutter_event_get_time (event),
|
|
|
|
WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
2013-08-16 06:13:26 -04:00
|
|
|
static int
|
|
|
|
count_buttons (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
static gint maskmap[5] =
|
|
|
|
{
|
|
|
|
CLUTTER_BUTTON1_MASK, CLUTTER_BUTTON2_MASK, CLUTTER_BUTTON3_MASK,
|
|
|
|
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK
|
|
|
|
};
|
|
|
|
ClutterModifierType mod_mask;
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
mod_mask = clutter_event_get_state (event);
|
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if (mod_mask & maskmap[i])
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2014-03-18 13:00:48 -04:00
|
|
|
static void
|
2013-11-13 15:41:29 -05:00
|
|
|
meta_wayland_seat_update_pointer (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2013-11-13 15:41:29 -05:00
|
|
|
float x, y;
|
|
|
|
|
|
|
|
clutter_event_get_coords (event, &x, &y);
|
|
|
|
seat->pointer.x = wl_fixed_from_double (x);
|
|
|
|
seat->pointer.y = wl_fixed_from_double (y);
|
|
|
|
|
2013-08-16 06:13:26 -04:00
|
|
|
seat->pointer.button_count = count_buttons (event);
|
|
|
|
|
2013-10-04 02:33:10 -04:00
|
|
|
if (seat->cursor_tracker)
|
|
|
|
{
|
|
|
|
meta_cursor_tracker_update_position (seat->cursor_tracker,
|
|
|
|
wl_fixed_to_int (seat->pointer.x),
|
|
|
|
wl_fixed_to_int (seat->pointer.y));
|
|
|
|
|
|
|
|
if (seat->pointer.current == NULL)
|
2013-11-18 19:19:42 -05:00
|
|
|
meta_cursor_tracker_unset_window_cursor (seat->cursor_tracker);
|
2013-10-04 02:33:10 -04:00
|
|
|
}
|
2013-11-13 15:41:29 -05:00
|
|
|
}
|
2013-10-04 02:33:10 -04:00
|
|
|
|
2014-03-18 13:00:48 -04:00
|
|
|
void
|
|
|
|
meta_wayland_seat_update (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
meta_wayland_seat_update_pointer (seat, event);
|
|
|
|
break;
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-13 15:41:29 -05:00
|
|
|
gboolean
|
|
|
|
meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *event)
|
|
|
|
{
|
2013-05-03 13:51:22 -04:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_MOTION:
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_motion_event (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_button_event (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2013-09-04 09:01:11 -04:00
|
|
|
return meta_wayland_keyboard_handle_event (&seat->keyboard,
|
|
|
|
(const ClutterKeyEvent *) event);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
case CLUTTER_SCROLL:
|
2013-09-11 08:06:05 -04:00
|
|
|
handle_scroll_event (seat, event);
|
2013-05-03 13:51:22 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-09-04 09:01:11 -04:00
|
|
|
|
|
|
|
return FALSE;
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The actor argument can be NULL in which case a Clutter pick will be
|
|
|
|
performed to determine the right actor. An actor should only be
|
|
|
|
passed if the repick is being performed due to an event in which
|
|
|
|
case Clutter will have already performed a pick so we can avoid
|
|
|
|
redundantly doing another one */
|
|
|
|
void
|
2013-09-11 08:06:05 -04:00
|
|
|
meta_wayland_seat_repick (MetaWaylandSeat *seat,
|
|
|
|
const ClutterEvent *for_event)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2013-09-11 08:06:05 -04:00
|
|
|
ClutterActor *actor = NULL;
|
2013-05-03 13:51:22 -04:00
|
|
|
MetaWaylandPointer *pointer = &seat->pointer;
|
|
|
|
MetaWaylandSurface *surface = NULL;
|
2014-03-16 15:32:52 -04:00
|
|
|
MetaDisplay *display = meta_get_display ();
|
|
|
|
|
2014-03-17 15:53:19 -04:00
|
|
|
if (meta_grab_op_is_wayland (display->grab_op))
|
2014-03-16 15:32:52 -04:00
|
|
|
{
|
|
|
|
meta_wayland_pointer_update_current_focus (pointer, NULL);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2013-09-11 08:06:05 -04:00
|
|
|
if (for_event)
|
|
|
|
{
|
|
|
|
actor = clutter_event_get_source (for_event);
|
|
|
|
}
|
|
|
|
else if (seat->current_stage)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (seat->current_stage);
|
|
|
|
actor = clutter_stage_get_actor_at_pos (stage,
|
|
|
|
CLUTTER_PICK_REACTIVE,
|
|
|
|
wl_fixed_to_double (pointer->x),
|
|
|
|
wl_fixed_to_double (pointer->y));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor)
|
|
|
|
seat->current_stage = clutter_actor_get_stage (actor);
|
|
|
|
else
|
|
|
|
seat->current_stage = NULL;
|
|
|
|
|
window-actor: Split into two subclasses of MetaSurfaceActor
The rendering logic before was somewhat complex. We had three independent
cases to take into account when doing rendering:
* X11 compositor. In this case, we're a traditional X11 compositor,
not a Wayland compositor. We use XCompositeNameWindowPixmap to get
the backing pixmap for the window, and deal with the COMPOSITE
extension messiness.
In this case, meta_is_wayland_compositor() is FALSE.
* Wayland clients. In this case, we're a Wayland compositor managing
Wayland surfaces. The rendering for this is fairly straightforward,
as Cogl handles most of the complexity with EGL and SHM buffers...
Wayland clients give us the input and opaque regions through
wl_surface.
In this case, meta_is_wayland_compositor() is TRUE and
priv->window->client_type == META_WINDOW_CLIENT_TYPE_WAYLAND.
* XWayland clients. In this case, we're a Wayland compositor, like
above, and XWayland hands us Wayland surfaces. XWayland handles
the COMPOSITE extension messiness for us, and hands us a buffer
like any other Wayland client. We have to fetch the input and
opaque regions from the X11 window ourselves.
In this case, meta_is_wayland_compositor() is TRUE and
priv->window->client_type == META_WINDOW_CLIENT_TYPE_X11.
We now split the rendering logic into two subclasses, which are:
* MetaSurfaceActorX11, which handles the X11 compositor case, in that
it uses XCompositeNameWindowPixmap to get the backing pixmap, and
deal with all the COMPOSITE extension messiness.
* MetaSurfaceActorWayland, which handles the Wayland compositor case
for both native Wayland clients and XWayland clients. XWayland handles
COMPOSITE for us, and handles pushing a surface over through the
xf86-video-wayland DDX.
Frame sync is still in MetaWindowActor, as it needs to work for both the
X11 compositor and XWayland client cases. When Wayland's video display
protocol lands, this will need to be significantly overhauled, as it would
have to work for any wl_surface, including subsurfaces, so we would need
surface-level discretion.
https://bugzilla.gnome.org/show_bug.cgi?id=720631
2014-02-01 17:21:11 -05:00
|
|
|
if (META_IS_SURFACE_ACTOR_WAYLAND (actor))
|
|
|
|
surface = meta_surface_actor_wayland_get_surface (META_SURFACE_ACTOR_WAYLAND (actor));
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-03-16 15:32:52 -04:00
|
|
|
meta_wayland_pointer_update_current_focus (pointer, surface);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_seat_free (MetaWaylandSeat *seat)
|
|
|
|
{
|
2014-02-01 17:18:21 -05:00
|
|
|
set_cursor_surface (seat, NULL);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
meta_wayland_pointer_release (&seat->pointer);
|
|
|
|
meta_wayland_keyboard_release (&seat->keyboard);
|
|
|
|
|
|
|
|
g_slice_free (MetaWaylandSeat, seat);
|
|
|
|
}
|