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
This commit is contained in:
Rui Matos 2017-05-05 17:51:06 +02:00
parent 7360f51ee8
commit c614a2db28
3 changed files with 29 additions and 0 deletions

View File

@ -156,5 +156,10 @@
<summary>Cancel tab popup</summary> <summary>Cancel tab popup</summary>
</key> </key>
<key name="rotate-monitor" type="as">
<default><![CDATA[['XF86RotateWindows']]]></default>
<summary>Rotates the built-in monitor configuration</summary>
</key>
</schema> </schema>
</schemalist> </schemalist>

View File

@ -44,6 +44,7 @@
#define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */ #define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */
#endif #endif
#include "backends/meta-monitor-manager-private.h"
#include "backends/meta-logical-monitor.h" #include "backends/meta-logical-monitor.h"
#include "backends/x11/meta-backend-x11.h" #include "backends/x11/meta-backend-x11.h"
#include "x11/window-x11.h" #include "x11/window-x11.h"
@ -3327,6 +3328,21 @@ handle_switch_vt (MetaDisplay *display,
} }
#endif /* HAVE_NATIVE_BACKEND */ #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: * meta_keybindings_set_custom_handler:
* @name: The name of the keybinding to set * @name: The name of the keybinding to set
@ -3616,6 +3632,13 @@ init_builtin_key_bindings (MetaDisplay *display)
META_KEYBINDING_ACTION_SET_SPEW_MARK, META_KEYBINDING_ACTION_SET_SPEW_MARK,
handle_set_spew_mark, 0); 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 #ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend (); MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend)) if (META_IS_BACKEND_NATIVE (backend))

View File

@ -357,6 +357,7 @@ typedef enum _MetaKeyBindingAction
META_KEYBINDING_ACTION_OVERLAY_KEY, META_KEYBINDING_ACTION_OVERLAY_KEY,
META_KEYBINDING_ACTION_ISO_NEXT_GROUP, META_KEYBINDING_ACTION_ISO_NEXT_GROUP,
META_KEYBINDING_ACTION_ALWAYS_ON_TOP, META_KEYBINDING_ACTION_ALWAYS_ON_TOP,
META_KEYBINDING_ACTION_ROTATE_MONITOR,
META_KEYBINDING_ACTION_LAST META_KEYBINDING_ACTION_LAST
} MetaKeyBindingAction; } MetaKeyBindingAction;