[gtk+] Improve detection of input device source type
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Improve detection of input device source type
- Date: Mon, 28 Sep 2009 14:18:37 +0000 (UTC)
commit 7d196b3939e1bbf5eddc5da0980e30c2f38c9cdd
Author: Thomas Jaeger <ThJaeger gmail com>
Date: Mon Sep 28 01:39:42 2009 -0400
Improve detection of input device source type
This detection code is not 100% reliable, but it should fare much better
than the current code, which just compares the device name to a fixed
set of strings. Many applications depend on erasers being recognized
reliably, so we start by checking for a device name containing the
substring 'eraser'.
Signed-off-by: Thomas Jaeger <ThJaeger gmail com>
gdk/x11/gdkinput-x11.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index c0b71e7..0805107 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -111,17 +111,15 @@ gdk_input_device_new (GdkDisplay *display,
tmp_name = g_ascii_strdown (gdkdev->info.name, -1);
- if (!strcmp (tmp_name, "pointer"))
- gdkdev->info.source = GDK_SOURCE_MOUSE;
- else if (!strcmp (tmp_name, "wacom") ||
- !strcmp (tmp_name, "pen"))
- gdkdev->info.source = GDK_SOURCE_PEN;
- else if (!strcmp (tmp_name, "eraser"))
+ if (g_strrstr (tmp_name, "eraser"))
gdkdev->info.source = GDK_SOURCE_ERASER;
- else if (!strcmp (tmp_name, "cursor"))
+ else if (g_strrstr (tmp_name, "cursor"))
gdkdev->info.source = GDK_SOURCE_CURSOR;
- else
+ else if (g_strrstr (tmp_name, "wacom") ||
+ g_strrstr (tmp_name, "pen"))
gdkdev->info.source = GDK_SOURCE_PEN;
+ else
+ gdkdev->info.source = GDK_SOURCE_MOUSE;
g_free(tmp_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]