[mutter] keybindings: Add toggle-tile-left/right bindings
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] keybindings: Add toggle-tile-left/right bindings
- Date: Tue, 13 Dec 2011 13:42:05 +0000 (UTC)
commit 34f6ffd1ad0d3b7369120a9802d84517748fe887
Author: Florian MÃllner <fmuellner gnome org>
Date: Tue Nov 15 17:29:56 2011 +0100
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
.gitignore | 1 +
po/POTFILES.in | 1 +
src/50-mutter-windows.xml.in | 15 ++++++++++
src/Makefile.am | 7 ++++
src/core/keybindings.c | 53 +++++++++++++++++++++++++++++++++++
src/meta/prefs.h | 2 +
src/org.gnome.mutter.gschema.xml.in | 8 +++++
7 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 8238599..671b4b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ libtool
ltmain.sh
missing
.deps
+src/50-mutter-windows.xml
src/mutter-wm.desktop
src/mutter.desktop
*.o
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 40cab83..5845fd4 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,5 +1,6 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
+src/50-mutter-windows.xml.in
src/compositor/compositor.c
src/core/bell.c
src/core/core.c
diff --git a/src/50-mutter-windows.xml.in b/src/50-mutter-windows.xml.in
new file mode 100644
index 0000000..4e0ab9d
--- /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 7291a20..d9cbfda 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 5510d28..9d64755 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 6007c7c..8232a72 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 76f13d6..8d11154 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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]