diff --git a/src/core/constraints.c b/src/core/constraints.c index 14044a957..f5360ef9d 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -943,7 +943,7 @@ constrain_maximization (MetaWindow *window, /* Calculate target_size = maximized size of (window + frame) */ if (META_WINDOW_TILED_MAXIMIZED (window)) { - meta_window_get_current_tile_area (window, &target_size); + meta_window_get_tile_area (window, window->tile_mode, &target_size); } else if (META_WINDOW_MAXIMIZED (window)) { @@ -1030,7 +1030,7 @@ constrain_tiling (MetaWindow *window, /* Calculate target_size - as the tile previews need this as well, we * use an external function for the actual calculation */ - meta_window_get_current_tile_area (window, &target_size); + meta_window_get_tile_area (window, window->tile_mode, &target_size); /* Check min size constraints; max size constraints are ignored as for * maximized windows. diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 41becb632..bbf98720b 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -2222,7 +2222,7 @@ process_mouse_move_resize_grab (MetaDisplay *display, if (event->keyval == CLUTTER_KEY_Escape) { /* Hide the tiling preview if necessary */ - if (window->tile_mode != META_TILE_NONE) + if (screen->preview_tile_mode != META_TILE_NONE) meta_screen_hide_tile_preview (screen); /* Restore the original tile mode */ diff --git a/src/core/screen-private.h b/src/core/screen-private.h index df1469930..ff796f01a 100644 --- a/src/core/screen-private.h +++ b/src/core/screen-private.h @@ -56,6 +56,7 @@ struct _MetaScreen MetaUI *ui; guint tile_preview_timeout_id; + guint preview_tile_mode : 2; MetaWorkspace *active_workspace; diff --git a/src/core/screen.c b/src/core/screen.c index c96aefd7f..e6c6cdd26 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1410,7 +1410,7 @@ meta_screen_update_tile_preview_timeout (gpointer data) if (window) { - switch (window->tile_mode) + switch (screen->preview_tile_mode) { case META_TILE_LEFT: case META_TILE_RIGHT: @@ -1435,7 +1435,7 @@ meta_screen_update_tile_preview_timeout (gpointer data) int monitor; monitor = meta_window_get_current_tile_monitor_number (window); - meta_window_get_current_tile_area (window, &tile_rect); + meta_window_get_tile_area (window, screen->preview_tile_mode, &tile_rect); meta_compositor_show_tile_preview (screen->display->compositor, window, &tile_rect, monitor); } @@ -1479,6 +1479,7 @@ meta_screen_hide_tile_preview (MetaScreen *screen) g_source_remove (screen->tile_preview_timeout_id); screen->tile_preview_timeout_id = 0; + screen->preview_tile_mode = META_TILE_NONE; meta_compositor_hide_tile_preview (screen->display->compositor); } diff --git a/src/core/window-private.h b/src/core/window-private.h index c3a1c0250..d50beae8b 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -199,9 +199,7 @@ struct _MetaWindow guint maximize_vertically_after_placement : 1; guint minimize_after_placement : 1; - /* The current or requested tile mode. If maximized_vertically is true, - * this is the current mode. If not, it is the mode which will be - * requested after the window grab is released */ + /* The current tile mode */ guint tile_mode : 2; /* The last "full" maximized/unmaximized state. We need to keep track of * that to toggle between normal/tiled or maximized/tiled states. */ @@ -648,8 +646,9 @@ void meta_window_get_work_area_for_logical_monitor (MetaWindow *window, MetaRectangle *area); int meta_window_get_current_tile_monitor_number (MetaWindow *window); -void meta_window_get_current_tile_area (MetaWindow *window, - MetaRectangle *tile_area); +void meta_window_get_tile_area (MetaWindow *window, + MetaTileMode mode, + MetaRectangle *tile_area); gboolean meta_window_same_application (MetaWindow *window, diff --git a/src/core/window.c b/src/core/window.c index 09020d590..88a9f22a2 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -3102,6 +3102,9 @@ meta_window_unmaximize (MetaWindow *window, meta_window_get_frame_rect (window, &old_frame_rect); meta_window_get_buffer_rect (window, &old_buffer_rect); + if (unmaximize_vertically) + window->tile_mode = META_TILE_NONE; + meta_topic (META_DEBUG_WINDOW_OPS, "Unmaximizing %s%s\n", window->desc, @@ -5713,6 +5716,7 @@ update_move_maybe_tile (MetaWindow *window, MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; + MetaScreen *screen = window->screen; MetaRectangle work_area; /* For side-by-side tiling we are interested in the inside vertical @@ -5742,18 +5746,18 @@ update_move_maybe_tile (MetaWindow *window, */ if (meta_window_can_tile_side_by_side (window) && x >= logical_monitor->rect.x && x < (work_area.x + shake_threshold)) - window->tile_mode = META_TILE_LEFT; + screen->preview_tile_mode = META_TILE_LEFT; else if (meta_window_can_tile_side_by_side (window) && x >= work_area.x + work_area.width - shake_threshold && x < (logical_monitor->rect.x + logical_monitor->rect.width)) - window->tile_mode = META_TILE_RIGHT; + screen->preview_tile_mode = META_TILE_RIGHT; else if (meta_window_can_tile_maximized (window) && y >= logical_monitor->rect.y && y <= work_area.y) - window->tile_mode = META_TILE_MAXIMIZED; + screen->preview_tile_mode = META_TILE_MAXIMIZED; else - window->tile_mode = META_TILE_NONE; + screen->preview_tile_mode = META_TILE_NONE; - if (window->tile_mode != META_TILE_NONE) + if (screen->preview_tile_mode != META_TILE_NONE) window->tile_monitor_number = logical_monitor->number; } @@ -5768,6 +5772,7 @@ update_move (MetaWindow *window, MetaRectangle old; int shake_threshold; MetaDisplay *display = window->display; + MetaScreen *screen = window->screen; display->grab_latest_motion_x = x; display->grab_latest_motion_y = y; @@ -5805,7 +5810,7 @@ update_move (MetaWindow *window, { /* We don't want to tile while snapping. Also, clear any previous tile request. */ - window->tile_mode = META_TILE_NONE; + screen->preview_tile_mode = META_TILE_NONE; window->tile_monitor_number = -1; } else if (meta_prefs_get_edge_tiling () && @@ -5921,8 +5926,8 @@ update_move (MetaWindow *window, * trigger it unwittingly, e.g. when shaking loose the window or moving * it to another monitor. */ - meta_screen_update_tile_preview (window->screen, - window->tile_mode != META_TILE_NONE); + meta_screen_update_tile_preview (screen, + screen->preview_tile_mode != META_TILE_NONE); meta_window_get_frame_rect (window, &old); @@ -6118,6 +6123,7 @@ 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); else @@ -6133,6 +6139,7 @@ end_grab_op (MetaWindow *window, TRUE); } } + window->screen->preview_tile_mode = META_TILE_NONE; meta_display_end_grab_op (window->display, clutter_event_get_time (event)); } @@ -6336,22 +6343,22 @@ meta_window_get_current_tile_monitor_number (MetaWindow *window) } void -meta_window_get_current_tile_area (MetaWindow *window, - MetaRectangle *tile_area) +meta_window_get_tile_area (MetaWindow *window, + MetaTileMode tile_mode, + MetaRectangle *tile_area) { int tile_monitor_number; - g_return_if_fail (window->tile_mode != META_TILE_NONE); + g_return_if_fail (tile_mode != META_TILE_NONE); tile_monitor_number = meta_window_get_current_tile_monitor_number (window); meta_window_get_work_area_for_monitor (window, tile_monitor_number, tile_area); - if (window->tile_mode == META_TILE_LEFT || - window->tile_mode == META_TILE_RIGHT) + if (tile_mode == META_TILE_LEFT || tile_mode == META_TILE_RIGHT) tile_area->width /= 2; - if (window->tile_mode == META_TILE_RIGHT) + if (tile_mode == META_TILE_RIGHT) tile_area->x += tile_area->width; }