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-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"
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
unbind_resource (struct wl_resource *resource)
|
|
|
|
{
|
|
|
|
wl_list_remove (wl_resource_get_link (resource));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
seat_get_pointer (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
|
2014-04-17 16:41:37 -04:00
|
|
|
MetaWaylandPointer *pointer = &seat->pointer;
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-04-17 17:16:17 -04:00
|
|
|
meta_wayland_pointer_create_new_resource (pointer, client, resource, id);
|
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);
|
2014-04-17 16:41:37 -04:00
|
|
|
MetaWaylandKeyboard *keyboard = &seat->keyboard;
|
2013-05-03 13:51:22 -04:00
|
|
|
|
2014-04-17 18:22:26 -04:00
|
|
|
meta_wayland_keyboard_create_new_resource (keyboard, client, resource, id);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
seat_get_touch (struct wl_client *client,
|
|
|
|
struct wl_resource *resource,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
/* Touch not supported */
|
|
|
|
}
|
|
|
|
|
2014-04-17 16:36:45 -04:00
|
|
|
static const struct wl_seat_interface seat_interface = {
|
|
|
|
seat_get_pointer,
|
|
|
|
seat_get_keyboard,
|
|
|
|
seat_get_touch
|
|
|
|
};
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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-04-17 18:12:23 -04:00
|
|
|
meta_wayland_pointer_init (&seat->pointer, display);
|
2014-02-17 20:49:04 -05:00
|
|
|
meta_wayland_keyboard_init (&seat->keyboard, display);
|
2013-05-03 13:51:22 -04:00
|
|
|
|
|
|
|
seat->display = display;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:57:25 -04:00
|
|
|
void
|
|
|
|
meta_wayland_seat_free (MetaWaylandSeat *seat)
|
|
|
|
{
|
|
|
|
meta_wayland_pointer_release (&seat->pointer);
|
|
|
|
meta_wayland_keyboard_release (&seat->keyboard);
|
|
|
|
|
|
|
|
g_slice_free (MetaWaylandSeat, seat);
|
|
|
|
}
|
|
|
|
|
2014-04-17 19:07:43 -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:
|
2014-04-17 17:52:11 -04:00
|
|
|
meta_wayland_pointer_update (&seat->pointer, event);
|
2014-04-17 19:07:43 -04:00
|
|
|
break;
|
2014-04-17 17:52:11 -04:00
|
|
|
|
2014-04-17 19:07:43 -04:00
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
|
|
|
|
break;
|
2014-04-17 17:52:11 -04:00
|
|
|
|
2014-04-17 19:07:43 -04:00
|
|
|
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:
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
2014-04-17 19:10:39 -04:00
|
|
|
case CLUTTER_SCROLL:
|
2014-04-17 18:16:49 -04:00
|
|
|
return meta_wayland_pointer_handle_event (&seat->pointer, event);
|
2014-04-17 19:10:39 -04:00
|
|
|
|
2013-05-03 13:51:22 -04:00
|
|
|
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
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-09-04 09:01:11 -04:00
|
|
|
|
|
|
|
return FALSE;
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-17 18:46:14 -04:00
|
|
|
meta_wayland_seat_repick (MetaWaylandSeat *seat)
|
2013-05-03 13:51:22 -04:00
|
|
|
{
|
2014-04-17 18:16:49 -04:00
|
|
|
meta_wayland_pointer_repick (&seat->pointer);
|
2013-05-03 13:51:22 -04:00
|
|
|
}
|
2014-04-17 19:14:17 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
|
|
|
{
|
|
|
|
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
|
|
|
|
}
|