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

Side by Side Diff: ui/aura/window.cc

Issue 8894018: Move the concept of Activation to the Shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 UpdateLayerName(name_); 96 UpdateLayerName(name_);
97 } 97 }
98 98
99 void Window::Show() { 99 void Window::Show() {
100 SetVisible(true); 100 SetVisible(true);
101 } 101 }
102 102
103 void Window::Hide() { 103 void Window::Hide() {
104 SetVisible(false); 104 SetVisible(false);
105 ReleaseCapture(); 105 ReleaseCapture();
106 if (RootWindow::GetInstance()->active_window() == this ||
107 !RootWindow::GetInstance()->active_window()) {
108 RootWindow::GetInstance()->ActivateTopmostWindow();
109 }
110 } 106 }
111 107
112 bool Window::IsVisible() const { 108 bool Window::IsVisible() const {
113 return layer_->IsDrawn(); 109 return layer_->IsDrawn();
114 } 110 }
115 111
116 gfx::Rect Window::GetScreenBounds() const { 112 gfx::Rect Window::GetScreenBounds() const {
117 gfx::Point origin = bounds().origin(); 113 gfx::Point origin = bounds().origin();
118 Window::ConvertPointToWindow(parent_, 114 Window::ConvertPointToWindow(parent_,
119 aura::RootWindow::GetInstance(), 115 aura::RootWindow::GetInstance(),
120 &origin); 116 &origin);
121 return gfx::Rect(origin, bounds().size()); 117 return gfx::Rect(origin, bounds().size());
122 } 118 }
123 119
124 void Window::Activate() {
125 // If we support minimization need to ensure this restores the window first.
126 aura::RootWindow::GetInstance()->SetActiveWindow(this, this);
127 }
128
129 void Window::Deactivate() {
130 aura::RootWindow::GetInstance()->Deactivate(this);
131 }
132
133 bool Window::IsActive() const {
134 return aura::RootWindow::GetInstance()->active_window() == this;
135 }
136
137 void Window::SetTransform(const ui::Transform& transform) { 120 void Window::SetTransform(const ui::Transform& transform) {
138 layer()->SetTransform(transform); 121 layer()->SetTransform(transform);
139 } 122 }
140 123
141 void Window::SetLayoutManager(LayoutManager* layout_manager) { 124 void Window::SetLayoutManager(LayoutManager* layout_manager) {
142 layout_manager_.reset(layout_manager); 125 layout_manager_.reset(layout_manager);
143 } 126 }
144 127
145 void Window::SetBounds(const gfx::Rect& new_bounds) { 128 void Window::SetBounds(const gfx::Rect& new_bounds) {
146 if (parent_ && parent_->layout_manager()) 129 if (parent_ && parent_->layout_manager())
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 Window* transient_child = *i; 195 Window* transient_child = *i;
213 if (transient_child->parent_ == this) { 196 if (transient_child->parent_ == this) {
214 StackChildAbove(transient_child, last_transient); 197 StackChildAbove(transient_child, last_transient);
215 last_transient = transient_child; 198 last_transient = transient_child;
216 } 199 }
217 } 200 }
218 201
219 child->OnStackingChanged(); 202 child->OnStackingChanged();
220 } 203 }
221 204
222 bool Window::CanActivate() const {
223 return IsVisible() && (!delegate_ || delegate_->ShouldActivate(NULL));
224 }
225
226 void Window::AddChild(Window* child) { 205 void Window::AddChild(Window* child) {
227 DCHECK(std::find(children_.begin(), children_.end(), child) == 206 DCHECK(std::find(children_.begin(), children_.end(), child) ==
228 children_.end()); 207 children_.end());
229 if (child->parent()) 208 if (child->parent())
230 child->parent()->RemoveChild(child); 209 child->parent()->RemoveChild(child);
231 child->parent_ = this; 210 child->parent_ = this;
232 211
233 layer_->Add(child->layer_.get()); 212 layer_->Add(child->layer_.get());
234 213
235 children_.push_back(child); 214 children_.push_back(child);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (id_ != -1) { 544 if (id_ != -1) {
566 char id_buf[10]; 545 char id_buf[10];
567 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); 546 base::snprintf(id_buf, sizeof(id_buf), " %d", id_);
568 layer_name.append(id_buf); 547 layer_name.append(id_buf);
569 } 548 }
570 layer()->set_name(layer_name); 549 layer()->set_name(layer_name);
571 #endif 550 #endif
572 } 551 }
573 552
574 } // namespace aura 553 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698