From 0103f18326f7be7075933235f8c04264d2892528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Thu, 1 Jan 2015 19:16:35 -0500 Subject: Add the tile-to-side options to the appropiate files. This is just a copy/paste from move-to-side-{e,w} with: s/move/tile/g s/Move/Tile/g . It uses the existing handle_toggle_tiled as the backend. --- src/50-marco-window-key.xml.in | 8 ++++++++ src/include/all-keybindings.h | 5 +++++ src/marco.convert | 2 ++ src/org.mate.marco.gschema.xml | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/src/50-marco-window-key.xml.in b/src/50-marco-window-key.xml.in index 2dcfabc3..0b3ecef4 100644 --- a/src/50-marco-window-key.xml.in +++ b/src/50-marco-window-key.xml.in @@ -69,6 +69,14 @@ name="maximize-horizontally" _description="Maximize window horizontally" /> + + + + diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h index 5b030280..a14777e9 100644 --- a/src/include/all-keybindings.h +++ b/src/include/all-keybindings.h @@ -252,6 +252,11 @@ keybind (maximize-vertically, handle_maximize_vertically, 0, keybind (maximize-horizontally, handle_maximize_horizontally, 0, BINDING_PER_WINDOW) +keybind (tile-to-side-e, handle_toggle_tiled, META_TILE_RIGHT, + BINDING_PER_WINDOW) +keybind (tile-to-side-w, handle_toggle_tiled, META_TILE_LEFT, + BINDING_PER_WINDOW) + keybind (move-to-corner-nw, handle_move_to_corner_nw, 0, BINDING_PER_WINDOW) keybind (move-to-corner-ne, handle_move_to_corner_ne, 0, diff --git a/src/marco.convert b/src/marco.convert index eb1f623b..21c8799f 100644 --- a/src/marco.convert +++ b/src/marco.convert @@ -142,6 +142,8 @@ raise = /apps/marco/window_keybindings/raise lower = /apps/marco/window_keybindings/lower maximize-vertically = /apps/marco/window_keybindings/maximize_vertically maximize-horizontally = /apps/marco/window_keybindings/maximize_horizontally +tile-to-side-e = /apps/marco/window_keybindings/tile_to_side_e +tile-to-side-w = /apps/marco/window_keybindings/tile_to_side_w move-to-corner-nw = /apps/marco/window_keybindings/move_to_corner_nw move-to-corner-ne = /apps/marco/window_keybindings/move_to_corner_ne move-to-corner-sw = /apps/marco/window_keybindings/move_to_corner_sw diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml index a0725382..4108355c 100644 --- a/src/org.mate.marco.gschema.xml +++ b/src/org.mate.marco.gschema.xml @@ -838,6 +838,16 @@ Maximize window horizontally The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + 'disabled' + Tile window to east (right) side of screen + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + + 'disabled' + Tile window to west (left) side of screen + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + 'disabled' Move window to north-west (top left) corner -- cgit v1.2.1 From 8a34cf4df4214f8e15e46568ee581b672e559fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Thu, 1 Jan 2015 20:27:31 -0500 Subject: Update handle_toggle_tiled. These are the minimal changes needed to make the keybinds work. Anything else should be fixed outside handle_toggle_tiled. --- src/core/keybindings.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 041d96fc..c52fe3b8 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -3050,7 +3050,6 @@ handle_toggle_above (MetaDisplay *display, meta_window_make_above (window); } -/* TODO: actually use this keybinding, without messing up the existing keybinding schema */ static void handle_toggle_tiled (MetaDisplay *display, MetaScreen *screen, @@ -3063,14 +3062,20 @@ handle_toggle_tiled (MetaDisplay *display, if ((META_WINDOW_TILED_LEFT (window) && mode == META_TILE_LEFT) || (META_WINDOW_TILED_RIGHT (window) && mode == META_TILE_RIGHT)) { - window->tile_mode = 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 | + { + window->tile_mode = META_TILE_MAXIMIZED; + window->tile_monitor_number = meta_screen_get_xinerama_for_window (window->screen, window)->number; + meta_window_maximize (window, META_MAXIMIZE_VERTICAL | META_MAXIMIZE_HORIZONTAL); + } + else + { + window->tile_mode = META_TILE_NONE; + window->tile_monitor_number = -1; + meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL | + META_MAXIMIZE_HORIZONTAL); + } } else if (meta_window_can_tile (window)) { @@ -3082,6 +3087,13 @@ handle_toggle_tiled (MetaDisplay *display, * we just set the flag and rely on meta_window_tile() syncing it to * save an additional roundtrip. */ + + /* If we skip meta_window_unmaximize we have to manually reset the + * window->saved_maximize flag. + */ + if (!META_WINDOW_MAXIMIZED (window)) + window->saved_maximize = FALSE; + window->maximized_horizontally = FALSE; meta_window_tile (window); } -- cgit v1.2.1 From 07f6f968dbe96ff7c8eb4347f2bbb4457f73c30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Thu, 1 Jan 2015 21:24:40 -0500 Subject: BugFix: Can't unmaximize a tiled window. The removed code did not allow tiled windows to be unmaximized. The code was trying to retile a tiled window when it was asked to unmaximize it. The only thing it did was turn a maximized window into a tiled window but that is not the normal expected behaviour of unmaximization. . I also reset window->tile_mode to ensure we always unmaximize correctly. Some duplicate code was also removed. . This bug affects tiling with: - tile-to-side-w - tile-to-side-e - Mouse dragging to the west corner - Mouse dragging to the east corner . Therefore it's an old bug unrelated to the new keybindings. --- src/core/window.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 95d49885..e820a26c 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -2667,17 +2667,12 @@ meta_window_maximize (MetaWindow *window, return; } - if (window->tile_mode != META_TILE_NONE) - { - saved_rect = &window->saved_rect; - window->maximized_vertically = FALSE; - } - if (window->tile_mode != META_TILE_NONE) { saved_rect = &window->saved_rect; window->maximized_vertically = FALSE; + window->tile_mode = META_TILE_NONE; } meta_window_maximize_internal (window, @@ -2780,15 +2775,6 @@ meta_window_unmaximize (MetaWindow *window, /* At least one of the two directions ought to be set */ gboolean unmaximize_horizontally, unmaximize_vertically; - /* Restore tiling if necessary */ - if (window->tile_mode == META_TILE_LEFT || - window->tile_mode == META_TILE_RIGHT) - { - window->maximized_horizontally = FALSE; - meta_window_tile (window); - return; - } - unmaximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL; unmaximize_vertically = directions & META_MAXIMIZE_VERTICAL; g_assert (unmaximize_horizontally || unmaximize_vertically); -- cgit v1.2.1 From 060838853303871a9fbb1ddfe0228668318070e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20A=2E=20Col=C3=B3n=20V=C3=A9lez?= Date: Thu, 1 Jan 2015 22:44:29 -0500 Subject: BugFix: Can't retile to a different corner with keybindings. has_maximize_func implies window->has_resize_func !window->fullscreen window->has_resize_func implies (window->size_hints.min_width < window->size_hints.max_width) || (window->size_hints.min_height < window->size_hints.max_height) A tiled window implies that it could be tiled. A maximized window implies that it could be tiled. . Therefore simplify the if and add window->shaded to make it equivalent to the macro but allowing to tile already maximized/tiled windows. . If this commit causes a regression it probably means that a call to meta_window_recalc_features is missing. . This bug already existed but can only be triggered by the new keybindings. --- src/core/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/window.c b/src/core/window.c index e820a26c..6f5a5fe0 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -2746,7 +2746,7 @@ meta_window_can_tile (MetaWindow *window) MetaRectangle tile_area; /*if (!META_WINDOW_ALLOWS_RESIZE (window))*/ - if (!META_WINDOW_ALLOWS_RESIZE (window)) + if (!meta_window_can_tile_maximized (window) || window->shaded) return FALSE; monitor = meta_screen_get_current_xinerama (window->screen); -- cgit v1.2.1