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

Unified Diff: ash/wm/window_util.cc

Issue 1890713002: Adds WmWindow and converts WindowState to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge again 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/window_util.h ('k') | ash/wm/window_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_util.cc
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 4a2c8b8f14c743e7d6d001a6f8a1e9d91e578321..7a29d24aba4b9043279ab237d820e6e3d5819deb 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -10,9 +10,13 @@
#include "ash/screen_util.h"
#include "ash/shell.h"
#include "ash/snap_to_pixel_layout_manager.h"
+#include "ash/wm/aura/wm_window_aura.h"
#include "ash/wm/common/wm_event.h"
+#include "ash/wm/common/wm_screen_util.h"
+#include "ash/wm/common/wm_window.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state.h"
+#include "ash/wm/window_state_aura.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
@@ -33,18 +37,20 @@ namespace wm {
namespace {
// Returns the default width of a snapped window.
-int GetDefaultSnappedWindowWidth(aura::Window* window) {
+int GetDefaultSnappedWindowWidth(wm::WmWindow* window) {
const float kSnappedWidthWorkspaceRatio = 0.5f;
- int work_area_width =
- ScreenUtil::GetDisplayWorkAreaBoundsInParent(window).width();
- int min_width = window->delegate() ?
- window->delegate()->GetMinimumSize().width() : 0;
+ 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));
}
+int GetDefaultSnappedWindowWidth(aura::Window* window) {
+ return GetDefaultSnappedWindowWidth(WmWindowAura::Get(window));
+}
+
} // namespace
// TODO(beng): replace many of these functions with the corewm versions.
@@ -86,6 +92,20 @@ void CenterWindow(aura::Window* window) {
wm::GetWindowState(window)->OnWMEvent(&event);
}
+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());
+}
+
gfx::Rect GetDefaultLeftSnappedWindowBoundsInParent(aura::Window* window) {
gfx::Rect work_area_in_parent(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
window));
« no previous file with comments | « ash/wm/window_util.h ('k') | ash/wm/window_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698