[mutter/wip/carlosg/input-thread: 1/23] clutter: Make ClutterSeat::handle_device_event vfunc more generic
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 1/23] clutter: Make ClutterSeat::handle_device_event vfunc more generic
- Date: Thu, 13 Aug 2020 19:40:18 +0000 (UTC)
commit a2616d83e855308b3d778a802668a2080cb00fc6
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Aug 11 11:27:18 2020 +0200
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
clutter/clutter/clutter-main.c | 8 +-------
clutter/clutter/clutter-mutter.h | 3 +++
clutter/clutter/clutter-seat.c | 15 +++++----------
clutter/clutter/clutter-seat.h | 7 ++-----
src/backends/meta-backend.c | 5 +++++
src/backends/native/meta-seat-native.c | 6 +++---
src/backends/x11/meta-seat-x11.c | 6 +++---
7 files changed, 22 insertions(+), 28 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 9f803ed00e..1acc632645 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -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:
diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h
index 654c6dac0e..9c75ad6a25 100644
--- a/clutter/clutter/clutter-mutter.h
+++ b/clutter/clutter/clutter-mutter.h
@@ -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__
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index 7d8b728802..973c6bf853 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -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));
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index 4f8d0f423a..df037ff4c2 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -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,
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index f0cf5b5c01..b38436e727 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -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);
}
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 93fbca33e2..08c26a6777 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -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] =
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 63a2a762dc..7ede6fb92f 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -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] =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]