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

Unified Diff: athena/wm/window_overview_mode.cc

Issue 416243004: Enable touch text selection on Athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed HomeCard issue Created 6 years, 5 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 | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/wm/window_overview_mode.cc
diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc
index b37339e3cf7cca7b76aad83cc3e4ae66a5508c24..b1dabcf954e47be61af13a79417ac590354434eb 100644
--- a/athena/wm/window_overview_mode.cc
+++ b/athena/wm/window_overview_mode.cc
@@ -45,6 +45,10 @@ namespace athena {
namespace {
+bool ShouldShowWindowInOverviewMode(aura::Window* window) {
+ return window->type() == ui::wm::WINDOW_TYPE_NORMAL;
+}
+
// Sets the progress-state for the window in the overview mode.
void SetWindowProgress(aura::Window* window, float progress) {
WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
@@ -110,10 +114,13 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
virtual ~WindowOverviewModeImpl() {
container_->set_target_handler(container_->delegate());
- aura::Window::Windows windows = container_->children();
- if (windows.empty())
- return;
- std::for_each(windows.begin(), windows.end(), &RestoreWindowState);
+ const aura::Window::Windows& windows = container_->children();
+ for (aura::Window::Windows::const_iterator iter = windows.begin();
+ iter != windows.end();
+ ++iter) {
+ if ((*iter)->GetProperty(kWindowOverviewState))
+ RestoreWindowState(*iter);
+ }
}
private:
@@ -121,8 +128,10 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
// positions. The transforms are set in the |kWindowOverviewState| property of
// the windows.
void ComputeTerminalStatesForAllWindows() {
- aura::Window::Windows windows = container_->children();
- size_t window_count = windows.size();
+ const aura::Window::Windows& windows = container_->children();
+ size_t window_count = std::count_if(windows.begin(), windows.end(),
+ ShouldShowWindowInOverviewMode);
+
size_t index = 0;
const gfx::Size container_size = container_->bounds().size();
@@ -131,10 +140,12 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
const float kMinScale = 0.6f;
const float kMaxScale = 0.95f;
- for (aura::Window::Windows::reverse_iterator iter = windows.rbegin();
+ for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
iter != windows.rend();
- ++iter, ++index) {
+ ++iter) {
aura::Window* window = (*iter);
+ if (!ShouldShowWindowInOverviewMode(window))
+ continue;
gfx::Transform top_transform;
int top = (window_count - index - 1) * kGapBetweenWindowsTop;
@@ -154,20 +165,27 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
state->progress = 0.f;
state->shadow = CreateShadowForWindow(window);
window->SetProperty(kWindowOverviewState, state);
+
+ index++;
}
}
// Sets the initial position for the windows for the overview mode.
void SetInitialWindowStates() {
- aura::Window::Windows windows = container_->children();
- size_t window_count = windows.size();
// The initial overview state of the topmost three windows.
const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f };
- for (size_t i = 0; i < window_count; ++i) {
+ size_t index = 0;
+ const aura::Window::Windows& windows = container_->children();
+ for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
+ iter != windows.rend();
+ ++iter) {
+ aura::Window* window = (*iter);
+ if (!window->GetProperty(kWindowOverviewState))
+ continue;
+
float progress = 0.f;
- aura::Window* window = windows[window_count - 1 - i];
- if (i < arraysize(kInitialProgress))
- progress = kInitialProgress[i];
+ if (index < arraysize(kInitialProgress))
+ progress = kInitialProgress[index];
scoped_refptr<ui::LayerAnimator> animator =
window->layer()->GetAnimator();
@@ -188,6 +206,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250));
SetWindowProgress(window, progress);
}
+ index++;
}
}
@@ -222,16 +241,18 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
// scrolling up; and positive when scrolling down.
void DoScroll(float delta_y) {
const float kEpsilon = 1e-3f;
- aura::Window::Windows windows = container_->children();
float delta_y_p = std::abs(delta_y) / GetScrollableHeight();
+ const aura::Window::Windows& windows = container_->children();
if (delta_y < 0) {
// Scroll up. Start with the top-most (i.e. behind-most in terms of
// z-index) window, and try to scroll them up.
- for (aura::Window::Windows::iterator iter = windows.begin();
+ for (aura::Window::Windows::const_iterator iter = windows.begin();
delta_y_p > kEpsilon && iter != windows.end();
++iter) {
aura::Window* window = (*iter);
WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
+ if (!state)
+ continue;
if (state->progress > kEpsilon) {
// It is possible to scroll |window| up. Scroll it up, and update
// |delta_y_p| for the next window.
@@ -243,11 +264,14 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
} else {
// Scroll down. Start with the bottom-most (i.e. front-most in terms of
// z-index) window, and try to scroll them down.
- for (aura::Window::Windows::reverse_iterator iter = windows.rbegin();
+ for (aura::Window::Windows::const_reverse_iterator iter =
+ windows.rbegin();
delta_y_p > kEpsilon && iter != windows.rend();
++iter) {
aura::Window* window = (*iter);
WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
+ if (!state)
+ continue;
if (1.f - state->progress > kEpsilon) {
// It is possible to scroll |window| down. Scroll it down, and update
// |delta_y_p| for the next window.
« no previous file with comments | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698