backend/native: Move barrier manager to MetaSeatNative

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1486
This commit is contained in:
Carlos Garnacho 2020-06-05 12:21:58 +02:00 committed by Jonas Ådahl
parent 6cb1557d99
commit 27ef073432
4 changed files with 37 additions and 32 deletions

View File

@ -48,7 +48,6 @@
#include "backends/meta-pointer-constraint.h" #include "backends/meta-pointer-constraint.h"
#include "backends/meta-settings-private.h" #include "backends/meta-settings-private.h"
#include "backends/meta-stage-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-clutter-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h" #include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-event-native.h" #include "backends/native/meta-event-native.h"
@ -75,7 +74,6 @@ struct _MetaBackendNative
MetaLauncher *launcher; MetaLauncher *launcher;
MetaUdev *udev; MetaUdev *udev;
MetaKms *kms; MetaKms *kms;
MetaBarrierManagerNative *barrier_manager;
gulong udev_device_added_handler_id; 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); 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 static void
constrain_to_client_constraint (ClutterInputDevice *device, constrain_to_client_constraint (ClutterInputDevice *device,
guint32 time, guint32 time,
@ -207,9 +191,6 @@ pointer_constrain_callback (ClutterInputDevice *device,
MetaMonitorManager *monitor_manager = MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend); meta_backend_get_monitor_manager (backend);
/* Constrain to barriers */
constrain_to_barriers (device, time, new_x, new_y);
/* Constrain to pointer lock */ /* Constrain to pointer lock */
constrain_to_client_constraint (device, time, prev_x, prev_y, new_x, new_y); 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 #endif
native->udev = meta_udev_new (native); native->udev = meta_udev_new (native);
native->barrier_manager = meta_barrier_manager_native_new ();
native->kms = meta_kms_new (META_BACKEND (native), error); native->kms = meta_kms_new (META_BACKEND (native), error);
if (!native->kms) if (!native->kms)
@ -789,12 +769,6 @@ meta_activate_vt (int vt, GError **error)
return meta_launcher_activate_vt (launcher, vt, 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: * meta_activate_session:
* *

View File

@ -36,8 +36,7 @@
#include "backends/meta-backend-private.h" #include "backends/meta-backend-private.h"
#include "backends/meta-barrier-private.h" #include "backends/meta-barrier-private.h"
#include "backends/native/meta-backend-native.h" #include "backends/native/meta-seat-native.h"
#include "backends/native/meta-backend-native-private.h"
#include "meta/barrier.h" #include "meta/barrier.h"
#include "meta/util.h" #include "meta/util.h"
@ -558,16 +557,16 @@ MetaBarrierImpl *
meta_barrier_impl_native_new (MetaBarrier *barrier) meta_barrier_impl_native_new (MetaBarrier *barrier)
{ {
MetaBarrierImplNative *self; MetaBarrierImplNative *self;
MetaBackendNative *native;
MetaBarrierManagerNative *manager; 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 = g_object_new (META_TYPE_BARRIER_IMPL_NATIVE, NULL);
self->barrier = barrier; self->barrier = barrier;
self->is_active = TRUE; self->is_active = TRUE;
native = META_BACKEND_NATIVE (meta_get_backend ()); manager = meta_seat_native_get_barrier_manager (META_SEAT_NATIVE (seat));
manager = meta_backend_native_get_barrier_manager (native);
self->manager = manager; self->manager = manager;
g_hash_table_add (manager->barriers, self); g_hash_table_add (manager->barriers, self);

View File

@ -26,6 +26,8 @@
#include "config.h" #include "config.h"
#include "backends/native/meta-seat-native.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <libinput.h> #include <libinput.h>
@ -33,7 +35,7 @@
#include <math.h> #include <math.h>
#include "backends/meta-cursor-tracker-private.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-event-native.h"
#include "backends/native/meta-input-device-native.h" #include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h" #include "backends/native/meta-input-device-tool-native.h"
@ -889,6 +891,19 @@ meta_event_check (GSource *source)
return retval; 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 void
meta_seat_native_constrain_pointer (MetaSeatNative *seat, meta_seat_native_constrain_pointer (MetaSeatNative *seat,
ClutterInputDevice *core_pointer, ClutterInputDevice *core_pointer,
@ -898,6 +913,10 @@ meta_seat_native_constrain_pointer (MetaSeatNative *seat,
float *new_x, float *new_x,
float *new_y) float *new_y)
{ {
constrain_to_barriers (seat, core_pointer,
us2ms (time_us),
new_x, new_y);
if (seat->constrain_callback) if (seat->constrain_callback)
{ {
seat->constrain_callback (core_pointer, seat->constrain_callback (core_pointer,
@ -2880,6 +2899,8 @@ meta_seat_native_init (MetaSeatNative *seat)
seat->repeat_delay = 250; /* ms */ seat->repeat_delay = 250; /* ms */
seat->repeat_interval = 33; /* ms */ seat->repeat_interval = 33; /* ms */
seat->barrier_manager = meta_barrier_manager_native_new ();
seat->reserved_virtual_slots = g_hash_table_new (NULL, NULL); seat->reserved_virtual_slots = g_hash_table_new (NULL, NULL);
} }
@ -3267,3 +3288,9 @@ meta_seat_native_get_xkb_state (MetaSeatNative *seat)
{ {
return seat->xkb; return seat->xkb;
} }
MetaBarrierManagerNative *
meta_seat_native_get_barrier_manager (MetaSeatNative *seat)
{
return seat->barrier_manager;
}

View File

@ -27,6 +27,7 @@
#include <libinput.h> #include <libinput.h>
#include <linux/input-event-codes.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-keymap-native.h"
#include "backends/native/meta-xkb-utils.h" #include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h" #include "clutter/clutter.h"
@ -108,6 +109,8 @@ struct _MetaSeatNative
int device_id_next; int device_id_next;
GList *free_device_ids; GList *free_device_ids;
MetaBarrierManagerNative *barrier_manager;
MetaPointerConstrainCallback constrain_callback; MetaPointerConstrainCallback constrain_callback;
gpointer constrain_data; gpointer constrain_data;
GDestroyNotify constrain_data_notify; GDestroyNotify constrain_data_notify;
@ -294,4 +297,6 @@ void meta_seat_native_set_keyboard_repeat (MetaSeatNative *seat,
void meta_seat_native_release_touch_slots (MetaSeatNative *seat, void meta_seat_native_release_touch_slots (MetaSeatNative *seat,
guint base_slot); guint base_slot);
MetaBarrierManagerNative * meta_seat_native_get_barrier_manager (MetaSeatNative *seat);
#endif /* META_SEAT_NATIVE_H */ #endif /* META_SEAT_NATIVE_H */