summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2017-08-18 21:27:35 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2017-09-08 15:27:19 -0300
commita06384ff464b040381b63184dc21d74ef5c3bc17 (patch)
tree9017e08599d94fb4779bfa9b04015b5c2979684e
parentc9a80def57e9cbd0d4c228e521f1812c93540285 (diff)
downloadmutter-wip/gbsneto/tiling-improvements.tar.gz
constraints: Preserve window ratio in tile constraintwip/gbsneto/tiling-improvements
Now that windows can be resized when tiled, the tiling constraint has no source of data to enforce a given size to the windowm and this aspect of the tiling constraint was lost. Fix that by storing the window screen ratio and applying it to the tiled windows in the tiling constraint. https://bugzilla.gnome.org/show_bug.cgi?id=645153
-rw-r--r--src/core/constraints.c30
-rw-r--r--src/core/window-private.h3
-rw-r--r--src/core/window.c19
3 files changed, 30 insertions, 22 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index 558e43d31..d1a775eb2 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -1020,8 +1020,6 @@ constrain_tiling (MetaWindow *window,
gboolean check_only)
{
MetaRectangle target_size;
- MetaRectangle min_size, max_size;
- gboolean hminbad, vminbad;
gboolean horiz_equal, vert_equal;
gboolean constraint_already_satisfied;
@@ -1032,24 +1030,13 @@ constrain_tiling (MetaWindow *window,
if (!META_WINDOW_TILED_SIDE_BY_SIDE (window))
return TRUE;
- /* Calculate target_size - as the tile previews need this as well, we
- * use an external function for the actual calculation
- */
- meta_window_get_tile_area_for_mode (window,
- window->tile_mode,
- window->tile_mode,
- window->tile_monitor_number,
- TRUE,
- &target_size);
-
- /* Check min size constraints; max size constraints are ignored as for
- * maximized windows.
- */
- get_size_limits (window, &min_size, &max_size);
- hminbad = target_size.width < min_size.width;
- vminbad = target_size.height < min_size.height;
- if (hminbad || vminbad)
- return TRUE;
+ target_size.x = info->work_area_monitor.x;
+ target_size.y = info->work_area_monitor.y;
+ target_size.width = info->work_area_monitor.width * window->hpercentage;
+ target_size.height = info->work_area_monitor.height * window->vpercentage;
+
+ if (window->tile_mode == META_TILE_RIGHT)
+ target_size.x += info->work_area_monitor.width - target_size.width;
/* Determine whether constraint is already satisfied; exit if it is */
horiz_equal = target_size.x == info->current.x &&
@@ -1061,13 +1048,14 @@ constrain_tiling (MetaWindow *window,
return constraint_already_satisfied;
/*** Enforce constraint ***/
+ info->current.x = target_size.x;
info->current.y = target_size.y;
+ info->current.width = target_size.width;
info->current.height = target_size.height;
return TRUE;
}
-
static gboolean
constrain_fullscreen (MetaWindow *window,
ConstraintInfo *info,
diff --git a/src/core/window-private.h b/src/core/window-private.h
index ce1157475..0c58675b3 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -213,6 +213,9 @@ struct _MetaWindow
guint previous_tile_mode : 2;
guint preview_tile_mode : 2;
+ gdouble hpercentage;
+ gdouble vpercentage;
+
int preferred_output_winsys_id;
/* Whether we're shaded */
diff --git a/src/core/window.c b/src/core/window.c
index ed67aa235..a57f59b29 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -3004,7 +3004,8 @@ meta_window_tile (MetaWindow *window,
meta_window_move_resize_internal (window,
(META_MOVE_RESIZE_MOVE_ACTION |
META_MOVE_RESIZE_RESIZE_ACTION |
- META_MOVE_RESIZE_STATE_CHANGED),
+ META_MOVE_RESIZE_STATE_CHANGED |
+ META_MOVE_RESIZE_USER_ACTION),
NorthWestGravity,
new_rect);
@@ -3733,6 +3734,18 @@ meta_window_update_monitor (MetaWindow *window,
}
}
+static void
+meta_window_update_screen_ratio (MetaWindow *window,
+ MetaRectangle rect)
+{
+ MetaRectangle workarea;
+
+ meta_window_get_work_area_current_monitor (window, &workarea);
+
+ window->hpercentage = rect.width / (gdouble) workarea.width;
+ window->vpercentage = rect.height / (gdouble) workarea.height;
+}
+
void
meta_window_move_resize_internal (MetaWindow *window,
MetaMoveResizeFlags flags,
@@ -3811,6 +3824,10 @@ meta_window_move_resize_internal (MetaWindow *window,
else
g_assert_not_reached ();
+ /* Only update percentage when the user resizes the window */
+ if ((flags & META_MOVE_RESIZE_USER_ACTION) && (flags & META_MOVE_RESIZE_RESIZE_ACTION))
+ meta_window_update_screen_ratio (window, unconstrained_rect);
+
constrained_rect = unconstrained_rect;
if (flags & (META_MOVE_RESIZE_MOVE_ACTION | META_MOVE_RESIZE_RESIZE_ACTION) &&
window->monitor)