backend/native: Move barrier manager to MetaSeatNative

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
Carlos Garnacho 2020-06-05 12:21:58 +02:00
parent 2316dfe394
commit 73e705a49b
4 changed files with 38 additions and 32 deletions

View File

@ -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"
@ -71,7 +70,6 @@ struct _MetaBackendNative
MetaLauncher *launcher;
MetaUdev *udev;
MetaKms *kms;
MetaBarrierManagerNative *barrier_manager;
gulong udev_device_added_handler_id;
};
@ -103,20 +101,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,
@ -203,9 +187,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);
@ -662,7 +643,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)
@ -742,12 +722,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:
*

View File

@ -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);

View File

@ -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"
@ -887,6 +889,19 @@ meta_event_check (GSource *source)
return retval;
}
static void
constrain_to_barriers (MetaSeatNative *seat,
ClutterInputDevice *device,
guint32 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,
@ -896,6 +911,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,
@ -2805,6 +2825,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 ();
}
ClutterInputDevice *
@ -3199,3 +3221,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;
}

View File

@ -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;
@ -292,4 +295,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 */