From bec068ef5ddc73f23ffd6298122bf818fd4d2084 Mon Sep 17 00:00:00 2001 From: infirit Date: Fri, 24 Oct 2014 21:59:58 +0200 Subject: Rework tiling code based off Consortium Taken from https://github.com/SolusOS-discontinued/consortium/commit/b463e03f5bdeab307ceee6b969c681f29537c76d --- src/core/keybindings.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/core/keybindings.c') diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 83dc4f93..8176b96f 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -1394,6 +1394,10 @@ process_mouse_move_resize_grab (MetaDisplay *display, if (keysym == XK_Escape) { + /* Restore the original tile mode */ + window->tile_mode = display->grab_tile_mode; + window->tile_monitor_number = display->grab_tile_monitor_number; + /* End move or resize and restore to original state. If the * window was a maximized window that had been "shaken loose" we * need to remaximize it. In normal cases, we need to do a @@ -1405,6 +1409,8 @@ process_mouse_move_resize_grab (MetaDisplay *display, meta_window_maximize (window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL); + else if (window->tile_mode == META_TILE_LEFT || window->tile_mode == META_TILE_RIGHT) + meta_window_tile (window); else if (!display->grab_wireframe_active) meta_window_move_resize (display->grab_window, TRUE, @@ -3016,6 +3022,43 @@ 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, + MetaWindow *window, + XEvent *event, + MetaKeyBinding *binding) +{ + 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_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 | + META_MAXIMIZE_HORIZONTAL); + } + else if (meta_window_can_tile (window)) + { + window->tile_mode = mode; + window->tile_monitor_number = meta_screen_get_xinerama_for_window (window->screen, window)->number; + /* 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, -- cgit v1.2.1