[gnome-settings-daemon/wip/carlosg/remove-device-mapper: 84/84] wacom: Migrate 'display' setting to 'output' for opaque tablets



commit bbeb97900cbac8438341a92f11c6cc8340c014f2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Aug 1 17:26:57 2018 +0200

    wacom: Migrate 'display' setting to 'output' for opaque tablets
    
    Display mapping is user-settable on opaque tablets, thus it makes sense to
    migrate this setting to the new one. For other tablets, heuristics should
    apply, which is the behavior expected from the unset key.

 ...ettings-daemon.peripherals.wacom.gschema.xml.in |  5 ++
 plugins/common/meson.build                         |  4 --
 plugins/wacom/gsd-wacom-manager.c                  | 58 ++++++++++++++++++++++
 plugins/wacom/meson.build                          |  4 ++
 4 files changed, 67 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.settings-daemon.peripherals.wacom.gschema.xml.in 
b/data/org.gnome.settings-daemon.peripherals.wacom.gschema.xml.in
index 52d8c727..f6874962 100644
--- a/data/org.gnome.settings-daemon.peripherals.wacom.gschema.xml.in
+++ b/data/org.gnome.settings-daemon.peripherals.wacom.gschema.xml.in
@@ -89,4 +89,9 @@
       <description>Label will be rendered to OLED display belonging to the button</description>
     </key>
   </schema>
+  <schema id="org.gnome.desktop.peripherals.tablet.deprecated">
+    <key name="display" type="as">
+      <default>["", "", ""]</default>
+    </key>
+  </schema>
 </schemalist>
diff --git a/plugins/common/meson.build b/plugins/common/meson.build
index d51e3d67..2f18c2c6 100644
--- a/plugins/common/meson.build
+++ b/plugins/common/meson.build
@@ -28,10 +28,6 @@ if host_is_darwin
   ldflags += ['-Wl,-bundle_loader,@0@'.format(join_paths(), meson.build_root(), meson.project_name(), 
meson.project_name())]
 endif
 
-if enable_wacom
-  deps += libwacom_dep
-endif
-
 libcommon = static_library(
   plugin_name,
   sources: sources,
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index e0524613..7ce04522 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -39,6 +39,10 @@
 #include <gdk/gdkx.h>
 #endif
 
+#if HAVE_WACOM
+#include <libwacom/libwacom.h>
+#endif
+
 #include "gsd-enums.h"
 #include "gnome-settings-profile.h"
 #include "gnome-settings-bus.h"
@@ -86,6 +90,10 @@ struct GsdWacomManagerPrivate
 
         gchar *machine_id;
 
+#if HAVE_WACOM
+        WacomDeviceDatabase *wacom_db;
+#endif
+
         /* DBus */
         GDBusNodeInfo   *introspection_data;
         GDBusConnection *dbus_connection;
@@ -102,6 +110,8 @@ static gboolean set_led (const gchar  *device_path,
                          guint         group,
                          guint         index,
                          GError      **error);
+static gboolean is_opaque_tablet (GsdWacomManager *manager,
+                                  GdkDevice       *device);
 
 G_DEFINE_TYPE (GsdWacomManager, gsd_wacom_manager, G_TYPE_OBJECT)
 
@@ -149,6 +159,22 @@ migrate_tablet_settings (GsdWacomManager *manager,
                                     "org.gnome.desktop.peripherals.tablet",
                                     new_path,
                                     tablet_settings, G_N_ELEMENTS (tablet_settings));
+
+        /* Opaque tablets' mapping may be modified by users, so only these
+         * need migration of settings.
+         */
+        if (is_opaque_tablet (manager, device)) {
+                GsdSettingsMigrateEntry display_setting[] = {
+                        { "display", "output", NULL },
+                };
+
+                gsd_settings_migrate_check ("org.gnome.desktop.peripherals.tablet.deprecated",
+                                            new_path,
+                                            "org.gnome.desktop.peripherals.tablet",
+                                            new_path,
+                                            display_setting, G_N_ELEMENTS (display_setting));
+        }
+
         g_free (old_path);
         g_free (new_path);
 }
@@ -174,6 +200,31 @@ get_device_path (GdkDevice *device)
                 return xdevice_get_device_node (gdk_x11_device_get_id (device));
 }
 
+static gboolean
+is_opaque_tablet (GsdWacomManager *manager,
+                  GdkDevice       *device)
+{
+        gboolean is_opaque = FALSE;
+#if HAVE_WACOM
+        WacomDevice *wacom_device;
+        gchar *devpath;
+
+        devpath = get_device_path (device);
+        wacom_device = libwacom_new_from_path (manager->priv->wacom_db, devpath,
+                                               WFALLBACK_GENERIC, NULL);
+        if (wacom_device) {
+                WacomIntegrationFlags integration_flags;
+
+                integration_flags = libwacom_get_integration_flags (wacom_device);
+                is_opaque = (integration_flags &
+                             (WACOM_DEVICE_INTEGRATED_DISPLAY | WACOM_DEVICE_INTEGRATED_SYSTEM)) == 0;
+                libwacom_destroy (wacom_device);
+        }
+
+#endif
+        return is_opaque;
+}
+
 static GdkDevice *
 lookup_device_by_path (GsdWacomManager *manager,
                        const gchar     *path)
@@ -353,6 +404,9 @@ static void
 gsd_wacom_manager_init (GsdWacomManager *manager)
 {
         manager->priv = GSD_WACOM_MANAGER_GET_PRIVATE (manager);
+#if HAVE_WACOM
+        manager->priv->wacom_db = libwacom_database_new ();
+#endif
 }
 
 static gboolean
@@ -512,6 +566,10 @@ gsd_wacom_manager_finalize (GObject *object)
 
         g_clear_object (&wacom_manager->priv->shell_proxy);
 
+#if HAVE_WACOM
+        libwacom_database_destroy (wacom_manager->priv->wacom_db);
+#endif
+
         G_OBJECT_CLASS (gsd_wacom_manager_parent_class)->finalize (object);
 }
 
diff --git a/plugins/wacom/meson.build b/plugins/wacom/meson.build
index e5300cdb..3b1994c5 100644
--- a/plugins/wacom/meson.build
+++ b/plugins/wacom/meson.build
@@ -28,6 +28,10 @@ deps = plugins_deps + [
   pango_dep
 ]
 
+if enable_wacom
+  deps += libwacom_dep
+endif
+
 cflags += ['-DLIBEXECDIR="@0@"'.format(gsd_libexecdir)]
 
 executable(


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]