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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho 2020-08-11 11:27:18 +02:00 committed by Marge Bot
parent c3acaeb251
commit 2ceac4a296
7 changed files with 28 additions and 29 deletions

View File

@ -1938,13 +1938,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

@ -994,12 +994,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

@ -1488,8 +1488,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;
@ -2872,7 +2872,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

@ -720,13 +720,18 @@ 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;
ClutterInputDevice *device;
gboolean is_touch;
if (event->type != CLUTTER_DEVICE_ADDED &&
event->type != CLUTTER_DEVICE_REMOVED)
return TRUE;
device = clutter_event_get_device (event);
is_touch =
clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE;
@ -1760,7 +1765,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] =