wayland: Make seat devices GObjects

This will make it possible to add signals and other GObject features.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
This commit is contained in:
Jonas Ådahl 2016-04-01 16:39:30 +08:00
parent d893adb290
commit e5a359a032
20 changed files with 193 additions and 121 deletions

View File

@ -505,7 +505,7 @@ meta_display_cancel_touch (MetaDisplay *display)
return;
compositor = meta_wayland_compositor_get_default ();
meta_wayland_touch_cancel (&compositor->seat->touch);
meta_wayland_touch_cancel (compositor->seat->touch);
#endif
}

View File

@ -620,7 +620,7 @@ meta_pointer_confinement_wayland_maybe_warp (MetaPointerConfinementWayland *self
seat = meta_wayland_pointer_constraint_get_seat (self->constraint);
surface = meta_wayland_pointer_constraint_get_surface (self->constraint);
clutter_input_device_get_coords (seat->pointer.device, NULL, &point);
clutter_input_device_get_coords (seat->pointer->device, NULL, &point);
meta_wayland_surface_get_relative_coordinates (surface,
point.x, point.y,
&sx, &sy);

View File

@ -465,7 +465,7 @@ primary_offer_receive (struct wl_client *client, struct wl_resource *resource,
seat = meta_wayland_data_source_get_seat (source);
if (wl_resource_get_client (offer->resource) !=
meta_wayland_keyboard_get_focus_client (&seat->keyboard))
meta_wayland_keyboard_get_focus_client (seat->keyboard))
{
close (fd);
return;
@ -979,7 +979,7 @@ drag_grab_button (MetaWaylandPointerGrab *grab,
drag_grab->feedback_actor = NULL;
}
if (seat->pointer.button_count == 0 &&
if (seat->pointer->button_count == 0 &&
event_type == CLUTTER_BUTTON_RELEASE)
data_device_end_drag_grab (drag_grab);
}
@ -1073,10 +1073,10 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data
data_device->current_grab = drag_grab = g_slice_new0 (MetaWaylandDragGrab);
drag_grab->generic.interface = funcs;
drag_grab->generic.pointer = &seat->pointer;
drag_grab->generic.pointer = seat->pointer;
drag_grab->keyboard_grab.interface = &keyboard_drag_grab_interface;
drag_grab->keyboard_grab.keyboard = &seat->keyboard;
drag_grab->keyboard_grab.keyboard = seat->keyboard;
drag_grab->drag_client = client;
drag_grab->seat = seat;
@ -1087,15 +1087,15 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data
&drag_grab->drag_origin_listener);
clutter_actor_transform_stage_point (CLUTTER_ACTOR (meta_surface_actor_get_texture (surface->surface_actor)),
seat->pointer.grab_x,
seat->pointer.grab_y,
seat->pointer->grab_x,
seat->pointer->grab_y,
&surface_pos.x, &surface_pos.y);
drag_grab->drag_start_x = surface_pos.x;
drag_grab->drag_start_y = surface_pos.y;
drag_grab->need_initial_focus = TRUE;
modifiers = clutter_input_device_get_modifier_state (seat->pointer.device);
modifiers = clutter_input_device_get_modifier_state (seat->pointer->device);
drag_grab->buttons = modifiers &
(CLUTTER_BUTTON1_MASK | CLUTTER_BUTTON2_MASK | CLUTTER_BUTTON3_MASK |
CLUTTER_BUTTON4_MASK | CLUTTER_BUTTON5_MASK);
@ -1121,12 +1121,13 @@ meta_wayland_data_device_start_drag (MetaWaylandDataDevice *data
clutter_actor_add_child (drag_grab->feedback_actor,
CLUTTER_ACTOR (drag_grab->drag_surface->surface_actor));
clutter_input_device_get_coords (seat->pointer.device, NULL, &pos);
clutter_input_device_get_coords (seat->pointer->device, NULL, &pos);
meta_feedback_actor_set_position (META_FEEDBACK_ACTOR (drag_grab->feedback_actor),
pos.x, pos.y);
}
meta_wayland_pointer_start_grab (&seat->pointer, (MetaWaylandPointerGrab*) drag_grab);
meta_wayland_pointer_start_grab (seat->pointer,
(MetaWaylandPointerGrab*) drag_grab);
meta_wayland_data_source_set_seat (source, seat);
}
@ -1155,16 +1156,16 @@ data_device_start_drag (struct wl_client *client,
if (!surface)
return;
if (seat->pointer.button_count == 0 ||
seat->pointer.grab_serial != serial ||
!seat->pointer.focus_surface ||
seat->pointer.focus_surface != surface)
if (seat->pointer->button_count == 0 ||
seat->pointer->grab_serial != serial ||
!seat->pointer->focus_surface ||
seat->pointer->focus_surface != surface)
return;
/* FIXME: Check that the data source type array isn't empty. */
if (data_device->current_grab ||
seat->pointer.grab != &seat->pointer.default_grab)
seat->pointer->grab != &seat->pointer->default_grab)
return;
if (icon_resource)
@ -1183,13 +1184,13 @@ data_device_start_drag (struct wl_client *client,
return;
}
meta_wayland_pointer_set_focus (&seat->pointer, NULL);
meta_wayland_pointer_set_focus (seat->pointer, NULL);
meta_wayland_data_device_start_drag (data_device, client,
&drag_grab_interface,
surface, drag_source, icon_surface);
meta_wayland_keyboard_set_focus (&seat->keyboard, NULL);
meta_wayland_keyboard_start_grab (&seat->keyboard,
meta_wayland_keyboard_set_focus (seat->keyboard, NULL);
meta_wayland_keyboard_start_grab (seat->keyboard,
&seat->data_device.current_grab->keyboard_grab);
}
@ -1203,7 +1204,7 @@ selection_data_source_destroyed (gpointer data, GObject *object_was_here)
data_device->selection_data_source = NULL;
focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
if (focus_client)
{
data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client);
@ -1529,7 +1530,7 @@ meta_wayland_data_device_set_selection (MetaWaylandDataDevice *data_device,
data_device->selection_data_source = source;
data_device->selection_serial = serial;
focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
if (focus_client)
{
data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client);
@ -1606,7 +1607,7 @@ primary_source_destroyed (gpointer data,
data_device->primary_data_source = NULL;
focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
if (focus_client)
{
struct wl_resource *data_device_resource;
@ -1635,7 +1636,7 @@ meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
resource = META_WAYLAND_DATA_SOURCE_PRIMARY (source)->resource;
if (wl_resource_get_client (resource) !=
meta_wayland_keyboard_get_focus_client (&seat->keyboard))
meta_wayland_keyboard_get_focus_client (seat->keyboard))
return;
}
@ -1654,7 +1655,7 @@ meta_wayland_data_device_set_primary (MetaWaylandDataDevice *data_device,
data_device->primary_data_source = source;
data_device->primary_serial = serial;
focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
if (focus_client)
{
data_device_resource = wl_resource_find_for_client (&data_device->primary_resource_list, focus_client);
@ -1840,7 +1841,7 @@ meta_wayland_data_device_set_keyboard_focus (MetaWaylandDataDevice *data_device)
struct wl_resource *data_device_resource, *offer;
MetaWaylandDataSource *source;
focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard);
focus_client = meta_wayland_keyboard_get_focus_client (seat->keyboard);
if (focus_client == data_device->focus_client)
return;

View File

@ -65,6 +65,8 @@
#include "backends/native/meta-backend-native.h"
#endif
G_DEFINE_TYPE (MetaWaylandKeyboard, meta_wayland_keyboard, G_TYPE_OBJECT);
static void meta_wayland_keyboard_update_xkb_state (MetaWaylandKeyboard *keyboard);
static void notify_modifiers (MetaWaylandKeyboard *keyboard);
static guint evdev_code (const ClutterKeyEvent *event);
@ -342,7 +344,7 @@ meta_wayland_keyboard_broadcast_modifiers (MetaWaylandKeyboard *keyboard)
l = &keyboard->focus_resource_list;
if (!wl_list_empty (l))
{
uint32_t serial = wl_display_next_serial (keyboard->display);
uint32_t serial = wl_display_next_serial (keyboard->seat->wl_display);
wl_resource_for_each (resource, l)
keyboard_send_modifiers (keyboard, resource, serial);
@ -478,14 +480,12 @@ static const MetaWaylandKeyboardGrabInterface default_keyboard_grab_interface =
};
void
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
struct wl_display *display)
meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard,
MetaWaylandSeat *seat)
{
MetaBackend *backend = meta_get_backend ();
memset (keyboard, 0, sizeof *keyboard);
keyboard->display = display;
keyboard->seat = seat;
wl_list_init (&keyboard->resource_list);
wl_list_init (&keyboard->focus_resource_list);
@ -512,17 +512,20 @@ meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
static void
meta_wayland_xkb_info_destroy (MetaWaylandXkbInfo *xkb_info)
{
xkb_keymap_unref (xkb_info->keymap);
xkb_state_unref (xkb_info->state);
g_clear_pointer (&xkb_info->keymap, xkb_keymap_unref);
g_clear_pointer (&xkb_info->state, xkb_state_unref);
if (xkb_info->keymap_area)
munmap (xkb_info->keymap_area, xkb_info->keymap_size);
{
munmap (xkb_info->keymap_area, xkb_info->keymap_size);
xkb_info->keymap_area = NULL;
}
if (xkb_info->keymap_fd >= 0)
close (xkb_info->keymap_fd);
}
void
meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard)
meta_wayland_keyboard_disable (MetaWaylandKeyboard *keyboard)
{
MetaBackend *backend = meta_get_backend ();
@ -534,9 +537,9 @@ meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard)
/* XXX: What about keyboard->resource_list? */
g_object_unref (keyboard->settings);
g_clear_object (&keyboard->settings);
keyboard->display = NULL;
keyboard->seat = NULL;
}
static guint
@ -682,7 +685,7 @@ void
meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
MetaWaylandSurface *surface)
{
if (keyboard->display == NULL)
if (keyboard->seat == NULL)
return;
if (keyboard->focus_surface == surface)
@ -809,3 +812,13 @@ meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard)
{
keyboard->grab = &keyboard->default_grab;
}
static void
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard)
{
}
static void
meta_wayland_keyboard_class_init (MetaWaylandKeyboardClass *klass)
{
}

View File

@ -49,6 +49,13 @@
#include <wayland-server.h>
#include <xkbcommon/xkbcommon.h>
#include "wayland/meta-wayland-types.h"
#define META_TYPE_WAYLAND_KEYBOARD (meta_wayland_keyboard_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandKeyboard, meta_wayland_keyboard,
META, WAYLAND_KEYBOARD,
GObject);
struct _MetaWaylandKeyboardGrabInterface
{
gboolean (*key) (MetaWaylandKeyboardGrab *grab,
@ -74,7 +81,9 @@ typedef struct
struct _MetaWaylandKeyboard
{
struct wl_display *display;
GObject parent;
MetaWaylandSeat *seat;
struct wl_list resource_list;
struct wl_list focus_resource_list;
@ -93,10 +102,10 @@ struct _MetaWaylandKeyboard
GSettings *settings;
};
void meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard,
struct wl_display *display);
void meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard,
MetaWaylandSeat *seat);
void meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard);
void meta_wayland_keyboard_disable (MetaWaylandKeyboard *keyboard);
void meta_wayland_keyboard_update (MetaWaylandKeyboard *keyboard,
const ClutterKeyEvent *event);

View File

@ -329,7 +329,7 @@ meta_wayland_pointer_constraint_enable (MetaWaylandPointerConstraint *constraint
constraint->is_enabled = TRUE;
meta_wayland_pointer_constraint_notify_activated (constraint);
meta_wayland_pointer_start_grab (&constraint->seat->pointer,
meta_wayland_pointer_start_grab (constraint->seat->pointer,
&constraint->grab);
constraint->constraint =
@ -394,7 +394,7 @@ meta_wayland_pointer_constraint_maybe_enable (MetaWaylandPointerConstraint *cons
if (!meta_window_appears_focused (constraint->surface->window))
return;
meta_wayland_pointer_get_relative_coordinates (&constraint->seat->pointer,
meta_wayland_pointer_get_relative_coordinates (constraint->seat->pointer,
constraint->surface,
&sx, &sy);
if (!is_within_constraint_region (constraint, sx, sy))
@ -416,7 +416,7 @@ void
meta_wayland_pointer_constraint_maybe_remove_for_seat (MetaWaylandSeat *seat,
MetaWindow *window)
{
MetaWaylandPointer *pointer = &seat->pointer;
MetaWaylandPointer *pointer = seat->pointer;
MetaWaylandPointerConstraint *constraint;
if ((pointer->grab->interface != &confined_pointer_grab_interface &&

View File

@ -27,6 +27,7 @@
#include "meta-wayland-pointer-gesture-pinch.h"
#include "meta-wayland-pointer.h"
#include "meta-wayland-seat.h"
#include "meta-wayland-surface.h"
#include "pointer-gestures-unstable-v1-server-protocol.h"
@ -39,7 +40,7 @@ handle_pinch_begin (MetaWaylandPointer *pointer,
uint32_t serial;
pointer_client = pointer->focus_client;
serial = wl_display_next_serial (pointer->display);
serial = wl_display_next_serial (pointer->seat->wl_display);
wl_resource_for_each (resource, &pointer_client->pinch_gesture_resources)
{
@ -84,7 +85,7 @@ handle_pinch_end (MetaWaylandPointer *pointer,
uint32_t serial;
pointer_client = pointer->focus_client;
serial = wl_display_next_serial (pointer->display);
serial = wl_display_next_serial (pointer->seat->wl_display);
if (event->touchpad_pinch.phase == CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL)
cancelled = TRUE;

View File

@ -27,6 +27,7 @@
#include "meta-wayland-pointer-gesture-swipe.h"
#include "meta-wayland-pointer.h"
#include "meta-wayland-seat.h"
#include "meta-wayland-surface.h"
#include "pointer-gestures-unstable-v1-server-protocol.h"
@ -39,7 +40,7 @@ handle_swipe_begin (MetaWaylandPointer *pointer,
uint32_t serial, fingers;
pointer_client = pointer->focus_client;
serial = wl_display_next_serial (pointer->display);
serial = wl_display_next_serial (pointer->seat->wl_display);
fingers = clutter_event_get_gesture_swipe_finger_count (event);
wl_resource_for_each (resource, &pointer_client->swipe_gesture_resources)
@ -81,7 +82,7 @@ handle_swipe_end (MetaWaylandPointer *pointer,
uint32_t serial;
pointer_client = pointer->focus_client;
serial = wl_display_next_serial (pointer->display);
serial = wl_display_next_serial (pointer->seat->wl_display);
if (event->touchpad_swipe.phase == CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL)
cancelled = TRUE;

View File

@ -52,6 +52,7 @@
#include "meta-wayland-pointer.h"
#include "meta-wayland-popup.h"
#include "meta-wayland-private.h"
#include "meta-wayland-seat.h"
#include "meta-wayland-surface.h"
#include "meta-wayland-buffer.h"
#include "meta-wayland-surface-role-cursor.h"
@ -74,6 +75,8 @@
#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10)
G_DEFINE_TYPE (MetaWaylandPointer, meta_wayland_pointer, G_TYPE_OBJECT);
static MetaWaylandPointerClient *
meta_wayland_pointer_client_new (void)
{
@ -444,15 +447,13 @@ meta_wayland_pointer_on_cursor_changed (MetaCursorTracker *cursor_tracker,
}
void
meta_wayland_pointer_init (MetaWaylandPointer *pointer,
struct wl_display *display)
meta_wayland_pointer_enable (MetaWaylandPointer *pointer,
MetaWaylandSeat *seat)
{
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
ClutterDeviceManager *manager;
memset (pointer, 0, sizeof *pointer);
pointer->display = display;
pointer->seat = seat;
pointer->pointer_clients =
g_hash_table_new_full (NULL, NULL, NULL,
@ -476,7 +477,7 @@ meta_wayland_pointer_init (MetaWaylandPointer *pointer,
}
void
meta_wayland_pointer_release (MetaWaylandPointer *pointer)
meta_wayland_pointer_disable (MetaWaylandPointer *pointer)
{
MetaCursorTracker *cursor_tracker = meta_cursor_tracker_get_for_screen (NULL);
@ -493,7 +494,7 @@ meta_wayland_pointer_release (MetaWaylandPointer *pointer)
meta_wayland_pointer_set_focus (pointer, NULL);
g_clear_pointer (&pointer->pointer_clients, g_hash_table_unref);
pointer->display = NULL;
pointer->seat = NULL;
pointer->cursor_surface = NULL;
}
@ -579,7 +580,7 @@ handle_button_event (MetaWaylandPointer *pointer,
pointer->grab->interface->button (pointer->grab, event);
if (implicit_grab)
pointer->grab_serial = wl_display_get_serial (pointer->display);
pointer->grab_serial = wl_display_get_serial (pointer->seat->wl_display);
}
static void
@ -786,7 +787,7 @@ void
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface)
{
if (pointer->display == NULL)
if (pointer->seat == NULL)
return;
if (pointer->focus_surface == surface)
@ -1194,6 +1195,15 @@ meta_wayland_relative_pointer_init (MetaWaylandCompositor *compositor)
MetaWaylandSeat *
meta_wayland_pointer_get_seat (MetaWaylandPointer *pointer)
{
MetaWaylandSeat *seat = wl_container_of (pointer, seat, pointer);
return seat;
return pointer->seat;
}
static void
meta_wayland_pointer_init (MetaWaylandPointer *pointer)
{
}
static void
meta_wayland_pointer_class_init (MetaWaylandPointerClass *klass)
{
}

View File

@ -32,6 +32,10 @@
#include <meta/meta-cursor-tracker.h>
#define META_TYPE_WAYLAND_POINTER (meta_wayland_pointer_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandPointer, meta_wayland_pointer,
META, WAYLAND_POINTER, GObject);
struct _MetaWaylandPointerGrabInterface
{
void (*focus) (MetaWaylandPointerGrab *grab,
@ -58,7 +62,9 @@ struct _MetaWaylandPointerClient
struct _MetaWaylandPointer
{
struct wl_display *display;
GObject parent;
MetaWaylandSeat *seat;
MetaWaylandPointerClient *focus_client;
GHashTable *pointer_clients;
@ -84,10 +90,10 @@ struct _MetaWaylandPointer
guint32 button_count;
};
void meta_wayland_pointer_init (MetaWaylandPointer *pointer,
struct wl_display *display);
void meta_wayland_pointer_enable (MetaWaylandPointer *pointer,
MetaWaylandSeat *seat);
void meta_wayland_pointer_release (MetaWaylandPointer *pointer);
void meta_wayland_pointer_disable (MetaWaylandPointer *pointer);
void meta_wayland_pointer_update (MetaWaylandPointer *pointer,
const ClutterEvent *event);

View File

@ -253,7 +253,7 @@ meta_wayland_popup_dismiss (MetaWaylandPopup *popup)
top_popup_surface = meta_wayland_popup_grab_get_top_popup (popup_grab);
seat = meta_wayland_pointer_get_seat (popup_grab->generic.pointer);
keyboard = &seat->keyboard;
keyboard = seat->keyboard;
meta_wayland_keyboard_set_focus (keyboard, top_popup_surface);
}
}
@ -285,7 +285,7 @@ meta_wayland_popup_create (MetaWaylandPopupSurface *popup_surface,
wl_list_insert (&grab->all_popups, &popup->link);
seat = meta_wayland_pointer_get_seat (grab->generic.pointer);
keyboard = &seat->keyboard;
keyboard = seat->keyboard;
meta_wayland_keyboard_set_focus (keyboard, surface);
return popup;

View File

@ -43,7 +43,7 @@ seat_get_pointer (struct wl_client *client,
uint32_t id)
{
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
MetaWaylandPointer *pointer = &seat->pointer;
MetaWaylandPointer *pointer = seat->pointer;
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0)
meta_wayland_pointer_create_new_resource (pointer, client, resource, id);
@ -55,7 +55,7 @@ seat_get_keyboard (struct wl_client *client,
uint32_t id)
{
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
MetaWaylandKeyboard *keyboard = &seat->keyboard;
MetaWaylandKeyboard *keyboard = seat->keyboard;
if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) != 0)
meta_wayland_keyboard_create_new_resource (keyboard, client, resource, id);
@ -67,7 +67,7 @@ seat_get_touch (struct wl_client *client,
uint32_t id)
{
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
MetaWaylandTouch *touch = &seat->touch;
MetaWaylandTouch *touch = seat->touch;
if ((seat->capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0)
meta_wayland_touch_create_new_resource (touch, client, resource, id);
@ -157,15 +157,15 @@ meta_wayland_seat_set_capabilities (MetaWaylandSeat *seat,
seat->capabilities = flags;
if (CAPABILITY_ENABLED (prev_flags, flags, WL_SEAT_CAPABILITY_POINTER))
meta_wayland_pointer_init (&seat->pointer, seat->wl_display);
meta_wayland_pointer_enable (seat->pointer, seat);
else if (CAPABILITY_DISABLED (prev_flags, flags, WL_SEAT_CAPABILITY_POINTER))
meta_wayland_pointer_release (&seat->pointer);
meta_wayland_pointer_disable (seat->pointer);
if (CAPABILITY_ENABLED (prev_flags, flags, WL_SEAT_CAPABILITY_KEYBOARD))
{
MetaDisplay *display;
meta_wayland_keyboard_init (&seat->keyboard, seat->wl_display);
meta_wayland_keyboard_enable (seat->keyboard, seat);
display = meta_get_display ();
/* Post-initialization, ensure the input focus is in sync */
@ -173,12 +173,12 @@ meta_wayland_seat_set_capabilities (MetaWaylandSeat *seat,
meta_display_sync_wayland_input_focus (display);
}
else if (CAPABILITY_DISABLED (prev_flags, flags, WL_SEAT_CAPABILITY_KEYBOARD))
meta_wayland_keyboard_release (&seat->keyboard);
meta_wayland_keyboard_disable (seat->keyboard);
if (CAPABILITY_ENABLED (prev_flags, flags, WL_SEAT_CAPABILITY_TOUCH))
meta_wayland_touch_init (&seat->touch, seat->wl_display);
meta_wayland_touch_enable (seat->touch, seat);
else if (CAPABILITY_DISABLED (prev_flags, flags, WL_SEAT_CAPABILITY_TOUCH))
meta_wayland_touch_release (&seat->touch);
meta_wayland_touch_disable (seat->touch);
/* Broadcast capability changes */
wl_resource_for_each (resource, &seat->base_resource_list)
@ -215,6 +215,10 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
wl_list_init (&seat->base_resource_list);
seat->wl_display = display;
seat->pointer = g_object_new (META_TYPE_WAYLAND_POINTER, NULL);
seat->keyboard = g_object_new (META_TYPE_WAYLAND_KEYBOARD, NULL);
seat->touch = g_object_new (META_TYPE_WAYLAND_TOUCH, NULL);
meta_wayland_data_device_init (&seat->data_device);
device_manager = clutter_device_manager_get_default ();
@ -247,6 +251,10 @@ meta_wayland_seat_free (MetaWaylandSeat *seat)
g_signal_handlers_disconnect_by_data (device_manager, seat);
meta_wayland_seat_set_capabilities (seat, 0);
g_object_unref (seat->pointer);
g_object_unref (seat->keyboard);
g_object_unref (seat->touch);
g_slice_free (MetaWaylandSeat, seat);
}
@ -306,20 +314,20 @@ meta_wayland_seat_update (MetaWaylandSeat *seat,
case CLUTTER_BUTTON_RELEASE:
case CLUTTER_SCROLL:
if (seat->capabilities & WL_SEAT_CAPABILITY_POINTER)
meta_wayland_pointer_update (&seat->pointer, event);
meta_wayland_pointer_update (seat->pointer, event);
break;
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
if (seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD)
meta_wayland_keyboard_update (&seat->keyboard, (const ClutterKeyEvent *) event);
meta_wayland_keyboard_update (seat->keyboard, (const ClutterKeyEvent *) event);
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
if (seat->capabilities & WL_SEAT_CAPABILITY_TOUCH)
meta_wayland_touch_update (&seat->touch, event);
meta_wayland_touch_update (seat->touch, event);
break;
default:
@ -343,18 +351,18 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
case CLUTTER_TOUCHPAD_SWIPE:
case CLUTTER_TOUCHPAD_PINCH:
if (seat->capabilities & WL_SEAT_CAPABILITY_POINTER)
return meta_wayland_pointer_handle_event (&seat->pointer, event);
return meta_wayland_pointer_handle_event (seat->pointer, event);
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
if (seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD)
return meta_wayland_keyboard_handle_event (&seat->keyboard,
return meta_wayland_keyboard_handle_event (seat->keyboard,
(const ClutterKeyEvent *) event);
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
if (seat->capabilities & WL_SEAT_CAPABILITY_TOUCH)
return meta_wayland_touch_handle_event (&seat->touch, event);
return meta_wayland_touch_handle_event (seat->touch, event);
default:
break;
@ -369,7 +377,7 @@ meta_wayland_seat_repick (MetaWaylandSeat *seat)
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0)
return;
meta_wayland_pointer_repick (&seat->pointer);
meta_wayland_pointer_repick (seat->pointer);
}
void
@ -381,7 +389,7 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
if ((seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) != 0)
{
meta_wayland_keyboard_set_focus (&seat->keyboard, surface);
meta_wayland_keyboard_set_focus (seat->keyboard, surface);
meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
}
@ -401,24 +409,28 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
gboolean can_grab_surface = FALSE;
if ((seat->capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0)
sequence = meta_wayland_touch_find_grab_sequence (&seat->touch, surface, serial);
sequence = meta_wayland_touch_find_grab_sequence (seat->touch,
surface,
serial);
if (sequence)
{
meta_wayland_touch_get_press_coords (&seat->touch, sequence, x, y);
meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y);
}
else
{
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) != 0 &&
(!require_pressed || seat->pointer.button_count > 0))
can_grab_surface = meta_wayland_pointer_can_grab_surface (&seat->pointer, surface, serial);
(!require_pressed || seat->pointer->button_count > 0))
can_grab_surface = meta_wayland_pointer_can_grab_surface (seat->pointer,
surface,
serial);
if (can_grab_surface)
{
if (x)
*x = seat->pointer.grab_x;
*x = seat->pointer->grab_x;
if (y)
*y = seat->pointer.grab_y;
*y = seat->pointer->grab_y;
}
}
@ -429,7 +441,7 @@ gboolean
meta_wayland_seat_can_popup (MetaWaylandSeat *seat,
uint32_t serial)
{
return (meta_wayland_pointer_can_popup (&seat->pointer, serial) ||
meta_wayland_keyboard_can_popup (&seat->keyboard, serial) ||
meta_wayland_touch_can_popup (&seat->touch, serial));
return (meta_wayland_pointer_can_popup (seat->pointer, serial) ||
meta_wayland_keyboard_can_popup (seat->keyboard, serial) ||
meta_wayland_touch_can_popup (seat->touch, serial));
}

View File

@ -36,9 +36,10 @@ struct _MetaWaylandSeat
struct wl_list base_resource_list;
struct wl_display *wl_display;
MetaWaylandPointer pointer;
MetaWaylandKeyboard keyboard;
MetaWaylandTouch touch;
MetaWaylandPointer *pointer;
MetaWaylandKeyboard *keyboard;
MetaWaylandTouch *touch;
MetaWaylandDataDevice data_device;
guint capabilities;

View File

@ -204,7 +204,7 @@ static void
meta_wayland_tablet_seat_device_added (MetaWaylandTabletSeat *tablet_seat,
ClutterInputDevice *device)
{
MetaWaylandSurface *pad_focus = tablet_seat->seat->keyboard.focus_surface;
MetaWaylandSurface *pad_focus = tablet_seat->seat->keyboard->focus_surface;
if (is_tablet_device (device))
{

View File

@ -34,6 +34,8 @@
#include "backends/native/meta-backend-native.h"
#endif
G_DEFINE_TYPE (MetaWaylandTouch, meta_wayland_touch, G_TYPE_OBJECT);
struct _MetaWaylandTouchSurface
{
MetaWaylandSurface *surface;
@ -454,7 +456,7 @@ meta_wayland_touch_cancel (MetaWaylandTouch *touch)
{
GList *surfaces, *s;
if (touch->display == NULL)
if (touch->seat == NULL)
return;
surfaces = s = touch_get_surfaces (touch, FALSE);
@ -514,14 +516,12 @@ evdev_filter_func (struct libinput_event *event,
#endif
void
meta_wayland_touch_init (MetaWaylandTouch *touch,
struct wl_display *display)
meta_wayland_touch_enable (MetaWaylandTouch *touch,
MetaWaylandSeat *seat)
{
ClutterDeviceManager *manager;
memset (touch, 0, sizeof *touch);
touch->display = display;
touch->seat = seat;
touch->touch_surfaces = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) touch_surface_free);
touch->touches = g_hash_table_new_full (NULL, NULL, NULL,
@ -540,7 +540,7 @@ meta_wayland_touch_init (MetaWaylandTouch *touch,
}
void
meta_wayland_touch_release (MetaWaylandTouch *touch)
meta_wayland_touch_disable (MetaWaylandTouch *touch)
{
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
@ -550,7 +550,7 @@ meta_wayland_touch_release (MetaWaylandTouch *touch)
g_clear_pointer (&touch->touch_surfaces, (GDestroyNotify) g_hash_table_unref);
g_clear_pointer (&touch->touches, (GDestroyNotify) g_hash_table_unref);
touch->display = NULL;
touch->seat = NULL;
}
void
@ -561,7 +561,7 @@ meta_wayland_touch_create_new_resource (MetaWaylandTouch *touch,
{
struct wl_resource *cr;
if (touch->display == NULL)
if (touch->seat == NULL)
{
wl_resource_post_error (seat_resource, WL_DISPLAY_ERROR_INVALID_METHOD,
"Cannot retrieve touch interface without touch capability");
@ -641,3 +641,13 @@ meta_wayland_touch_get_press_coords (MetaWaylandTouch *touch,
return TRUE;
}
static void
meta_wayland_touch_init (MetaWaylandTouch *touch)
{
}
static void
meta_wayland_touch_class_init (MetaWaylandTouchClass *klass)
{
}

View File

@ -28,12 +28,21 @@
#include "meta-wayland-types.h"
#define META_TYPE_WAYLAND_TOUCH (meta_wayland_touch_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandTouch, meta_wayland_touch,
META, WAYLAND_TOUCH,
GObject);
typedef struct _MetaWaylandTouchSurface MetaWaylandTouchSurface;
typedef struct _MetaWaylandTouchInfo MetaWaylandTouchInfo;
struct _MetaWaylandTouch
{
struct wl_display *display;
GObject parent;
MetaWaylandSeat *seat;
struct wl_list resource_list;
GHashTable *touch_surfaces; /* HT of MetaWaylandSurface->MetaWaylandTouchSurface */
@ -43,10 +52,10 @@ struct _MetaWaylandTouch
guint64 frame_slots;
};
void meta_wayland_touch_init (MetaWaylandTouch *touch,
struct wl_display *display);
void meta_wayland_touch_enable (MetaWaylandTouch *touch,
MetaWaylandSeat *seat);
void meta_wayland_touch_release (MetaWaylandTouch *touch);
void meta_wayland_touch_disable (MetaWaylandTouch *touch);
void meta_wayland_touch_update (MetaWaylandTouch *touch,
const ClutterEvent *event);

View File

@ -324,7 +324,7 @@ meta_wayland_wl_shell_surface_create_popup (MetaWaylandWlShellSurface *wl_shell_
MetaWaylandSeat *seat = wl_shell_surface->popup_seat;
MetaWaylandPopup *popup;
popup = meta_wayland_pointer_start_popup_grab (&seat->pointer, popup_surface);
popup = meta_wayland_pointer_start_popup_grab (seat->pointer, popup_surface);
if (!popup)
{
wl_shell_surface_send_popup_done (wl_shell_surface->resource);

View File

@ -442,7 +442,7 @@ xdg_popup_grab (struct wl_client *client,
return;
}
top_popup = meta_wayland_pointer_get_top_popup (&seat->pointer);
top_popup = meta_wayland_pointer_get_top_popup (seat->pointer);
if ((top_popup == NULL &&
!META_IS_WAYLAND_XDG_SURFACE (parent_surface->role)) ||
(top_popup != NULL && parent_surface != top_popup))
@ -803,7 +803,7 @@ finish_popup_setup (MetaWaylandXdgPopup *xdg_popup)
meta_window_focus (window, meta_display_get_current_time (display));
popup_surface = META_WAYLAND_POPUP_SURFACE (surface->role);
popup = meta_wayland_pointer_start_popup_grab (&seat->pointer,
popup = meta_wayland_pointer_start_popup_grab (seat->pointer,
popup_surface);
if (popup == NULL)
{
@ -1675,7 +1675,6 @@ meta_wayland_xdg_positioner_set_constraint_adjustment (struct wl_client *clien
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_X |
ZXDG_POSITIONER_V6_CONSTRAINT_ADJUSTMENT_RESIZE_Y);
if ((constraint_adjustment & ~all_adjustments) != 0)
{
wl_resource_post_error (resource, ZXDG_POSITIONER_V6_ERROR_INVALID_INPUT,

View File

@ -226,7 +226,7 @@ meta_wayland_compositor_update_key_state (MetaWaylandCompositor *compositor,
int key_vector_len,
int offset)
{
meta_wayland_keyboard_update_key_state (&compositor->seat->keyboard,
meta_wayland_keyboard_update_key_state (compositor->seat->keyboard,
key_vector, key_vector_len, offset);
}

View File

@ -972,7 +972,7 @@ meta_x11_drag_dest_update (MetaWaylandDataDevice *data_device,
MetaWaylandSeat *seat = compositor->seat;
ClutterPoint pos;
clutter_input_device_get_coords (seat->pointer.device, NULL, &pos);
clutter_input_device_get_coords (seat->pointer->device, NULL, &pos);
xdnd_send_position (compositor->xwayland_manager.selection_data,
compositor->xwayland_manager.selection_data->dnd.dnd_dest,
clutter_get_current_event_time (),
@ -1378,7 +1378,7 @@ drag_xgrab_motion (MetaWaylandPointerGrab *grab,
event);
dnd->last_motion_time = clutter_event_get_time (event);
meta_wayland_pointer_send_motion (&seat->pointer, event);
meta_wayland_pointer_send_motion (seat->pointer, event);
}
static void
@ -1388,7 +1388,7 @@ drag_xgrab_button (MetaWaylandPointerGrab *grab,
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
MetaWaylandSeat *seat = compositor->seat;
meta_wayland_pointer_send_button (&seat->pointer, event);
meta_wayland_pointer_send_button (seat->pointer, event);
}
static const MetaWaylandPointerGrabInterface drag_xgrab_interface = {
@ -1499,10 +1499,10 @@ meta_xwayland_selection_handle_client_message (MetaWaylandCompositor *compositor
uint32_t action = 0;
motion = clutter_event_new (CLUTTER_MOTION);
clutter_input_device_get_coords (seat->pointer.device, NULL, &pos);
clutter_input_device_get_coords (seat->pointer->device, NULL, &pos);
clutter_event_set_coords (motion, pos.x, pos.y);
clutter_event_set_device (motion, seat->pointer.device);
clutter_event_set_source_device (motion, seat->pointer.device);
clutter_event_set_device (motion, seat->pointer->device);
clutter_event_set_source_device (motion, seat->pointer->device);
clutter_event_set_time (motion, dnd->last_motion_time);
action = atom_to_action ((Atom) event->data.l[4]);
@ -1591,7 +1591,7 @@ meta_xwayland_selection_handle_xfixes_selection_notify (MetaWaylandCompositor *c
{
MetaWaylandSurface *focus;
focus = compositor->seat->pointer.focus_surface;
focus = compositor->seat->pointer->focus_surface;
selection->source = meta_wayland_data_source_xwayland_new (selection);
meta_wayland_data_device_set_dnd_source (&compositor->seat->data_device,
selection->source);