Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1380)

Unified Diff: ash/wm/maximize_mode/maximize_mode_window_state.cc

Issue 249723002: Fixing problem where applications are not getting centered when created after maximize mode starts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_mode/maximize_mode_window_state.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc
index e823455d48e15688f8759c3194c0497bf2cd57b9..77a58fde1a9687a1b899ca91154ced426e15294f 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc
@@ -45,6 +45,25 @@ gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) {
return size;
}
+// Returns the centered bounds of the given bounds in the work area.
+gfx::Rect GetCenteredBounds(const gfx::Rect& bounds_in_parent,
+ wm::WindowState* state_object) {
+ gfx::Rect bounds = bounds_in_parent;
+ gfx::Rect work_area_in_parent =
+ ScreenUtil::GetDisplayWorkAreaBoundsInParent(state_object->window());
+ wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent, &bounds);
+
+ // Center the window over the work area.
+ int x = (work_area_in_parent.width() - bounds.width()) / 2 +
+ work_area_in_parent.x();
+ int y = (work_area_in_parent.height() - bounds.height()) / 2 +
+ work_area_in_parent.y();
oshima 2014/04/24 21:01:25 I think work_area_in_parent.ClampToCenteredSize(b
Mr4D (OOO till 08-26) 2014/04/24 21:42:20 I tried this yesterday. And it did not work. Appar
+
+ bounds.set_origin(gfx::Point(x, y));
+
+ return bounds;
+}
+
// Returns the maximized and centered bounds of a window.
gfx::Rect GetMaximizedAndCenteredBounds(wm::WindowState* state_object) {
gfx::Rect bounds_in_parent;
@@ -60,21 +79,7 @@ gfx::Rect GetMaximizedAndCenteredBounds(wm::WindowState* state_object) {
else
bounds_in_parent = state_object->window()->bounds();
}
- gfx::Rect work_area_in_parent =
- ScreenUtil::GetDisplayWorkAreaBoundsInParent(state_object->window());
-
- wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent,
- &bounds_in_parent);
-
- // Center the window over the work area.
- int x = (work_area_in_parent.width() - bounds_in_parent.width()) / 2 +
- work_area_in_parent.x();
- int y = (work_area_in_parent.height() - bounds_in_parent.height()) / 2 +
- work_area_in_parent.y();
-
- bounds_in_parent.set_origin(gfx::Point(x, y));
-
- return bounds_in_parent;
+ return GetCenteredBounds(bounds_in_parent, state_object);
}
} // namespace
@@ -148,11 +153,13 @@ void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
// requested bounds and center it to a fully visible area on the screen.
gfx::Rect bounds_in_parent =
(static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds();
- bounds_in_parent.ClampToCenteredSize(
- ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- window_state->window()).size());
- if (bounds_in_parent != window_state->window()->bounds())
- window_state->SetBoundsDirectAnimated(bounds_in_parent);
+ bounds_in_parent = GetCenteredBounds(bounds_in_parent, window_state);
+ if (bounds_in_parent != window_state->window()->bounds()) {
+ if (window_state->window()->IsVisible())
oshima 2014/04/24 21:01:25 how this can be not visible (in non minimized mode
Mr4D (OOO till 08-26) 2014/04/24 21:42:20 Multi user mode for example. Before the window get
oshima 2014/04/24 21:57:52 I see. I don't think we do this in normal mode, bu
+ window_state->SetBoundsDirectAnimated(bounds_in_parent);
+ else
+ window_state->SetBoundsDirect(bounds_in_parent);
+ }
}
break;
case wm::WM_EVENT_ADDED_TO_WORKSPACE:
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698