[mutter] keybindings: Add a switch-monitor builtin keybinding
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] keybindings: Add a switch-monitor builtin keybinding
- Date: Wed, 19 Jul 2017 09:20:50 +0000 (UTC)
commit 7e330bd65f9ce38744dbaf2084825c1420af892c
Author: Rui Matos <tiagomatos gmail com>
Date: Wed Jun 7 19:07:26 2017 +0200
keybindings: Add a switch-monitor builtin keybinding
Moved from g-s-d's media keys plugin, where it was called "video-out",
since it requires changing the current monitor configuration and we
want to remove the old DBus API.
This implementation is intentionally simple and not really meant for
more than debugging and validating the various configurations. A
better user experience will be introduced in gnome-shell with a custom
keybinding handler.
The default value includes <Super>P in addition to the standard keysym
for historical reasons.
https://bugzilla.gnome.org/show_bug.cgi?id=781906
data/org.gnome.mutter.gschema.xml.in | 5 +++++
src/core/keybindings.c | 28 ++++++++++++++++++++++++++++
src/meta/prefs.h | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in
index 7038178..4ced07f 100644
--- a/data/org.gnome.mutter.gschema.xml.in
+++ b/data/org.gnome.mutter.gschema.xml.in
@@ -156,6 +156,11 @@
<summary>Cancel tab popup</summary>
</key>
+ <key name="switch-monitor" type="as">
+ <default><![CDATA[['<Super>p','XF86Display']]]></default>
+ <summary>Switch monitor configurations</summary>
+ </key>
+
<key name="rotate-monitor" type="as">
<default><![CDATA[['XF86RotateWindows']]]></default>
<summary>Rotates the built-in monitor configuration</summary>
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index c7e3c88..518416c 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -3329,6 +3329,27 @@ handle_switch_vt (MetaDisplay *display,
#endif /* HAVE_NATIVE_BACKEND */
static void
+handle_switch_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);
+ MetaMonitorSwitchConfigType config_type =
+ meta_monitor_manager_get_switch_config (monitor_manager);
+
+ if (!meta_monitor_manager_can_switch_config (monitor_manager))
+ return;
+
+ config_type = (config_type + 1) % (META_MONITOR_SWITCH_CONFIG_UNKNOWN);
+ meta_monitor_manager_switch_config (monitor_manager, config_type);
+}
+
+static void
handle_rotate_monitor (MetaDisplay *display,
MetaScreen *screen,
MetaWindow *window,
@@ -3633,6 +3654,13 @@ init_builtin_key_bindings (MetaDisplay *display)
handle_set_spew_mark, 0);
add_builtin_keybinding (display,
+ "switch-monitor",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_SWITCH_MONITOR,
+ handle_switch_monitor, 0);
+
+ add_builtin_keybinding (display,
"rotate-monitor",
mutter_keybindings,
META_KEY_BINDING_NONE,
diff --git a/src/meta/prefs.h b/src/meta/prefs.h
index 961d5ab..a0175ae 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_SWITCH_MONITOR,
META_KEYBINDING_ACTION_ROTATE_MONITOR,
META_KEYBINDING_ACTION_LAST
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]