diff options
author | Florian Müllner <fmuellner@gnome.org> | 2011-11-15 17:29:56 +0100 |
---|---|---|
committer | Florian Müllner <fmuellner@gnome.org> | 2011-12-13 14:36:40 +0100 |
commit | 34f6ffd1ad0d3b7369120a9802d84517748fe887 (patch) | |
tree | 3f0a9fbc01c8de1a5f8592ea89ab1bd0d445f39c /src | |
parent | baeb9fbc4b7441ce7ee59848b48ce8c0da92b4fc (diff) | |
download | mutter-34f6ffd1ad0d3b7369120a9802d84517748fe887.tar.gz |
keybindings: Add toggle-tile-left/right bindings
Having keybindings for side-by-side tiling has been requested for
a long time, so add this support now.
https://bugzilla.gnome.org/show_bug.cgi?id=648700
Diffstat (limited to 'src')
-rw-r--r-- | src/50-mutter-windows.xml.in | 15 | ||||
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/core/keybindings.c | 53 | ||||
-rw-r--r-- | src/meta/prefs.h | 2 | ||||
-rw-r--r-- | src/org.gnome.mutter.gschema.xml.in | 8 |
5 files changed, 85 insertions, 0 deletions
diff --git a/src/50-mutter-windows.xml.in b/src/50-mutter-windows.xml.in new file mode 100644 index 000000000..4e0ab9d52 --- /dev/null +++ b/src/50-mutter-windows.xml.in @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<KeyListEntries schema="org.gnome.mutter.keybindings" + group="system" + _name="Windows" + wm_name="Mutter" + package="mutter"> + + <KeyListEntry name="toggle-tiled-left" + _description="View split on left"/> + + <KeyListEntry name="toggle-tiled-right" + _description="View split on right"/> + +</KeyListEntries> + diff --git a/src/Makefile.am b/src/Makefile.am index 7291a20b5..d9cbfdaba 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -261,6 +261,11 @@ wmproperties_in_files=mutter-wm.desktop.in wmproperties_files=$(wmproperties_in_files:.desktop.in=.desktop) wmproperties_DATA = $(wmproperties_files) +xmldir = @GNOME_KEYBINDINGS_KEYSDIR@ +xml_in_files = \ + 50-mutter-windows.xml.in +xml_DATA = $(xml_in_files:.xml.in=.xml) + gsettings_SCHEMAS = org.gnome.mutter.gschema.xml @INTLTOOL_XML_NOMERGE_RULE@ @GSETTINGS_RULES@ @@ -279,6 +284,7 @@ CLEANFILES = \ mutter.desktop \ mutter-wm.desktop \ org.gnome.mutter.gschema.xml \ + $(xml_DATA) \ $(mutter_built_sources) \ $(typelib_DATA) \ $(gir_DATA) @@ -295,6 +301,7 @@ EXTRA_DIST=$(desktopfiles_files) \ $(IMAGES) \ $(desktopfiles_in_files) \ $(wmproperties_in_files) \ + $(xml_in_files) \ org.gnome.mutter.gschema.xml.in \ mutter-schemas.convert \ libmutter.pc.in \ diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 5510d2876..9d647557c 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -3233,6 +3233,45 @@ handle_toggle_above (MetaDisplay *display, } static void +handle_toggle_tiled (MetaDisplay *display, + MetaScreen *screen, + MetaWindow *window, + XEvent *event, + MetaKeyBinding *binding, + gpointer dummy) +{ + MetaTileMode mode = binding->handler->data; + + if ((META_WINDOW_TILED_LEFT (window) && mode == META_TILE_LEFT) || + (META_WINDOW_TILED_RIGHT (window) && mode == META_TILE_RIGHT)) + { + window->tile_monitor_number = window->saved_maximize ? window->monitor->number + : -1; + window->tile_mode = window->saved_maximize ? META_TILE_MAXIMIZED + : META_TILE_NONE; + + if (window->saved_maximize) + meta_window_maximize (window, META_MAXIMIZE_VERTICAL | + META_MAXIMIZE_HORIZONTAL); + else + meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL | + META_MAXIMIZE_HORIZONTAL); + } + else if (meta_window_can_tile_side_by_side (window)) + { + window->tile_monitor_number = window->monitor->number; + window->tile_mode = mode; + /* Maximization constraints beat tiling constraints, so if the window + * is maximized, tiling won't have any effect unless we unmaximize it + * horizontally first; rather than calling meta_window_unmaximize(), + * we just set the flag and rely on meta_window_tile() syncing it to + * save an additional roundtrip. + window->maximized_horizontally = FALSE; + meta_window_tile (window); + } +} + +static void handle_toggle_maximized (MetaDisplay *display, MetaScreen *screen, MetaWindow *window, @@ -3890,6 +3929,20 @@ init_builtin_key_bindings (MetaDisplay *display) handle_toggle_maximized, 0); add_builtin_keybinding (display, + "toggle-tiled-left", + SCHEMA_MUTTER_KEYBINDINGS, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_TOGGLE_TILED_LEFT, + handle_toggle_tiled, META_TILE_LEFT); + + add_builtin_keybinding (display, + "toggle-tiled-right", + SCHEMA_MUTTER_KEYBINDINGS, + META_KEY_BINDING_PER_WINDOW, + META_KEYBINDING_ACTION_TOGGLE_TILED_RIGHT, + handle_toggle_tiled, META_TILE_RIGHT); + + add_builtin_keybinding (display, "toggle-above", SCHEMA_COMMON_KEYBINDINGS, META_KEY_BINDING_PER_WINDOW, diff --git a/src/meta/prefs.h b/src/meta/prefs.h index 6007c7c03..8232a7254 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -191,6 +191,8 @@ typedef enum _MetaKeyBindingAction META_KEYBINDING_ACTION_ACTIVATE_WINDOW_MENU, META_KEYBINDING_ACTION_TOGGLE_FULLSCREEN, META_KEYBINDING_ACTION_TOGGLE_MAXIMIZED, + META_KEYBINDING_ACTION_TOGGLE_TILED_LEFT, + META_KEYBINDING_ACTION_TOGGLE_TILED_RIGHT, META_KEYBINDING_ACTION_TOGGLE_ABOVE, META_KEYBINDING_ACTION_MAXIMIZE, META_KEYBINDING_ACTION_UNMAXIMIZE, diff --git a/src/org.gnome.mutter.gschema.xml.in b/src/org.gnome.mutter.gschema.xml.in index 76f13d688..8d11154e1 100644 --- a/src/org.gnome.mutter.gschema.xml.in +++ b/src/org.gnome.mutter.gschema.xml.in @@ -83,6 +83,14 @@ <default><![CDATA[['<Control><Shift><Alt>r']]]></default> </key> + <key name="toggle-tiled-left" type="as"> + <default><![CDATA[['<Super>Left']]]></default> + </key> + + <key name="toggle-tiled-right" type="as"> + <default><![CDATA[['<Super>Right']]]></default> + </key> + <key name="tab-popup-select" type="as"> <default>[]</default> <_summary>Select window from tab popup</_summary> |