seat: Rewrite event handling in terms of MetaWaylandPointer
This commit is contained in:
parent
e15c260e56
commit
bdf55bc674
@ -283,13 +283,17 @@ pointer_constrain_callback (ClutterInputDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_pointer_init (MetaWaylandPointer *pointer)
|
meta_wayland_pointer_init (MetaWaylandPointer *pointer,
|
||||||
|
struct wl_display *display)
|
||||||
{
|
{
|
||||||
ClutterDeviceManager *manager;
|
ClutterDeviceManager *manager;
|
||||||
ClutterInputDevice *device;
|
ClutterInputDevice *device;
|
||||||
ClutterPoint current;
|
ClutterPoint current;
|
||||||
|
|
||||||
memset (pointer, 0, sizeof *pointer);
|
memset (pointer, 0, sizeof *pointer);
|
||||||
|
|
||||||
|
pointer->display = display;
|
||||||
|
|
||||||
wl_list_init (&pointer->resource_list);
|
wl_list_init (&pointer->resource_list);
|
||||||
wl_list_init (&pointer->focus_resource_list);
|
wl_list_init (&pointer->focus_resource_list);
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ struct _MetaWaylandPointerGrab
|
|||||||
|
|
||||||
struct _MetaWaylandPointer
|
struct _MetaWaylandPointer
|
||||||
{
|
{
|
||||||
|
struct wl_display *display;
|
||||||
|
|
||||||
struct wl_list resource_list;
|
struct wl_list resource_list;
|
||||||
struct wl_list focus_resource_list;
|
struct wl_list focus_resource_list;
|
||||||
|
|
||||||
@ -74,7 +76,8 @@ struct _MetaWaylandPointer
|
|||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_pointer_init (MetaWaylandPointer *pointer);
|
meta_wayland_pointer_init (MetaWaylandPointer *pointer,
|
||||||
|
struct wl_display *display);
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_wayland_pointer_release (MetaWaylandPointer *pointer);
|
meta_wayland_pointer_release (MetaWaylandPointer *pointer);
|
||||||
|
@ -141,7 +141,7 @@ meta_wayland_seat_new (struct wl_display *display)
|
|||||||
wl_list_init (&seat->base_resource_list);
|
wl_list_init (&seat->base_resource_list);
|
||||||
wl_list_init (&seat->data_device_resource_list);
|
wl_list_init (&seat->data_device_resource_list);
|
||||||
|
|
||||||
meta_wayland_pointer_init (&seat->pointer);
|
meta_wayland_pointer_init (&seat->pointer, display);
|
||||||
meta_wayland_keyboard_init (&seat->keyboard, display);
|
meta_wayland_keyboard_init (&seat->keyboard, display);
|
||||||
|
|
||||||
seat->display = display;
|
seat->display = display;
|
||||||
@ -184,11 +184,10 @@ meta_wayland_seat_update (MetaWaylandSeat *seat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
repick_for_event (MetaWaylandSeat *seat,
|
repick_for_event (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *for_event)
|
const ClutterEvent *for_event)
|
||||||
{
|
{
|
||||||
ClutterActor *actor = NULL;
|
ClutterActor *actor = NULL;
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
|
||||||
MetaWaylandSurface *surface = NULL;
|
MetaWaylandSurface *surface = NULL;
|
||||||
MetaDisplay *display = meta_get_display ();
|
MetaDisplay *display = meta_get_display ();
|
||||||
|
|
||||||
@ -222,31 +221,28 @@ repick_for_event (MetaWaylandSeat *seat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_motion (MetaWaylandSeat *seat,
|
notify_motion (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *event)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
repick_for_event (pointer, event);
|
||||||
|
|
||||||
repick_for_event (seat, event);
|
|
||||||
|
|
||||||
pointer->grab->interface->motion (pointer->grab, event);
|
pointer->grab->interface->motion (pointer->grab, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_motion_event (MetaWaylandSeat *seat,
|
handle_motion_event (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *event)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
notify_motion (seat, event);
|
notify_motion (pointer, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_button_event (MetaWaylandSeat *seat,
|
handle_button_event (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *event)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
|
||||||
gboolean implicit_grab;
|
gboolean implicit_grab;
|
||||||
|
|
||||||
notify_motion (seat, event);
|
notify_motion (pointer, event);
|
||||||
|
|
||||||
implicit_grab = (event->type == CLUTTER_BUTTON_PRESS) && (pointer->button_count == 1);
|
implicit_grab = (event->type == CLUTTER_BUTTON_PRESS) && (pointer->button_count == 1);
|
||||||
if (implicit_grab)
|
if (implicit_grab)
|
||||||
@ -260,19 +256,18 @@ handle_button_event (MetaWaylandSeat *seat,
|
|||||||
pointer->grab->interface->button (pointer->grab, event);
|
pointer->grab->interface->button (pointer->grab, event);
|
||||||
|
|
||||||
if (implicit_grab)
|
if (implicit_grab)
|
||||||
pointer->grab_serial = wl_display_get_serial (seat->display);
|
pointer->grab_serial = wl_display_get_serial (pointer->display);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_scroll_event (MetaWaylandSeat *seat,
|
handle_scroll_event (MetaWaylandPointer *pointer,
|
||||||
const ClutterEvent *event)
|
const ClutterEvent *event)
|
||||||
{
|
{
|
||||||
MetaWaylandPointer *pointer = &seat->pointer;
|
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wl_list *l;
|
struct wl_list *l;
|
||||||
wl_fixed_t x_value = 0, y_value = 0;
|
wl_fixed_t x_value = 0, y_value = 0;
|
||||||
|
|
||||||
notify_motion (seat, event);
|
notify_motion (pointer, event);
|
||||||
|
|
||||||
if (clutter_event_is_pointer_emulated (event))
|
if (clutter_event_is_pointer_emulated (event))
|
||||||
return;
|
return;
|
||||||
@ -327,16 +322,16 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case CLUTTER_MOTION:
|
case CLUTTER_MOTION:
|
||||||
handle_motion_event (seat, event);
|
handle_motion_event (&seat->pointer, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_BUTTON_PRESS:
|
case CLUTTER_BUTTON_PRESS:
|
||||||
case CLUTTER_BUTTON_RELEASE:
|
case CLUTTER_BUTTON_RELEASE:
|
||||||
handle_button_event (seat, event);
|
handle_button_event (&seat->pointer, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_SCROLL:
|
case CLUTTER_SCROLL:
|
||||||
handle_scroll_event (seat, event);
|
handle_scroll_event (&seat->pointer, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_KEY_PRESS:
|
case CLUTTER_KEY_PRESS:
|
||||||
@ -354,7 +349,7 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
|
|||||||
void
|
void
|
||||||
meta_wayland_seat_repick (MetaWaylandSeat *seat)
|
meta_wayland_seat_repick (MetaWaylandSeat *seat)
|
||||||
{
|
{
|
||||||
repick_for_event (seat, NULL);
|
repick_for_event (&seat->pointer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user