[mutter/wip/tablet-protocol-v2: 49/70] backends: Fetch libwacom information for tablets in MetaInputSettings
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/tablet-protocol-v2: 49/70] backends: Fetch libwacom information for tablets in MetaInputSettings
- Date: Wed, 22 Jun 2016 17:37:28 +0000 (UTC)
commit dfa54e00f93e64041bc6163619106808d00bffb3
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 13 13:20:07 2016 +0200
backends: Fetch libwacom information for tablets in MetaInputSettings
Given that information defines largely how such devices are to be
configured, it makes sense to have that information at hand. A getter
has been also added for the places where it could be useful, although
it will require HAVE_LIBWACOM checks in callers too.
src/backends/meta-input-settings-private.h | 9 ++++
src/backends/meta-input-settings.c | 60 ++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h
index a7e6ea0..1b3e13f 100644
--- a/src/backends/meta-input-settings-private.h
+++ b/src/backends/meta-input-settings-private.h
@@ -27,6 +27,10 @@
#include <clutter/clutter.h>
+#ifdef HAVE_LIBWACOM
+#include <libwacom/libwacom.h>
+#endif
+
#define META_TYPE_INPUT_SETTINGS (meta_input_settings_get_type ())
#define META_INPUT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_INPUT_SETTINGS,
MetaInputSettings))
#define META_INPUT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_INPUT_SETTINGS,
MetaInputSettingsClass))
@@ -102,4 +106,9 @@ MetaInputSettings * meta_input_settings_create (void);
GDesktopTabletMapping meta_input_settings_get_tablet_mapping (MetaInputSettings *settings,
ClutterInputDevice *device);
+#ifdef HAVE_LIBWACOM
+WacomDevice * meta_input_settings_get_tablet_wacom_device (MetaInputSettings *settings,
+ ClutterInputDevice *device);
+#endif
+
#endif /* META_INPUT_SETTINGS_PRIVATE_H */
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 51f45d5..4506782 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -48,6 +48,9 @@ struct _DeviceMappingInfo
MetaInputSettings *input_settings;
ClutterInputDevice *device;
GSettings *settings;
+#ifdef HAVE_LIBWACOM
+ WacomDevice *wacom_device;
+#endif
};
struct _MetaInputSettingsPrivate
@@ -62,6 +65,10 @@ struct _MetaInputSettingsPrivate
GSettings *keyboard_settings;
GHashTable *mappable_devices;
+
+#ifdef HAVE_LIBWACOM
+ WacomDeviceDatabase *wacom_db;
+#endif
};
typedef void (*ConfigBoolFunc) (MetaInputSettings *input_settings,
@@ -122,6 +129,9 @@ meta_input_settings_dispose (GObject *object)
g_clear_object (&priv->monitor_manager);
+ if (priv->wacom_db)
+ libwacom_database_destroy (priv->wacom_db);
+
G_OBJECT_CLASS (meta_input_settings_parent_class)->dispose (object);
}
@@ -851,6 +861,10 @@ monitors_changed_cb (MetaMonitorManager *monitor_manager,
static void
device_mapping_info_free (DeviceMappingInfo *info)
{
+#ifdef HAVE_LIBWACOM
+ if (info->wacom_device)
+ libwacom_destroy (info->wacom_device);
+#endif
g_object_unref (info->settings);
g_slice_free (DeviceMappingInfo, info);
}
@@ -875,6 +889,26 @@ check_add_mappable_device (MetaInputSettings *input_settings,
info->device = device;
info->settings = settings;
+#ifdef HAVE_LIBWACOM
+ if (clutter_input_device_get_device_type (device) == CLUTTER_TABLET_DEVICE ||
+ clutter_input_device_get_device_type (device) == CLUTTER_PAD_DEVICE)
+ {
+ WacomError *error = libwacom_error_new ();
+
+ info->wacom_device = libwacom_new_from_path (priv->wacom_db,
+ clutter_input_device_get_device_node (device),
+ WFALLBACK_NONE, error);
+ if (!info->wacom_device)
+ {
+ g_warning ("Could not get tablet information for '%s': %s",
+ clutter_input_device_get_device_name (device),
+ libwacom_error_get_message (error));
+ }
+
+ libwacom_error_free (&error);
+ }
+#endif
+
g_signal_connect (settings, "changed",
G_CALLBACK (mapped_device_changed_cb), info);
@@ -1000,6 +1034,13 @@ meta_input_settings_init (MetaInputSettings *settings)
priv->monitor_manager = g_object_ref (meta_monitor_manager_get ());
g_signal_connect (priv->monitor_manager, "monitors-changed",
G_CALLBACK (monitors_changed_cb), settings);
+
+ priv->wacom_db = libwacom_database_new ();
+ if (!priv->wacom_db)
+ {
+ g_warning ("Could not create database of Wacom devices, "
+ "expect tablets to misbehave");
+ }
}
MetaInputSettings *
@@ -1037,3 +1078,22 @@ meta_input_settings_get_tablet_mapping (MetaInputSettings *settings,
return g_settings_get_enum (info->settings, "mapping");
}
+
+#ifdef HAVE_LIBWACOM
+WacomDevice *
+meta_input_settings_get_tablet_wacom_device (MetaInputSettings *settings,
+ ClutterInputDevice *device)
+{
+ MetaInputSettingsPrivate *priv;
+ DeviceMappingInfo *info;
+
+ g_return_val_if_fail (META_IS_INPUT_SETTINGS (settings), NULL);
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
+
+ priv = meta_input_settings_get_instance_private (settings);
+ info = g_hash_table_lookup (priv->mappable_devices, device);
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->wacom_device;
+}
+#endif /* HAVE_LIBWACOM */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]