OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 bool Window::IsVisible() const { | 181 bool Window::IsVisible() const { |
182 // Layer visibility can be inconsistent with window visibility, for example | 182 // Layer visibility can be inconsistent with window visibility, for example |
183 // when a Window is hidden, we want this function to return false immediately | 183 // when a Window is hidden, we want this function to return false immediately |
184 // after, even though the client may decide to animate the hide effect (and | 184 // after, even though the client may decide to animate the hide effect (and |
185 // so the layer will be visible for some time after Hide() is called). | 185 // so the layer will be visible for some time after Hide() is called). |
186 return visible_ && layer_ && layer_->IsDrawn(); | 186 return visible_ && layer_ && layer_->IsDrawn(); |
187 } | 187 } |
188 | 188 |
189 gfx::Rect Window::GetScreenBounds() const { | 189 gfx::Rect Window::GetScreenBounds() const { |
| 190 // TODO(beng): There may be a better way to handle this, and the existing code |
| 191 // is likely wrong anyway in a multi-monitor world, but this will |
| 192 // do for now. |
| 193 if (!GetRootWindow()) |
| 194 return bounds(); |
190 gfx::Point origin = bounds().origin(); | 195 gfx::Point origin = bounds().origin(); |
191 Window::ConvertPointToWindow(parent_, GetRootWindow(), &origin); | 196 Window::ConvertPointToWindow(parent_, GetRootWindow(), &origin); |
192 return gfx::Rect(origin, bounds().size()); | 197 return gfx::Rect(origin, bounds().size()); |
193 } | 198 } |
194 | 199 |
195 void Window::SetTransform(const ui::Transform& transform) { | 200 void Window::SetTransform(const ui::Transform& transform) { |
196 RootWindow* root_window = GetRootWindow(); | 201 RootWindow* root_window = GetRootWindow(); |
197 bool contained_mouse = IsVisible() && root_window && | 202 bool contained_mouse = IsVisible() && root_window && |
198 ContainsPointInRoot(root_window->last_mouse_location()); | 203 ContainsPointInRoot(root_window->last_mouse_location()); |
199 layer()->SetTransform(transform); | 204 layer()->SetTransform(transform); |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 if (id_ != -1) { | 794 if (id_ != -1) { |
790 char id_buf[10]; | 795 char id_buf[10]; |
791 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); | 796 base::snprintf(id_buf, sizeof(id_buf), " %d", id_); |
792 layer_name.append(id_buf); | 797 layer_name.append(id_buf); |
793 } | 798 } |
794 layer()->set_name(layer_name); | 799 layer()->set_name(layer_name); |
795 #endif | 800 #endif |
796 } | 801 } |
797 | 802 |
798 } // namespace aura | 803 } // namespace aura |
OLD | NEW |