[mutter/wayland] keybinding: Implement keybindings for moving windows between monitors



commit c54a19825b8fd8620925e7b500c646be51432685
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Dec 11 17:57:45 2013 +0100

    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(+), 0 deletions(-)
---
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index aa137d2..1f40c68 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 <meta/prefs.h>
 #include "util-private.h"
 
@@ -3930,6 +3931,26 @@ handle_move_to_workspace  (MetaDisplay     *display,
 }
 
 static void
+handle_move_to_monitor (MetaDisplay    *display,
+                        MetaScreen     *screen,
+                        MetaWindow     *window,
+                       ClutterKeyEvent *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,
                       MetaWindow      *window,
@@ -4671,6 +4692,34 @@ init_builtin_key_bindings (MetaDisplay *display)
                           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,
                           META_KEY_BINDING_PER_WINDOW,
diff --git a/src/meta/prefs.h b/src/meta/prefs.h
index 93dcfbd..3ccaddb 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,


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