[gnome-settings-daemon] orientation: Add orientation -> rotation function



commit 543c0398e92186dc2cac2ce500bcf410b0a15e7c
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jun 3 01:31:50 2011 +0100

    orientation: Add orientation -> rotation function

 plugins/orientation/Makefile.am               |    2 ++
 plugins/orientation/gsd-orientation-manager.c |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/plugins/orientation/Makefile.am b/plugins/orientation/Makefile.am
index ac4cff8..4d08ae8 100644
--- a/plugins/orientation/Makefile.am
+++ b/plugins/orientation/Makefile.am
@@ -26,6 +26,7 @@ test_orientation_CFLAGS =					\
 	-I$(top_srcdir)/gnome-settings-daemon			\
 	-I$(top_srcdir)/plugins/common				\
 	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"	\
+	$(GNOME_DESKTOP_CFLAGS)					\
 	$(GUDEV_CFLAGS)						\
 	$(XINPUT_CFLAGS)					\
 	$(PLUGIN_CFLAGS)					\
@@ -59,6 +60,7 @@ liborientation_la_CPPFLAGS = \
 liborientation_la_CFLAGS = \
 	$(PLUGIN_CFLAGS)		\
 	$(GUDEV_CFLAGS)			\
+	$(GNOME_DESKTOP_CFLAGS)		\
 	$(SETTINGS_PLUGIN_CFLAGS)	\
 	$(AM_CFLAGS)
 
diff --git a/plugins/orientation/gsd-orientation-manager.c b/plugins/orientation/gsd-orientation-manager.c
index e58e483..88af63b 100644
--- a/plugins/orientation/gsd-orientation-manager.c
+++ b/plugins/orientation/gsd-orientation-manager.c
@@ -30,6 +30,9 @@
 #include <gudev/gudev.h>
 #include <X11/extensions/XInput2.h>
 
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-rr.h>
+
 #include "gsd-input-helper.h"
 #include "gnome-settings-profile.h"
 #include "gsd-orientation-manager.h"
@@ -101,6 +104,23 @@ gsd_orientation_manager_init (GsdOrientationManager *manager)
         manager->priv->device_id = -1;
 }
 
+static GnomeRRRotation
+orientation_to_rotation (OrientationUp    orientation)
+{
+        switch (orientation) {
+        case ORIENTATION_NORMAL:
+                return GNOME_RR_ROTATION_0;
+        case ORIENTATION_BOTTOM_UP:
+                return GNOME_RR_ROTATION_180;
+        case ORIENTATION_LEFT_UP:
+                return GNOME_RR_ROTATION_90;
+        case ORIENTATION_RIGHT_UP:
+                return GNOME_RR_ROTATION_270;
+        default:
+                g_assert_not_reached ();
+        }
+}
+
 static gboolean
 get_current_values (GsdOrientationManager *manager,
                     int                   *x,
@@ -180,6 +200,9 @@ check_value_change_cb (GsdOrientationManager *manager)
 
                 /* We have updated values */
                 if (update_current_orientation (manager, x, y, z)) {
+                        GnomeRRRotation rotation;
+
+                        rotation = orientation_to_rotation (manager->priv->prev_orientation);
                         /* FIXME: call into XRandR plugin */
                 }
 



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