From 0fe5c4f95774b857d0aaf7462841ff32bb95a5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 11 Dec 2013 17:57:45 +0100 Subject: [PATCH] keybinding: Implement keybindings for moving windows between monitors Currently the only way to move a window to another monitor via keyboard is to start a move operation and move it manually using arrow keys. We do have all the bits of a dedicated keybinding in place already, so offer it as a more comfortable alternative. https://bugzilla.gnome.org/show_bug.cgi?id=671054 --- src/core/keybindings.c | 49 ++++++++++++++++++++++++++++++++++++++++++ src/meta/prefs.h | 8 +++++++ 2 files changed, 57 insertions(+) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 7918a7c60..bd557baa3 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -41,6 +41,7 @@ #include "ui.h" #include "frame.h" #include "place.h" +#include "screen-private.h" #include #include @@ -3973,6 +3974,26 @@ handle_move_to_workspace (MetaDisplay *display, } } +static void +handle_move_to_monitor (MetaDisplay *display, + MetaScreen *screen, + MetaWindow *window, + XIDeviceEvent *event, + MetaKeyBinding *binding, + gpointer dummy) +{ + gint which = binding->handler->data; + const MetaMonitorInfo *current, *new; + + current = meta_screen_get_monitor_for_window (screen, window); + new = meta_screen_get_monitor_neighbor (screen, current->number, which); + + if (new == NULL) + return; + + meta_window_move_to_monitor (window, new->number); +} + static void handle_raise_or_lower (MetaDisplay *display, MetaScreen *screen, @@ -4629,6 +4650,34 @@ init_builtin_key_bindings (MetaDisplay *display) META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_DOWN, handle_move_to_workspace, META_MOTION_DOWN); + add_builtin_keybinding (display, + "move-to-monitor-left", + common_keybindings, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_LEFT, + handle_move_to_monitor, META_SCREEN_LEFT); + + add_builtin_keybinding (display, + "move-to-monitor-right", + common_keybindings, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_RIGHT, + handle_move_to_monitor, META_SCREEN_RIGHT); + + add_builtin_keybinding (display, + "move-to-monitor-down", + common_keybindings, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_DOWN, + handle_move_to_monitor, META_SCREEN_DOWN); + + add_builtin_keybinding (display, + "move-to-monitor-up", + common_keybindings, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_UP, + handle_move_to_monitor, META_SCREEN_UP); + add_builtin_keybinding (display, "raise-or-lower", common_keybindings, diff --git a/src/meta/prefs.h b/src/meta/prefs.h index fabe3525d..248d16cc8 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -243,6 +243,10 @@ void meta_prefs_set_ignore_request_hide_titlebar (gboolean whether); * @META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_RIGHT: FILLME * @META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_UP: FILLME * @META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_DOWN: FILLME + * @META_KEYBINDING_ACTION_MOVE_TO_MONITOR_LEFT: FILLME + * @META_KEYBINDING_ACTION_MOVE_TO_MONITOR_RIGHT: FILLME + * @META_KEYBINDING_ACTION_MOVE_TO_MONITOR_UP: FILLME + * @META_KEYBINDING_ACTION_MOVE_TO_MONITOR_DOWN: FILLME * @META_KEYBINDING_ACTION_RAISE_OR_LOWER: FILLME * @META_KEYBINDING_ACTION_RAISE: FILLME * @META_KEYBINDING_ACTION_LOWER: FILLME @@ -336,6 +340,10 @@ typedef enum _MetaKeyBindingAction META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_RIGHT, META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_UP, META_KEYBINDING_ACTION_MOVE_TO_WORKSPACE_DOWN, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_LEFT, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_RIGHT, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_UP, + META_KEYBINDING_ACTION_MOVE_TO_MONITOR_DOWN, META_KEYBINDING_ACTION_RAISE_OR_LOWER, META_KEYBINDING_ACTION_RAISE, META_KEYBINDING_ACTION_LOWER,