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

Unified Diff: ash/wm/common/window_positioning_utils.cc

Issue 1901773002: Removes most of aura dependencies from DefaultState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wm_window_positioner
Patch Set: nit and merge Created 4 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/common/window_positioning_utils.h ('k') | ash/wm/common/window_state_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/common/window_positioning_utils.cc
diff --git a/ash/wm/common/window_positioning_utils.cc b/ash/wm/common/window_positioning_utils.cc
index 7ba629babc2eadcc9004da5bf1fd6c96bde662ad..a1105ea4df1dc0db54dd6c1c775d783ebe6c6fd1 100644
--- a/ash/wm/common/window_positioning_utils.cc
+++ b/ash/wm/common/window_positioning_utils.cc
@@ -6,12 +6,29 @@
#include <algorithm>
+#include "ash/wm/common/wm_screen_util.h"
+#include "ash/wm/common/wm_window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
namespace ash {
namespace wm {
+namespace {
+
+// Returns the default width of a snapped window.
+int GetDefaultSnappedWindowWidth(WmWindow* window) {
+ const float kSnappedWidthWorkspaceRatio = 0.5f;
+
+ int work_area_width = GetDisplayWorkAreaBoundsInParent(window).width();
+ int min_width = window->GetMinimumSize().width();
+ int ideal_width =
+ static_cast<int>(work_area_width * kSnappedWidthWorkspaceRatio);
+ return std::min(work_area_width, std::max(ideal_width, min_width));
+}
+
+} // namespace
+
void AdjustBoundsSmallerThan(const gfx::Size& max_size, gfx::Rect* bounds) {
bounds->set_width(std::min(bounds->width(), max_size.width()));
bounds->set_height(std::min(bounds->height(), max_size.height()));
@@ -46,5 +63,19 @@ void AdjustBoundsToEnsureMinimumWindowVisibility(const gfx::Rect& visible_area,
kMinimumOnScreenArea, bounds);
}
+gfx::Rect GetDefaultLeftSnappedWindowBoundsInParent(wm::WmWindow* window) {
+ gfx::Rect work_area_in_parent(GetDisplayWorkAreaBoundsInParent(window));
+ return gfx::Rect(work_area_in_parent.x(), work_area_in_parent.y(),
+ GetDefaultSnappedWindowWidth(window),
+ work_area_in_parent.height());
+}
+
+gfx::Rect GetDefaultRightSnappedWindowBoundsInParent(wm::WmWindow* window) {
+ gfx::Rect work_area_in_parent(GetDisplayWorkAreaBoundsInParent(window));
+ int width = GetDefaultSnappedWindowWidth(window);
+ return gfx::Rect(work_area_in_parent.right() - width, work_area_in_parent.y(),
+ width, work_area_in_parent.height());
+}
+
} // namespace wm
} // namespace ash
« no previous file with comments | « ash/wm/common/window_positioning_utils.h ('k') | ash/wm/common/window_state_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698