[mutter] keybindings: Add a rotate-monitor builtin keybinding



commit c614a2db285458f0d6319e90039f725da9b04d66
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri May 5 17:51:06 2017 +0200

    keybindings: Add a rotate-monitor builtin keybinding
    
    Moved from g-s-d's media keys plugin, where it was called
    "video-rotate", since it requires changing the current monitor
    configuration and we want to remove the old DBus API.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781906

 data/org.gnome.mutter.gschema.xml.in |    5 +++++
 src/core/keybindings.c               |   23 +++++++++++++++++++++++
 src/meta/prefs.h                     |    1 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in
index 7e59c16..95aa42e 100644
--- a/data/org.gnome.mutter.gschema.xml.in
+++ b/data/org.gnome.mutter.gschema.xml.in
@@ -156,5 +156,10 @@
       <summary>Cancel tab popup</summary>
     </key>
 
+    <key name="rotate-monitor" type="as">
+      <default><![CDATA[['XF86RotateWindows']]]></default>
+      <summary>Rotates the built-in monitor configuration</summary>
+    </key>
+
   </schema>
 </schemalist>
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index f2aafdd..c7e3c88 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -44,6 +44,7 @@
 #define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */
 #endif
 
+#include "backends/meta-monitor-manager-private.h"
 #include "backends/meta-logical-monitor.h"
 #include "backends/x11/meta-backend-x11.h"
 #include "x11/window-x11.h"
@@ -3327,6 +3328,21 @@ handle_switch_vt (MetaDisplay     *display,
 }
 #endif /* HAVE_NATIVE_BACKEND */
 
+static void
+handle_rotate_monitor (MetaDisplay    *display,
+                       MetaScreen     *screen,
+                       MetaWindow     *window,
+                       ClutterKeyEvent *event,
+                       MetaKeyBinding *binding,
+                       gpointer        dummy)
+{
+  MetaBackend *backend = meta_get_backend ();
+  MetaMonitorManager *monitor_manager =
+    meta_backend_get_monitor_manager (backend);
+
+  meta_monitor_manager_rotate_monitor (monitor_manager);
+}
+
 /**
  * meta_keybindings_set_custom_handler:
  * @name: The name of the keybinding to set
@@ -3616,6 +3632,13 @@ init_builtin_key_bindings (MetaDisplay *display)
                           META_KEYBINDING_ACTION_SET_SPEW_MARK,
                           handle_set_spew_mark, 0);
 
+  add_builtin_keybinding (display,
+                          "rotate-monitor",
+                          mutter_keybindings,
+                          META_KEY_BINDING_NONE,
+                          META_KEYBINDING_ACTION_ROTATE_MONITOR,
+                          handle_rotate_monitor, 0);
+
 #ifdef HAVE_NATIVE_BACKEND
   MetaBackend *backend = meta_get_backend ();
   if (META_IS_BACKEND_NATIVE (backend))
diff --git a/src/meta/prefs.h b/src/meta/prefs.h
index 9887634..961d5ab 100644
--- a/src/meta/prefs.h
+++ b/src/meta/prefs.h
@@ -357,6 +357,7 @@ typedef enum _MetaKeyBindingAction
   META_KEYBINDING_ACTION_OVERLAY_KEY,
   META_KEYBINDING_ACTION_ISO_NEXT_GROUP,
   META_KEYBINDING_ACTION_ALWAYS_ON_TOP,
+  META_KEYBINDING_ACTION_ROTATE_MONITOR,
 
   META_KEYBINDING_ACTION_LAST
 } MetaKeyBindingAction;


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