[gnome-settings-daemon/opensuse-moblin: 2/24] Grab the XF86RotateWindows key as well



commit cf5c242651aeabaa322e74d6567e6f90c25b226d
Author: Federico Mena Quintero <federico novell com>
Date:   Wed Nov 25 13:00:39 2009 -0600

    Grab the XF86RotateWindows key as well
    
    We will use this to rotate the tablet's main output when that key is pressed.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>

 plugins/xrandr/gsd-xrandr-manager.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index 672cf99..82856f0 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -66,6 +66,7 @@
 #define CONF_KEY "show_notification_icon"
 
 #define VIDEO_KEYSYM    "XF86Display"
+#define ROTATE_KEYSYM   "XF86RotateWindows"
 
 /* Number of seconds that the confirmation dialog will last before it resets the
  * RANDR configuration to its old state.
@@ -89,6 +90,10 @@ struct GsdXrandrManagerPrivate
 
         /* Key code of the XF86Display key (Fn-F7 on Thinkpads, Fn-F4 on HP machines, etc.) */
         guint switch_video_mode_keycode;
+
+        /* Key code of the XF86RotateWindows key (present on some tablets) */
+        guint rotate_windows_keycode;
+
         GnomeRRScreen *rw_screen;
         gboolean running;
 
@@ -1929,6 +1934,18 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
                 gdk_error_trap_pop ();
         }
 
+        if (manager->priv->rotate_windows_keycode) {
+                gdk_error_trap_push ();
+
+                XGrabKey (gdk_x11_get_default_xdisplay(),
+                          manager->priv->rotate_windows_keycode, AnyModifier,
+                          gdk_x11_get_default_root_xwindow(),
+                          True, GrabModeAsync, GrabModeAsync);
+
+                gdk_flush ();
+                gdk_error_trap_pop ();
+        }
+
         show_timestamps_dialog (manager, "Startup");
         apply_stored_configuration_at_startup (manager, GDK_CURRENT_TIME); /* we don't have a real timestamp at startup anyway */
 
@@ -1960,6 +1977,16 @@ gsd_xrandr_manager_stop (GsdXrandrManager *manager)
                 gdk_error_trap_pop ();
         }
 
+        if (manager->priv->rotate_windows_keycode) {
+                gdk_error_trap_push ();
+
+                XUngrabKey (gdk_x11_get_default_xdisplay(),
+                            manager->priv->rotate_windows_keycode, AnyModifier,
+                            gdk_x11_get_default_root_xwindow());
+
+                gdk_error_trap_pop ();
+        }
+
         gdk_window_remove_filter (gdk_get_default_root_window (),
                                   (GdkFilterFunc) event_filter,
                                   manager);
@@ -2085,6 +2112,7 @@ gsd_xrandr_manager_init (GsdXrandrManager *manager)
         manager->priv = GSD_XRANDR_MANAGER_GET_PRIVATE (manager);
 
         manager->priv->switch_video_mode_keycode = get_keycode_for_keysym_name (VIDEO_KEYSYM);
+        manager->priv->rotate_windows_keycode = get_keycode_for_keysym_name (ROTATE_KEYSYM);
 
         manager->priv->current_fn_f7_config = -1;
         manager->priv->fn_f7_configs = NULL;



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