Little effect for most users of the database, but the generated udev rules
become more predictable and a lot easier to patch this way.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
I admit, it's a bit heavy-handed to sort the database even though we need it
mainly for the rules file. But it's less lines of code doing it this way :)

 libwacom/libwacom-database.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c
index 997b53f..ccdf5a5 100644
--- a/libwacom/libwacom-database.c
+++ b/libwacom/libwacom-database.c
@@ -696,6 +696,19 @@ libwacom_database_destroy(WacomDeviceDatabase *db)
        g_free (db);
 }
 
+static gint
+device_compare(gconstpointer pa, gconstpointer pb)
+{
+       const WacomDevice *a = pa,
+                         *b = pb;
+       int cmp;
+
+       cmp = libwacom_get_vendor_id(a) - libwacom_get_vendor_id(b);
+       if (cmp == 0)
+               cmp = libwacom_get_product_id(a) - libwacom_get_product_id(b);
+       return cmp;
+}
+
 WacomDevice**
 libwacom_list_devices_from_database(const WacomDeviceDatabase *db, WacomError 
*error)
 {
@@ -714,6 +727,8 @@ libwacom_list_devices_from_database(const 
WacomDeviceDatabase *db, WacomError *e
                return NULL;
        }
 
+       devices = g_list_sort (devices, device_compare);
+
        for (p = list, cur = devices; cur; cur = g_list_next (cur))
                *p++ = (WacomDevice *) cur->data;
        g_list_free (devices);
-- 
2.7.3


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to