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

Unified Diff: ash/wm/workspace/workspace_event_handler.cc

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
Index: ash/wm/workspace/workspace_event_handler.cc
diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc
index b46d3deff8357958da7b70cc2fe9afd16faaf4ab..b737962be701c88e2cedb096201da69e7d7cd543 100644
--- a/ash/wm/workspace/workspace_event_handler.cc
+++ b/ash/wm/workspace/workspace_event_handler.cc
@@ -9,7 +9,7 @@
#include "ash/shell_delegate.h"
#include "ash/touch/touch_uma.h"
#include "ash/wm/coordinate_conversion.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "ui/aura/client/aura_constants.h"
@@ -24,36 +24,29 @@
namespace ash {
namespace {
-void SingleAxisMaximize(aura::Window* window,
+void SingleAxisMaximize(wm::WindowState* window_state,
const gfx::Rect& maximize_rect_in_screen) {
- gfx::Rect bounds_in_screen =
- ScreenAsh::ConvertRectToScreen(window->parent(), window->bounds());
- SetRestoreBoundsInScreen(window, bounds_in_screen);
- gfx::Rect bounds_in_parent =
- ScreenAsh::ConvertRectFromScreen(window->parent(),
- maximize_rect_in_screen);
- window->SetBounds(bounds_in_parent);
+ window_state->SaveCurrentBoundsForRestore();
+ window_state->SetBoundsInScreen(maximize_rect_in_screen);
}
-void SingleAxisUnmaximize(aura::Window* window,
+void SingleAxisUnmaximize(wm::WindowState* window_state,
const gfx::Rect& restore_bounds_in_screen) {
- gfx::Rect restore_bounds = ScreenAsh::ConvertRectFromScreen(
- window->parent(), restore_bounds_in_screen);
- window->SetBounds(restore_bounds);
- ClearRestoreBounds(window);
+ window_state->SetBoundsInScreen(restore_bounds_in_screen);
+ window_state->ClearRestoreBounds();
}
-void ToggleMaximizedState(aura::Window* window) {
- if (GetRestoreBoundsInScreen(window)) {
- if (window->GetProperty(aura::client::kShowStateKey) ==
- ui::SHOW_STATE_NORMAL) {
- window->SetBounds(GetRestoreBoundsInParent(window));
- ClearRestoreBounds(window);
+void ToggleMaximizedState(wm::WindowState* window_state) {
+ if (window_state->HasRestoreBounds()) {
+ if (window_state->GetShowState() == ui::SHOW_STATE_NORMAL) {
+ window_state->window()->SetBounds(
+ window_state->GetRestoreBoundsInParent());
+ window_state->ClearRestoreBounds();
} else {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ window_state->Normalize();
}
- } else if (wm::CanMaximizeWindow(window)) {
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ } else if (window_state->CanMaximize()) {
+ window_state->Maximize();
}
}
@@ -93,7 +86,7 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
ToplevelWindowEventHandler::OnMouseEvent(event);
return;
}
-
+ wm::WindowState* target_state = wm::GetWindowState(target);
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
event->IsOnlyLeftMouseButton() &&
target->delegate()->GetNonClientComponent(event->location()) ==
@@ -103,13 +96,13 @@ void WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) {
destroyed_ = &destroyed;
ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK);
- ToggleMaximizedState(target);
+ ToggleMaximizedState(target_state);
if (destroyed)
return;
destroyed_ = NULL;
}
multi_window_resize_controller_.Hide();
- HandleVerticalResizeDoubleClick(target, event);
+ HandleVerticalResizeDoubleClick(target_state, event);
break;
}
default:
@@ -130,7 +123,8 @@ void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
// TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP is counted once.
TouchUMA::GetInstance()->RecordGestureAction(
TouchUMA::GESTURE_MAXIMIZE_DOUBLETAP);
- ToggleMaximizedState(target); // |this| may be destroyed from here.
+ // |this| may be destroyed from here.
+ ToggleMaximizedState(wm::GetWindowState(target));
event->StopPropagation();
return;
} else {
@@ -143,50 +137,47 @@ void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) {
}
void WorkspaceEventHandler::HandleVerticalResizeDoubleClick(
- aura::Window* target,
+ wm::WindowState* target,
James Cook 2013/09/18 20:44:17 Are you sure you want to change target to a Window
oshima 2013/09/19 01:52:01 how does it look to you now?
James Cook 2013/09/19 03:49:53 Better, thanks.
ui::MouseEvent* event) {
- gfx::Rect max_size(target->delegate()->GetMaximumSize());
- if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
- !wm::IsWindowMaximized(target)) {
+ gfx::Rect max_size(target->window()->delegate()->GetMaximumSize());
+ if (event->flags() & ui::EF_IS_DOUBLE_CLICK && !target->IsMaximized()) {
int component =
- target->delegate()->GetNonClientComponent(event->location());
- gfx::Rect work_area =
- Shell::GetScreen()->GetDisplayNearestWindow(target).work_area();
- const gfx::Rect* restore_bounds =
- GetRestoreBoundsInScreen(target);
+ target->window()->delegate()->GetNonClientComponent(event->location());
+ gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
+ target->window()).work_area();
if (component == HTBOTTOM || component == HTTOP) {
// Don't maximize vertically if the window has a max height defined.
if (max_size.height() != 0)
return;
- if (restore_bounds &&
- (target->bounds().height() == work_area.height() &&
- target->bounds().y() == work_area.y())) {
- SingleAxisUnmaximize(target, *restore_bounds);
+ if (target->HasRestoreBounds() &&
+ (target->window()->bounds().height() == work_area.height() &&
+ target->window()->bounds().y() == work_area.y())) {
+ SingleAxisUnmaximize(target, target->GetRestoreBoundsInScreen());
} else {
- gfx::Point origin = target->bounds().origin();
- wm::ConvertPointToScreen(target->parent(), &origin);
+ gfx::Point origin = target->window()->bounds().origin();
+ wm::ConvertPointToScreen(target->window()->parent(), &origin);
SingleAxisMaximize(target,
gfx::Rect(origin.x(),
work_area.y(),
- target->bounds().width(),
+ target->window()->bounds().width(),
work_area.height()));
}
} else if (component == HTLEFT || component == HTRIGHT) {
// Don't maximize horizontally if the window has a max width defined.
if (max_size.width() != 0)
return;
- if (restore_bounds &&
- (target->bounds().width() == work_area.width() &&
- target->bounds().x() == work_area.x())) {
- SingleAxisUnmaximize(target, *restore_bounds);
+ if (target->HasRestoreBounds() &&
+ (target->window()->bounds().width() == work_area.width() &&
+ target->window()->bounds().x() == work_area.x())) {
+ SingleAxisUnmaximize(target, target->GetRestoreBoundsInScreen());
} else {
- gfx::Point origin = target->bounds().origin();
- wm::ConvertPointToScreen(target->parent(), &origin);
+ gfx::Point origin = target->window()->bounds().origin();
+ wm::ConvertPointToScreen(target->window()->parent(), &origin);
SingleAxisMaximize(target,
gfx::Rect(work_area.x(),
origin.y(),
work_area.width(),
- target->bounds().height()));
+ target->window()->bounds().height()));
}
}
}

Powered by Google App Engine
This is Rietveld 408576698