[gnome-settings-daemon] wacom: move out get_oled_sys_path () from main
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] wacom: move out get_oled_sys_path () from main
- Date: Tue, 12 Aug 2014 21:58:03 +0000 (UTC)
commit cf41b6e03463687339be5212745949e775720228
Author: Benjamin Tissoires <benjamin tissoires redhat com>
Date: Tue Aug 12 10:51:43 2014 -0400
wacom: move out get_oled_sys_path () from main
Kernel 3.17 introduce a new ABI for Wacom devices (the path changed).
In order to properly detect this and be able to differentiate both ABI,
split out the retrieval of the OLED sysfs node first.
https://bugzilla.gnome.org/show_bug.cgi?id=734458
plugins/wacom/gsd-wacom-oled-helper.c | 75 ++++++++++++++++++++++-----------
1 files changed, 50 insertions(+), 25 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-oled-helper.c b/plugins/wacom/gsd-wacom-oled-helper.c
index 945286d..0c1ad15 100644
--- a/plugins/wacom/gsd-wacom-oled-helper.c
+++ b/plugins/wacom/gsd-wacom-oled-helper.c
@@ -202,17 +202,60 @@ get_bt_oled_filename (GUdevClient *client, GUdevDevice *device, int button_num)
return filename;
}
+static char *
+get_oled_sys_path (GUdevClient *client,
+ GUdevDevice *device,
+ int button_num,
+ gboolean usb,
+ GsdWacomOledType *type)
+{
+ GUdevDevice *parent;
+ char *filename = NULL;
+
+ if (usb) {
+ parent = g_udev_device_get_parent_with_subsystem (device, "usb", "usb_interface");
+ if (!parent)
+ goto no_parent;
+
+ filename = get_oled_sysfs_path (parent, button_num);
+ *type = GSD_WACOM_OLED_TYPE_USB;
+ } else if (g_strrstr (g_udev_device_get_property (device, "DEVPATH"), "bluetooth")) {
+ parent = g_udev_device_get_parent_with_subsystem (device, "input", NULL);
+ if (!parent)
+ goto no_parent;
+
+ filename = get_bt_oled_filename (client, parent, button_num);
+ *type = GSD_WACOM_OLED_TYPE_BLUETOOTH;
+ } else {
+ g_critical ("Not an expected device: '%s'",
+ g_udev_device_get_device_file (device));
+ goto out_err;
+ }
+
+ g_object_unref (parent);
+
+ return filename;
+
+no_parent:
+ g_debug ("Could not find proper parent device for '%s'",
+ g_udev_device_get_device_file (device));
+
+out_err:
+ return NULL;
+}
+
int main (int argc, char **argv)
{
GOptionContext *context;
GUdevClient *client;
- GUdevDevice *device, *parent;
+ GUdevDevice *device;
int uid, euid;
char *filename;
GError *error = NULL;
const char * const subsystems[] = { "input", NULL };
int ret = 1;
+ gboolean usb;
GsdWacomOledType type;
char *path = NULL;
@@ -266,32 +309,14 @@ int main (int argc, char **argv)
goto out;
}
- if (g_strcmp0 (g_udev_device_get_property (device, "ID_BUS"), "usb") == 0) {
- parent = g_udev_device_get_parent_with_subsystem (device, "usb", "usb_interface");
- if (parent == NULL) {
- g_critical ("Could not find parent USB device for '%s'", path);
- goto out;
- }
- g_object_unref (device);
- device = parent;
-
- filename = get_oled_sysfs_path (device, button_num);
- type = GSD_WACOM_OLED_TYPE_USB;
- } else if (g_strrstr( g_udev_device_get_property (device, "DEVPATH"), "bluetooth")) {
- parent = g_udev_device_get_parent (device);
- if (parent == NULL) {
- g_critical ("Could not find parent device for '%s'", path);
- goto out;
- }
- g_object_unref (device);
- device = parent;
+ if (g_strcmp0 (g_udev_device_get_property (device, "ID_BUS"), "usb") != 0)
+ usb = FALSE;
+ else
+ usb = TRUE;
- filename = get_bt_oled_filename (client, device, button_num);
- type = GSD_WACOM_OLED_TYPE_BLUETOOTH;
- } else {
- g_critical ("Not an expected device: %s", path);
+ filename = get_oled_sys_path (client, device, button_num, usb, &type);
+ if (!filename)
goto out;
- }
if (gsd_wacom_oled_helper_write (filename, buffer, type, &error) == FALSE) {
g_critical ("Could not set OLED icon for '%s': %s", path, error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]