summaryrefslogtreecommitdiff
path: root/src/core/keybindings.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-10-28 12:12:43 -0400
committerraveit65 <[email protected]>2019-10-31 09:51:11 +0100
commitae80350494d7e0756ab51191092db4347defa030 (patch)
tree27e5ac349738590d490bd2ab2781a27e3d6ad950 /src/core/keybindings.c
parent3523b6b7c0aaa47cc00b176769d248f77ca8751c (diff)
downloadmarco-ae80350494d7e0756ab51191092db4347defa030.tar.bz2
marco-ae80350494d7e0756ab51191092db4347defa030.tar.xz
window: Add optional tile size cycling
Adding a new option to allow tile size cycling. When enabled, using the keyboard shortcut for tiling multiple times in a row cycles the window through different sizes (1/2 -> 1/3 -> 1/4 -> 3/4 -> 2/3 -> Untiled).
Diffstat (limited to 'src/core/keybindings.c')
-rw-r--r--src/core/keybindings.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index e94d1824..e9597340 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -3161,15 +3161,63 @@ handle_toggle_tiled (MetaDisplay *display,
MetaKeyBinding *binding)
{
MetaTileMode mode = binding->handler->data;
+ MetaTileCycle next_cycle;
- if (mode == window->tile_mode && META_WINDOW_TILED(window))
+ /* Check if we're cycling through tile ratios */
+ if (meta_prefs_get_allow_tile_cycling ())
+ {
+ if (window->tile_mode != mode)
+ {
+ /* If changing tile mode, reset to first tile size */
+ next_cycle = META_TILE_CYCLE_50;
+ }
+ else
+ {
+ /* Cycle through the different tile sizes: 1/2 -> 1/3 -> 1/4 -> 3/4 -> 2/3 -> Untiled */
+ switch (window->tile_cycle)
+ {
+ case META_TILE_CYCLE_NONE:
+ next_cycle = META_TILE_CYCLE_50;
+ break;
+ case META_TILE_CYCLE_50:
+ next_cycle = META_TILE_CYCLE_33;
+ break;
+ case META_TILE_CYCLE_33:
+ next_cycle = META_TILE_CYCLE_25;
+ break;
+ case META_TILE_CYCLE_25:
+ next_cycle = META_TILE_CYCLE_75;
+ break;
+ case META_TILE_CYCLE_75:
+ next_cycle = META_TILE_CYCLE_66;
+ break;
+ case META_TILE_CYCLE_66:
+ next_cycle = META_TILE_CYCLE_NONE;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (META_WINDOW_TILED(window))
+ next_cycle = META_TILE_CYCLE_NONE;
+ else
+ next_cycle = META_TILE_CYCLE_50;
+ }
+
+ if (mode == window->tile_mode && next_cycle == META_TILE_CYCLE_NONE)
{
window->tile_mode = META_TILE_NONE;
window->tile_monitor_number = -1;
+ window->tile_cycle = META_TILE_CYCLE_NONE;
meta_window_untile(window);
}
else if (meta_window_can_tile (window))
{
+ window->tile_cycle = next_cycle;
window->tile_mode = mode;
window->tile_resized = FALSE;
window->tile_monitor_number = meta_screen_get_xinerama_for_window (window->screen, window)->number;