clutter: Make ClutterSeat::handle_device_event vfunc more generic

Make it able to handle not just device added/removed events, but perform
any kind of post-processing that needed to be done on ClutterEvents at
the seat level.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
Carlos Garnacho 2020-08-11 11:27:18 +02:00
parent 92bc79fd51
commit a2616d83e8
7 changed files with 22 additions and 28 deletions

View File

@ -1935,13 +1935,7 @@ _clutter_process_event_details (ClutterActor *stage,
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
if (!_clutter_event_process_filters (event))
{
ClutterSeat *seat;
seat = clutter_backend_get_default_seat (context->backend);
clutter_seat_handle_device_event (seat, event);
}
_clutter_event_process_filters (event);
break;
case CLUTTER_EVENT_LAST:

View File

@ -71,6 +71,9 @@ gboolean clutter_actor_has_transitions (ClutterActor *actor);
CLUTTER_EXPORT
ClutterFrameClock * clutter_actor_pick_frame_clock (ClutterActor *self,
ClutterActor **out_actor);
CLUTTER_EXPORT
gboolean clutter_seat_handle_event_post (ClutterSeat *seat,
const ClutterEvent *event);
#undef __CLUTTER_H_INSIDE__

View File

@ -27,6 +27,7 @@
#include "clutter-input-device-tool.h"
#include "clutter-input-pointer-a11y-private.h"
#include "clutter-marshal.h"
#include "clutter-mutter.h"
#include "clutter-private.h"
#include "clutter-seat.h"
#include "clutter-virtual-input-device.h"
@ -635,8 +636,8 @@ clutter_seat_compress_motion (ClutterSeat *seat,
}
gboolean
clutter_seat_handle_device_event (ClutterSeat *seat,
ClutterEvent *event)
clutter_seat_handle_event_post (ClutterSeat *seat,
const ClutterEvent *event)
{
ClutterSeatClass *seat_class;
ClutterInputDevice *device;
@ -644,16 +645,10 @@ clutter_seat_handle_device_event (ClutterSeat *seat,
g_return_val_if_fail (CLUTTER_IS_SEAT (seat), FALSE);
g_return_val_if_fail (event, FALSE);
g_assert (event->type == CLUTTER_DEVICE_ADDED ||
event->type == CLUTTER_DEVICE_REMOVED);
seat_class = CLUTTER_SEAT_GET_CLASS (seat);
if (seat_class->handle_device_event)
{
if (!seat_class->handle_device_event (seat, event))
return FALSE;
}
if (seat_class->handle_event_post)
seat_class->handle_event_post (seat, event);
device = clutter_event_get_source_device (event);
g_assert_true (CLUTTER_IS_INPUT_DEVICE (device));

View File

@ -88,8 +88,8 @@ struct _ClutterSeatClass
ClutterEvent *event,
const ClutterEvent *to_discard);
gboolean (* handle_device_event) (ClutterSeat *seat,
ClutterEvent *event);
gboolean (* handle_event_post) (ClutterSeat *seat,
const ClutterEvent *event);
void (* warp_pointer) (ClutterSeat *seat,
int x,
@ -162,9 +162,6 @@ void clutter_seat_compress_motion (ClutterSeat *seat,
ClutterEvent *event,
const ClutterEvent *to_discard);
gboolean clutter_seat_handle_device_event (ClutterSeat *seat,
ClutterEvent *event);
CLUTTER_EXPORT
void clutter_seat_warp_pointer (ClutterSeat *seat,
int x,

View File

@ -1001,12 +1001,17 @@ clutter_source_dispatch (GSource *source,
gpointer user_data)
{
MetaBackendSource *backend_source = (MetaBackendSource *) source;
MetaBackendPrivate *priv =
meta_backend_get_instance_private (backend_source->backend);
ClutterEvent *event = clutter_event_get ();
ClutterSeat *seat;
if (event)
{
event->any.stage =
CLUTTER_STAGE (meta_backend_get_stage (backend_source->backend));
seat = clutter_backend_get_default_seat (priv->clutter_backend);
clutter_seat_handle_event_post (seat, event);
clutter_do_event (event);
clutter_event_free (event);
}

View File

@ -1474,8 +1474,8 @@ evdev_remove_device (MetaSeatNative *seat,
}
static gboolean
meta_seat_native_handle_device_event (ClutterSeat *seat,
ClutterEvent *event)
meta_seat_native_handle_event_post (ClutterSeat *seat,
const ClutterEvent *event)
{
MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
ClutterInputDevice *device = event->device.device;
@ -2821,7 +2821,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
seat_class->get_supported_virtual_device_types = meta_seat_native_get_supported_virtual_device_types;
seat_class->compress_motion = meta_seat_native_compress_motion;
seat_class->warp_pointer = meta_seat_native_warp_pointer;
seat_class->handle_device_event = meta_seat_native_handle_device_event;
seat_class->handle_event_post = meta_seat_native_handle_event_post;
seat_class->query_state = meta_seat_native_query_state;
props[PROP_SEAT_ID] =

View File

@ -719,8 +719,8 @@ remove_device (MetaSeatX11 *seat_x11,
}
static gboolean
meta_seat_x11_handle_device_event (ClutterSeat *seat,
ClutterEvent *event)
meta_seat_x11_handle_event_post (ClutterSeat *seat,
const ClutterEvent *event)
{
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
ClutterInputDevice *device = event->device.device;
@ -1740,7 +1740,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
seat_class->create_virtual_device = meta_seat_x11_create_virtual_device;
seat_class->get_supported_virtual_device_types = meta_seat_x11_get_supported_virtual_device_types;
seat_class->warp_pointer = meta_seat_x11_warp_pointer;
seat_class->handle_device_event = meta_seat_x11_handle_device_event;
seat_class->handle_event_post = meta_seat_x11_handle_event_post;
seat_class->query_state = meta_seat_x11_query_state;
props[PROP_OPCODE] =