---
 plugins/xrandr/gsd-xrandr-manager-glue.h |   58 ++++++++++++++++++++++++++++---
 plugins/xrandr/gsd-xrandr-manager.c      |   39 ++++++++++++++++++--
 plugins/xrandr/gsd-xrandr-manager.xml    |    8 ++++
 3 files changed, 96 insertions(+), 9 deletions(-)

--- a/plugins/xrandr/gsd-xrandr-manager-glue.h
+++ b/plugins/xrandr/gsd-xrandr-manager-glue.h
@@ -27,6 +27,7 @@
 #define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
 #define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
 #define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
 #else /* !G_ENABLE_DEBUG */
 /* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
  *          Do not access GValues directly in your code. Instead, use the
@@ -50,9 +51,57 @@
 #define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
 #define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
 #define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
 #endif /* !G_ENABLE_DEBUG */
 
 
+/* BOOLEAN:INT64,POINTER */
+extern void dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__INT64_POINTER (GClosure     *closure,
+                                                                         GValue       *return_value,
+                                                                         guint         n_param_values,
+                                                                         const GValue *param_values,
+                                                                         gpointer      invocation_hint,
+                                                                         gpointer      marshal_data);
+void
+dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__INT64_POINTER (GClosure     *closure,
+                                                             GValue       *return_value G_GNUC_UNUSED,
+                                                             guint         n_param_values,
+                                                             const GValue *param_values,
+                                                             gpointer      invocation_hint G_GNUC_UNUSED,
+                                                             gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__INT64_POINTER) (gpointer     data1,
+                                                           gint64       arg_1,
+                                                           gpointer     arg_2,
+                                                           gpointer     data2);
+  register GMarshalFunc_BOOLEAN__INT64_POINTER callback;
+  register GCClosure *cc = (GCClosure*) closure;
+  register gpointer data1, data2;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__INT64_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_int64 (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
 /* BOOLEAN:POINTER */
 extern void dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__POINTER (GClosure     *closure,
                                                                    GValue       *return_value,
@@ -155,13 +204,14 @@
 static const DBusGMethodInfo dbus_glib_gsd_xrandr_manager_methods[] = {
   { (GCallback) gsd_xrandr_manager_apply_configuration, dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__POINTER, 0 },
   { (GCallback) gsd_xrandr_manager_2_apply_configuration, dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__INT64_INT64_POINTER, 54 },
+  { (GCallback) gsd_xrandr_manager_2_video_mode_switch, dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__INT64_POINTER, 145 },
+  { (GCallback) gsd_xrandr_manager_2_rotate, dbus_glib_marshal_gsd_xrandr_manager_BOOLEAN__INT64_POINTER, 212 },
 };
 
-const DBusGObjectInfo dbus_glib_gsd_xrandr_manager_object_info = {
-  0,
+const DBusGObjectInfo dbus_glib_gsd_xrandr_manager_object_info = {  1,
   dbus_glib_gsd_xrandr_manager_methods,
-  2,
-"org.gnome.SettingsDaemon.XRANDR\0ApplyConfiguration\0S\0\0org.gnome.SettingsDaemon.XRANDR_2\0ApplyConfiguration\0S\0parent_window_id\0I\0x\0timestamp\0I\0x\0\0\0",
+  4,
+"org.gnome.SettingsDaemon.XRANDR\0ApplyConfiguration\0S\0\0org.gnome.SettingsDaemon.XRANDR_2\0ApplyConfiguration\0S\0parent_window_id\0I\0x\0timestamp\0I\0x\0\0org.gnome.SettingsDaemon.XRANDR_2\0VideoModeSwitch\0S\0timestamp\0I\0x\0\0org.gnome.SettingsDaemon.XRANDR_2\0Rotate\0S\0timestamp\0I\0x\0\0\0",
 "\0",
 "\0"
 };
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -814,6 +814,29 @@
         return result;
 }
 
+static void handle_video_mode_switch (GsdXrandrManager *mgr, guint32 timestamp);
+static void handle_rotate_windows (GsdXrandrManager *mgr, guint32 timestamp);
+
+/* DBus method for org.gnome.SettingsDaemon.XRANDR_2 VideoModeSwitch; see gsd-xrandr-manager.xml for the interface definition */
+static gboolean
+gsd_xrandr_manager_2_video_mode_switch (GsdXrandrManager *manager,
+                                        guint32           timestamp,
+                                        GError          **error)
+{
+        handle_video_mode_switch (manager, timestamp);
+        return TRUE;
+}
+
+/* DBus method for org.gnome.SettingsDaemon.XRANDR_2 Rotate; see gsd-xrandr-manager.xml for the interface definition */
+static gboolean
+gsd_xrandr_manager_2_rotate (GsdXrandrManager *manager,
+                             guint32           timestamp,
+                             GError          **error)
+{
+        handle_rotate_windows (manager, timestamp);
+        return TRUE;
+}
+
 /* We include this after the definition of gsd_xrandr_manager_apply_configuration() so the prototype will already exist */
 #include "gsd-xrandr-manager-glue.h"
 
@@ -1754,6 +1777,16 @@
 	g_debug ("done handling XF86Display");
 }
 
+static void
+handle_video_mode_switch (GsdXrandrManager *manager, guint32 timestamp)
+{
+        manager->priv->xkey_time = timestamp;
+        if (!gconf_client_get_bool (manager->priv->client, CONF_KEY_WHEEL_SELECT_OSD, NULL))
+                handle_stock_config_hotkey (manager, timestamp);	//TODO:
+        else
+                handle_stock_config_hotkey_osd (manager);
+}
+
 static GnomeOutputInfo *
 get_laptop_output_info (GnomeRRConfig *config)
 {
@@ -1901,11 +1934,7 @@
         if (xev->xany.type == KeyPress) {
                 if (xev->xkey.keycode == manager->priv->switch_video_mode_keycode) {
 			manager->priv->current_screen = acme_get_screen_from_event (manager, xany);
-			manager->priv->xkey_time = xev->xkey.time;
-        		if (!gconf_client_get_bool (manager->priv->client, CONF_KEY_WHEEL_SELECT_OSD, NULL))
-                        	handle_stock_config_hotkey (manager, xev->xkey.time);	//TODO:
-			else
-                        	handle_stock_config_hotkey_osd (manager);
+                        handle_video_mode_switch (manager, xev->xkey.time);
 		}
                 else if (xev->xkey.keycode == manager->priv->rotate_windows_keycode)
                         handle_rotate_windows (manager, xev->xkey.time);
--- a/plugins/xrandr/gsd-xrandr-manager.xml
+++ b/plugins/xrandr/gsd-xrandr-manager.xml
@@ -19,5 +19,13 @@
       the future) for the RANDR calls themselves -->
       <arg name="timestamp" type="x" direction="in"/>
     </method>
+    <method name="VideoModeSwitch">
+      <!-- Timestamp for the RANDR call itself -->"
+      <arg name="timestamp" type="x" direction="in"/>"
+    </method>
+    <method name="Rotate">
+      <!-- Timestamp for the RANDR call itself -->"
+      <arg name="timestamp" type="x" direction="in"/>"
+    </method>"
   </interface>
 </node>
