[gnome-settings-daemon/opensuse-moblin: 11/24] Call xsetwacom(1) to rotate the stylus
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/opensuse-moblin: 11/24] Call xsetwacom(1) to rotate the stylus
- Date: Thu, 28 Jan 2010 01:47:37 +0000 (UTC)
commit 4049b530416b99407eaf210fded7aa2550f60ea7
Author: Federico Mena Quintero <federico novell com>
Date: Fri Jan 30 13:46:57 2009 -0600
Call xsetwacom(1) to rotate the stylus
Signed-off-by: Federico Mena Quintero <federico novell com>
plugins/xrandr/gsd-xrandr-manager.c | 74 +++++++++++++++++++++++++++++++++++
1 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 91e269d..5bc3d88 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -197,6 +197,80 @@ find_rotation_for_tablet (GnomeRRConfig *configuration)
}
static void
+rotate_tablet (GsdXrandrManager *manager, GnomeRRRotation rotation)
+{
+ char *stdout_str;
+ int status;
+ char *p;
+ char *newline;
+ const char *arg;
+
+ /* We really don't do error checking. If xsetwacom(1) doesn't exist,
+ * well, too bad. Maybe that means that the user doesn't have a tablet.
+ */
+
+ stdout_str = NULL;
+ if (!g_spawn_command_line_sync ("xsetwacom list",
+ &stdout_str,
+ NULL,
+ &status,
+ NULL))
+ goto out;
+
+ if (!(WIFEXITED (status) && WEXITSTATUS (status) == 0 && stdout_str != NULL))
+ goto out;
+
+ switch (rotation) {
+ case GNOME_RR_ROTATION_90:
+ arg = "CW";
+ break;
+
+ case GNOME_RR_ROTATION_180:
+ arg = "HALF";
+ break;
+
+ case GNOME_RR_ROTATION_270:
+ arg = "CCW";
+ break;
+
+ default: /* this also catches GNOME_RR_ROTATION_0 */
+ arg = "NONE";
+ break;
+ }
+
+ for (p = stdout_str; *p != '\0'; p = newline + 1) {
+ char *end;
+ char *device_name;
+ char *command;
+
+ newline = strchr (p, '\n');
+ if (!newline)
+ break;
+
+ *newline = '\0';
+
+ if (!strstr (p, "stylus"))
+ continue;
+
+ device_name = p;
+ for (end = device_name; *end != '\0' && !g_ascii_isspace (*end); end++);
+
+ *end = '\0';
+
+ if (strlen (device_name) == 0)
+ continue;
+
+ command = g_strconcat ("xsetwacom set ", device_name, " Rotate ", arg, NULL);
+ g_spawn_command_line_sync (command, NULL, NULL, NULL, NULL);
+ g_free (command);
+ }
+
+out:
+
+ g_free (stdout_str);
+}
+
+static void
handle_tablet_rotation (GsdXrandrManager *manager)
{
struct GsdXrandrManagerPrivate *priv = manager->priv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]