diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2020-12-15 23:57:59 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2020-12-16 01:13:01 +0100 |
commit | fff9540bfbc255fb1fea390d3525dabb05605512 (patch) | |
tree | 5d9921c0010b1fe4fe711b38928273c157061429 | |
parent | 68437fa88666fe5faab99824a933ca9a488178dd (diff) | |
download | mutter-fff9540bfbc255fb1fea390d3525dabb05605512.tar.gz |
backends/native: Make group modes checks libinput device independent
Remove the dependence on the underlying libinput device here.
-rw-r--r-- | src/backends/native/meta-input-device-native.c | 16 | ||||
-rw-r--r-- | src/backends/native/meta-input-device-native.h | 1 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c index 808135a8d..e1e0911f4 100644 --- a/src/backends/native/meta-input-device-native.c +++ b/src/backends/native/meta-input-device-native.c @@ -78,6 +78,7 @@ meta_input_device_native_finalize (GObject *object) stop_mousekeys_move (device_evdev); g_clear_pointer (&device_evdev->pad_features, g_array_unref); + g_clear_pointer (&device_evdev->modes, g_array_unref); G_OBJECT_CLASS (meta_input_device_native_parent_class)->finalize (object); } @@ -159,13 +160,12 @@ static int meta_input_device_native_get_group_n_modes (ClutterInputDevice *device, int group) { - struct libinput_device *libinput_device; - struct libinput_tablet_pad_mode_group *mode_group; + MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device); - libinput_device = meta_input_device_native_get_libinput_device (device); - mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, group); + if (!device_native->modes || group < device_native->modes->len) + return -1; - return libinput_tablet_pad_mode_group_get_num_modes (mode_group); + return g_array_index (device_native->modes, int, group); } static gboolean @@ -1284,7 +1284,7 @@ update_pad_features (MetaInputDeviceNative *device_native) ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_native); struct libinput_device *libinput_device; struct libinput_tablet_pad_mode_group *mode_group; - int n_groups, n_buttons, n_rings, n_strips, i, j; + int n_groups, n_buttons, n_rings, n_strips, n_modes, i, j; libinput_device = meta_input_device_native_get_libinput_device (device); n_rings = libinput_device_tablet_pad_get_num_rings (libinput_device); @@ -1293,12 +1293,16 @@ update_pad_features (MetaInputDeviceNative *device_native) n_buttons = libinput_device_tablet_pad_get_num_buttons (libinput_device); device_native->pad_features = g_array_new (FALSE, FALSE, sizeof (PadFeature)); + device_native->modes = g_array_new (FALSE, FALSE, sizeof (int)); for (i = 0; i < n_groups; i++) { mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, i); + n_modes = libinput_tablet_pad_mode_group_get_num_modes (mode_group); + g_array_append_val (device_native->modes, n_modes); + for (j = 0; j < n_buttons; j++) { gboolean is_mode_switch = diff --git a/src/backends/native/meta-input-device-native.h b/src/backends/native/meta-input-device-native.h index 2000888dc..44c31f6ad 100644 --- a/src/backends/native/meta-input-device-native.h +++ b/src/backends/native/meta-input-device-native.h @@ -76,6 +76,7 @@ struct _MetaInputDeviceNative MetaSeatImpl *seat_impl; ClutterInputDeviceTool *last_tool; GArray *pad_features; + GArray *modes; cairo_matrix_t device_matrix; double device_aspect_ratio; /* w:h */ |