[gnome-control-center] wacom: Only write a generic pen to the keyfile when it's previously unseen



commit a82b975367e3733612062bd8a8075640ab5837f7
Author: Peter Hutterer <peter hutterer who-t net>
Date:   Thu Dec 13 16:36:14 2018 +1000

    wacom: Only write a generic pen to the keyfile when it's previously unseen
    
    When we bring a generic pen (serial 0) into proximity, the tool is initialized
    as "generic" and mapped to the current tablet. This is then written out into
    the keyfile, so we end up with something like:
    
    [056a:00d1]
    Styli=generic;
    
    On the next g-c-c start the generic pen is pre-loaded from the keyfile but not
    yet associated with the tablet. When the pen gets into proximity the
    association was handled like a completely new pen, thus triggering a key file
    entry again. Eventually, our styli list looked like this:
    
    [056a:00d1]
    Styli=generic;generic;generic;generic;generic;generic;
    
    Fix this by remembering whether we freshly initialized the tool or whether it
    was already known. Since we can only have one generic tool per tablet (because
    we wouldn't notice the difference between two physical tools) we just skip the
    write of the keyfile.
    
    Fixes #313

 panels/wacom/cc-tablet-tool-map.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/panels/wacom/cc-tablet-tool-map.c b/panels/wacom/cc-tablet-tool-map.c
index eea54c282..8b681e3f4 100644
--- a/panels/wacom/cc-tablet-tool-map.c
+++ b/panels/wacom/cc-tablet-tool-map.c
@@ -347,6 +347,7 @@ cc_tablet_tool_map_add_relation (CcTabletToolMap *map,
                                 CcWacomTool     *tool)
 {
        gboolean tablets_changed = FALSE, tools_changed = FALSE;
+       gboolean new_tool_without_serial = FALSE;
        gchar *tool_key, *device_key;
        GError *error = NULL;
        guint64 serial, id;
@@ -367,6 +368,7 @@ cc_tablet_tool_map_add_relation (CcTabletToolMap *map,
                        g_hash_table_insert (map->no_serial_tool_map,
                                             g_strdup (device_key),
                                             g_object_ref (tool));
+                       new_tool_without_serial = TRUE;
                }
        } else {
                tool_key = get_tool_key (serial);
@@ -383,12 +385,15 @@ cc_tablet_tool_map_add_relation (CcTabletToolMap *map,
        styli = g_hash_table_lookup (map->tablet_map, device_key);
 
        if (!g_list_find (styli, tool)) {
-               tablets_changed = TRUE;
-               keyfile_add_device_stylus (map, device_key, tool_key);
                styli = g_list_prepend (styli, tool);
                g_hash_table_replace (map->tablet_map,
                                      g_strdup (device_key),
                                      g_list_copy (styli));
+
+               if (serial || new_tool_without_serial) {
+                       tablets_changed = TRUE;
+                       keyfile_add_device_stylus (map, device_key, tool_key);
+               }
        }
 
        g_free (device_key);


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