[mutter/wip/carlosg/input-refactors-pt1: 29/44] backend/native: Move barrier manager to MetaSeatNative
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-refactors-pt1: 29/44] backend/native: Move barrier manager to MetaSeatNative
- Date: Thu, 15 Oct 2020 23:25:53 +0000 (UTC)
commit 8db9a25db4c750bc6589630b96b52662f042f35c
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 5 12:21:58 2020 +0200
backend/native: Move barrier manager to MetaSeatNative
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
src/backends/native/meta-backend-native.c | 26 --------------------------
src/backends/native/meta-barrier-native.c | 9 ++++-----
src/backends/native/meta-seat-native.c | 30 +++++++++++++++++++++++++++++-
src/backends/native/meta-seat-native.h | 5 +++++
4 files changed, 38 insertions(+), 32 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index afd3ff79a4..7873ce9082 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -48,7 +48,6 @@
#include "backends/meta-pointer-constraint.h"
#include "backends/meta-settings-private.h"
#include "backends/meta-stage-private.h"
-#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-event-native.h"
@@ -75,7 +74,6 @@ struct _MetaBackendNative
MetaLauncher *launcher;
MetaUdev *udev;
MetaKms *kms;
- MetaBarrierManagerNative *barrier_manager;
gulong udev_device_added_handler_id;
};
@@ -107,20 +105,6 @@ meta_backend_native_finalize (GObject *object)
G_OBJECT_CLASS (meta_backend_native_parent_class)->finalize (object);
}
-static void
-constrain_to_barriers (ClutterInputDevice *device,
- guint32 time,
- float *new_x,
- float *new_y)
-{
- MetaBackendNative *native = META_BACKEND_NATIVE (meta_get_backend ());
-
- meta_barrier_manager_native_process (native->barrier_manager,
- device,
- time,
- new_x, new_y);
-}
-
static void
constrain_to_client_constraint (ClutterInputDevice *device,
guint32 time,
@@ -207,9 +191,6 @@ pointer_constrain_callback (ClutterInputDevice *device,
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
- /* Constrain to barriers */
- constrain_to_barriers (device, time, new_x, new_y);
-
/* Constrain to pointer lock */
constrain_to_client_constraint (device, time, prev_x, prev_y, new_x, new_y);
@@ -709,7 +690,6 @@ meta_backend_native_initable_init (GInitable *initable,
#endif
native->udev = meta_udev_new (native);
- native->barrier_manager = meta_barrier_manager_native_new ();
native->kms = meta_kms_new (META_BACKEND (native), error);
if (!native->kms)
@@ -789,12 +769,6 @@ meta_activate_vt (int vt, GError **error)
return meta_launcher_activate_vt (launcher, vt, error);
}
-MetaBarrierManagerNative *
-meta_backend_native_get_barrier_manager (MetaBackendNative *native)
-{
- return native->barrier_manager;
-}
-
/**
* meta_activate_session:
*
diff --git a/src/backends/native/meta-barrier-native.c b/src/backends/native/meta-barrier-native.c
index 260febe8d1..bdb006fb13 100644
--- a/src/backends/native/meta-barrier-native.c
+++ b/src/backends/native/meta-barrier-native.c
@@ -36,8 +36,7 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-barrier-private.h"
-#include "backends/native/meta-backend-native.h"
-#include "backends/native/meta-backend-native-private.h"
+#include "backends/native/meta-seat-native.h"
#include "meta/barrier.h"
#include "meta/util.h"
@@ -558,16 +557,16 @@ MetaBarrierImpl *
meta_barrier_impl_native_new (MetaBarrier *barrier)
{
MetaBarrierImplNative *self;
- MetaBackendNative *native;
MetaBarrierManagerNative *manager;
+ ClutterBackend *backend = clutter_get_default_backend ();
+ ClutterSeat *seat = clutter_backend_get_default_seat (backend);
self = g_object_new (META_TYPE_BARRIER_IMPL_NATIVE, NULL);
self->barrier = barrier;
self->is_active = TRUE;
- native = META_BACKEND_NATIVE (meta_get_backend ());
- manager = meta_backend_native_get_barrier_manager (native);
+ manager = meta_seat_native_get_barrier_manager (META_SEAT_NATIVE (seat));
self->manager = manager;
g_hash_table_add (manager->barriers, self);
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 2a0d8cc9b2..c825bbd7d2 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -26,6 +26,8 @@
#include "config.h"
+#include "backends/native/meta-seat-native.h"
+
#include <errno.h>
#include <fcntl.h>
#include <libinput.h>
@@ -33,7 +35,7 @@
#include <math.h>
#include "backends/meta-cursor-tracker-private.h"
-#include "backends/native/meta-seat-native.h"
+#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h"
@@ -889,6 +891,19 @@ meta_event_check (GSource *source)
return retval;
}
+static void
+constrain_to_barriers (MetaSeatNative *seat,
+ ClutterInputDevice *device,
+ uint32_t time,
+ float *new_x,
+ float *new_y)
+{
+ meta_barrier_manager_native_process (seat->barrier_manager,
+ device,
+ time,
+ new_x, new_y);
+}
+
void
meta_seat_native_constrain_pointer (MetaSeatNative *seat,
ClutterInputDevice *core_pointer,
@@ -898,6 +913,11 @@ meta_seat_native_constrain_pointer (MetaSeatNative *seat,
float *new_x,
float *new_y)
{
+ /* Constrain to barriers */
+ constrain_to_barriers (seat, core_pointer,
+ us2ms (time_us),
+ new_x, new_y);
+
if (seat->constrain_callback)
{
seat->constrain_callback (core_pointer,
@@ -2819,6 +2839,8 @@ meta_seat_native_init (MetaSeatNative *seat)
seat->repeat = TRUE;
seat->repeat_delay = 250; /* ms */
seat->repeat_interval = 33; /* ms */
+
+ seat->barrier_manager = meta_barrier_manager_native_new ();
}
void
@@ -3205,3 +3227,9 @@ meta_seat_native_get_xkb_state (MetaSeatNative *seat)
{
return seat->xkb;
}
+
+MetaBarrierManagerNative *
+meta_seat_native_get_barrier_manager (MetaSeatNative *seat)
+{
+ return seat->barrier_manager;
+}
diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h
index 1c4ee182c3..106fb505d1 100644
--- a/src/backends/native/meta-seat-native.h
+++ b/src/backends/native/meta-seat-native.h
@@ -27,6 +27,7 @@
#include <libinput.h>
#include <linux/input-event-codes.h>
+#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
@@ -106,6 +107,8 @@ struct _MetaSeatNative
int device_id_next;
GList *free_device_ids;
+ MetaBarrierManagerNative *barrier_manager;
+
MetaPointerConstrainCallback constrain_callback;
gpointer constrain_data;
GDestroyNotify constrain_data_notify;
@@ -289,4 +292,6 @@ void meta_seat_native_set_keyboard_repeat (MetaSeatNative *seat,
uint32_t delay,
uint32_t interval);
+MetaBarrierManagerNative * meta_seat_native_get_barrier_manager (MetaSeatNative *seat);
+
#endif /* META_SEAT_NATIVE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]