window: Pass mode as parameter to tile() operation

Now that the preview tile mode has been split from the window's
tile_mode property, it is much more natural to pass the requested
tile_mode to the tile() function instead of setting it externally
and calling the function to apply the state.
This commit is contained in:
Florian Müllner 2017-09-27 15:11:54 +02:00 committed by Georges Basile Stavracas Neto
parent a2dcf44c60
commit 5b5d8676d4
3 changed files with 15 additions and 11 deletions

View File

@ -2221,12 +2221,14 @@ process_mouse_move_resize_grab (MetaDisplay *display,
if (event->keyval == CLUTTER_KEY_Escape)
{
MetaTileMode tile_mode;
/* Hide the tiling preview if necessary */
if (screen->preview_tile_mode != META_TILE_NONE)
meta_screen_hide_tile_preview (screen);
/* Restore the original tile mode */
window->tile_mode = display->grab_tile_mode;
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
@ -2234,10 +2236,10 @@ process_mouse_move_resize_grab (MetaDisplay *display,
* need to remaximize it. In normal cases, we need to do a
* moveresize now to get the position back to the original.
*/
if (window->shaken_loose || window->tile_mode == META_TILE_MAXIMIZED)
if (window->shaken_loose || tile_mode == META_TILE_MAXIMIZED)
meta_window_maximize (window, META_MAXIMIZE_BOTH);
else if (window->tile_mode != META_TILE_NONE)
meta_window_tile (window);
else if (tile_mode != META_TILE_NONE)
meta_window_tile (window, tile_mode);
else
meta_window_move_resize_frame (display->grab_window,
TRUE,
@ -3184,7 +3186,6 @@ handle_toggle_tiled (MetaDisplay *display,
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(),
@ -3192,7 +3193,7 @@ handle_toggle_tiled (MetaDisplay *display,
* save an additional roundtrip.
*/
window->maximized_horizontally = FALSE;
meta_window_tile (window);
meta_window_tile (window, mode);
}
}

View File

@ -577,7 +577,8 @@ void meta_window_unmanage (MetaWindow *window,
guint32 timestamp);
void meta_window_queue (MetaWindow *window,
guint queuebits);
void meta_window_tile (MetaWindow *window);
void meta_window_tile (MetaWindow *window,
MetaTileMode mode);
void meta_window_maximize_internal (MetaWindow *window,
MetaMaximizeFlags directions,
MetaRectangle *saved_rect);

View File

@ -2969,11 +2969,14 @@ meta_window_requested_dont_bypass_compositor (MetaWindow *window)
}
void
meta_window_tile (MetaWindow *window)
meta_window_tile (MetaWindow *window,
MetaTileMode tile_mode)
{
MetaMaximizeFlags directions;
MetaRectangle old_frame_rect, old_buffer_rect;
window->tile_mode = tile_mode;
/* Don't do anything if no tiling is requested */
if (window->tile_mode == META_TILE_NONE)
return;
@ -6123,9 +6126,8 @@ end_grab_op (MetaWindow *window,
{
if (meta_grab_op_is_moving (window->display->grab_op))
{
window->tile_mode = window->screen->preview_tile_mode;
if (window->tile_mode != META_TILE_NONE)
meta_window_tile (window);
if (window->screen->preview_tile_mode != META_TILE_NONE)
meta_window_tile (window, window->screen->preview_tile_mode);
else
update_move (window,
modifiers & CLUTTER_SHIFT_MASK,