From 7e330bd65f9ce38744dbaf2084825c1420af892c Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Wed, 7 Jun 2017 19:07:26 +0200 Subject: [PATCH] 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 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(+) diff --git a/data/org.gnome.mutter.gschema.xml.in b/data/org.gnome.mutter.gschema.xml.in index 703817864..4ced07f13 100644 --- a/data/org.gnome.mutter.gschema.xml.in +++ b/data/org.gnome.mutter.gschema.xml.in @@ -156,6 +156,11 @@ Cancel tab popup + + p','XF86Display']]]> + Switch monitor configurations + + Rotates the built-in monitor configuration diff --git a/src/core/keybindings.c b/src/core/keybindings.c index c7e3c8869..518416ce2 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -3328,6 +3328,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, @@ -3632,6 +3653,13 @@ init_builtin_key_bindings (MetaDisplay *display) META_KEYBINDING_ACTION_SET_SPEW_MARK, 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, diff --git a/src/meta/prefs.h b/src/meta/prefs.h index 961d5abc3..a0175aea9 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