[mutter] Revert "window: Move placement code from the constraints path"
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Revert "window: Move placement code from the constraints path"
- Date: Tue, 24 Jun 2014 22:02:32 +0000 (UTC)
commit 555e2f6de21eb23750ac571f652db0d7de259265
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jun 19 19:02:14 2014 +0200
Revert "window: Move placement code from the constraints path"
Window state like maximization and minimization should be preserved
over restarts - in a patch review, this would qualify as "needs-work",
so revert the cleanup until the issues are fixed.
This reverts commit dc6decefb5cbd14d5ab059a59952fd96e86dc763.
src/core/constraints.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++
src/core/window.c | 104 +++++---------------------------------------
2 files changed, 125 insertions(+), 92 deletions(-)
---
diff --git a/src/core/constraints.c b/src/core/constraints.c
index baf4fd2..42204bc 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -195,6 +195,8 @@ static void setup_constraint_info (ConstraintInfo *info,
int resize_gravity,
const MetaRectangle *orig,
MetaRectangle *new);
+static void place_window_if_needed (MetaWindow *window,
+ ConstraintInfo *info);
static void update_onscreen_requirements (MetaWindow *window,
ConstraintInfo *info);
@@ -285,6 +287,7 @@ meta_window_constrain (MetaWindow *window,
resize_gravity,
orig,
new);
+ place_window_if_needed (window, &info);
while (!satisfied && priority <= PRIORITY_MAXIMUM) {
gboolean check_only = TRUE;
@@ -433,6 +436,116 @@ setup_constraint_info (ConstraintInfo *info,
}
static void
+place_window_if_needed(MetaWindow *window,
+ ConstraintInfo *info)
+{
+ gboolean did_placement;
+
+ /* Do placement if any, so we go ahead and apply position
+ * constraints in a move-only context. Don't place
+ * maximized/minimized/fullscreen windows until they are
+ * unmaximized, unminimized and unfullscreened.
+ */
+ did_placement = FALSE;
+ if (!window->placed &&
+ window->calc_placement &&
+ !(window->maximized_horizontally ||
+ window->maximized_vertically) &&
+ !window->minimized &&
+ !window->fullscreen)
+ {
+ MetaRectangle orig_rect;
+ MetaRectangle placed_rect;
+ MetaWorkspace *cur_workspace;
+ const MetaMonitorInfo *monitor_info;
+
+ meta_window_get_frame_rect (window, &placed_rect);
+
+ orig_rect = info->orig;
+
+ meta_window_place (window, orig_rect.x, orig_rect.y,
+ &placed_rect.x, &placed_rect.y);
+ did_placement = TRUE;
+
+ /* placing the window may have changed the monitor. Find the
+ * new monitor and update the ConstraintInfo
+ */
+ monitor_info =
+ meta_screen_get_monitor_for_rect (window->screen, &placed_rect);
+ info->entire_monitor = monitor_info->rect;
+ meta_window_get_work_area_for_monitor (window,
+ monitor_info->number,
+ &info->work_area_monitor);
+ cur_workspace = window->screen->active_workspace;
+ info->usable_monitor_region =
+ meta_workspace_get_onmonitor_region (cur_workspace,
+ monitor_info->number);
+
+ info->current.x = placed_rect.x;
+ info->current.y = placed_rect.y;
+
+ /* Since we just barely placed the window, there's no reason to
+ * consider any of the directions fixed.
+ */
+ info->fixed_directions = FIXED_DIRECTION_NONE;
+ }
+
+ if (window->placed || did_placement)
+ {
+ if (window->maximize_horizontally_after_placement ||
+ window->maximize_vertically_after_placement ||
+ window->fullscreen_after_placement)
+ {
+ /* define a sane saved_rect so that the user can unmaximize or
+ * make unfullscreen to something reasonable.
+ */
+ if (info->current.width >= info->work_area_monitor.width)
+ {
+ info->current.width = .75 * info->work_area_monitor.width;
+ info->current.x = info->work_area_monitor.x +
+ .125 * info->work_area_monitor.width;
+ }
+ if (info->current.height >= info->work_area_monitor.height)
+ {
+ info->current.height = .75 * info->work_area_monitor.height;
+ info->current.y = info->work_area_monitor.y +
+ .083 * info->work_area_monitor.height;
+ }
+
+ /* idle_move_resize() uses the unconstrained_rect, so make sure it
+ * uses the placed coordinates (bug #556696).
+ */
+ window->unconstrained_rect = info->current;
+
+ if (window->maximize_horizontally_after_placement ||
+ window->maximize_vertically_after_placement)
+ meta_window_maximize_internal (window,
+ (window->maximize_horizontally_after_placement ?
+ META_MAXIMIZE_HORIZONTAL : 0 ) |
+ (window->maximize_vertically_after_placement ?
+ META_MAXIMIZE_VERTICAL : 0), &info->current);
+
+ if (window->fullscreen_after_placement)
+ {
+ window->saved_rect = info->current;
+ window->fullscreen = TRUE;
+ window->fullscreen_after_placement = FALSE;
+
+ g_object_notify (G_OBJECT (window), "fullscreen");
+ }
+
+ window->maximize_horizontally_after_placement = FALSE;
+ window->maximize_vertically_after_placement = FALSE;
+ }
+ if (window->minimize_after_placement)
+ {
+ meta_window_minimize (window);
+ window->minimize_after_placement = FALSE;
+ }
+ }
+}
+
+static void
update_onscreen_requirements (MetaWindow *window,
ConstraintInfo *info)
{
diff --git a/src/core/window.c b/src/core/window.c
index 132479c..59efbba 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -3632,93 +3632,6 @@ meta_window_update_monitor (MetaWindow *window)
}
}
-static gboolean
-place_window_if_needed (MetaWindow *window,
- MetaRectangle *unconstrained_rect)
-{
- /* Do placement if any, so we go ahead and apply position
- * constraints in a move-only context. Don't place
- * maximized/minimized/fullscreen windows until they are
- * unmaximized, unminimized and unfullscreened.
- */
-
- if (!window->placed &&
- window->calc_placement &&
- !(window->maximized_horizontally ||
- window->maximized_vertically) &&
- !window->minimized &&
- !window->fullscreen)
- {
- meta_window_place (window,
- unconstrained_rect->x,
- unconstrained_rect->y,
- &unconstrained_rect->x,
- &unconstrained_rect->y);
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-
-static void
-apply_after_placement_rules (MetaWindow *window)
-{
- if (window->maximize_horizontally_after_placement ||
- window->maximize_vertically_after_placement ||
- window->fullscreen_after_placement)
- {
- const MetaMonitorInfo *monitor_info;
- MetaRectangle work_area_monitor;
-
- monitor_info = meta_screen_get_monitor_for_rect (window->screen, &window->unconstrained_rect);
- meta_window_get_work_area_for_monitor (window,
- monitor_info->number,
- &work_area_monitor);
-
- /* define a sane saved_rect so that the user can unmaximize or
- * make unfullscreen to something reasonable.
- */
- if (window->unconstrained_rect.width >= work_area_monitor.width)
- {
- window->saved_rect.width = .75 * work_area_monitor.width;
- window->saved_rect.x = work_area_monitor.x + .125 * work_area_monitor.width;
- }
- if (window->unconstrained_rect.height >= work_area_monitor.height)
- {
- window->saved_rect.height = .75 * work_area_monitor.height;
- window->saved_rect.y = work_area_monitor.y + .083 * work_area_monitor.height;
- }
-
- if (window->maximize_horizontally_after_placement ||
- window->maximize_vertically_after_placement)
- {
- meta_window_maximize_internal (window,
- (window->maximize_horizontally_after_placement ?
META_MAXIMIZE_HORIZONTAL : 0 ) |
- (window->maximize_vertically_after_placement ?
META_MAXIMIZE_VERTICAL : 0),
- &window->saved_rect);
-
- window->maximize_horizontally_after_placement = FALSE;
- window->maximize_vertically_after_placement = FALSE;
- }
-
- if (window->fullscreen_after_placement)
- {
- window->fullscreen = TRUE;
- window->fullscreen_after_placement = FALSE;
-
- g_object_notify (G_OBJECT (window), "fullscreen");
- }
- }
-
- if (window->minimize_after_placement)
- {
- meta_window_minimize (window);
- window->minimize_after_placement = FALSE;
- }
-}
-
void
meta_window_move_resize_internal (MetaWindow *window,
MetaMoveResizeFlags flags,
@@ -3756,6 +3669,8 @@ meta_window_move_resize_internal (MetaWindow *window,
*/
g_assert (flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION | META_IS_WAYLAND_RESIZE));
+ did_placement = !window->placed && window->calc_placement;
+
/* We don't need it in the idle queue anymore. */
meta_window_unqueue (window, META_QUEUE_MOVE_RESIZE);
@@ -3783,15 +3698,10 @@ meta_window_move_resize_internal (MetaWindow *window,
unconstrained_rect.height = window->rect.height;
}
- did_placement = place_window_if_needed (window, &unconstrained_rect);
-
/* Save the unconstrained rectangle to the position we should be at
* before constraints kick in. */
window->unconstrained_rect = unconstrained_rect;
- if (did_placement)
- apply_after_placement_rules (window);
-
constrained_rect = unconstrained_rect;
if (flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION))
{
@@ -3805,6 +3715,16 @@ meta_window_move_resize_internal (MetaWindow *window,
&constrained_rect);
}
+ /* If we did placement, then we need to save the position that the window
+ * was placed at to make sure that meta_window_move_resize_now places the
+ * window correctly.
+ */
+ if (did_placement)
+ {
+ window->unconstrained_rect.x = constrained_rect.x;
+ window->unconstrained_rect.y = constrained_rect.y;
+ }
+
/* Do the protocol-specific move/resize logic */
META_WINDOW_GET_CLASS (window)->move_resize_internal (window, gravity, unconstrained_rect,
constrained_rect, flags, &result);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]