| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ui/aura/client/window_stacking_client.h" | 27 #include "ui/aura/client/window_stacking_client.h" |
| 28 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 29 #include "ui/aura/layout_manager.h" | 29 #include "ui/aura/layout_manager.h" |
| 30 #include "ui/aura/window_delegate.h" | 30 #include "ui/aura/window_delegate.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/aura/window_observer.h" | 32 #include "ui/aura/window_observer.h" |
| 33 #include "ui/aura/window_tracker.h" | 33 #include "ui/aura/window_tracker.h" |
| 34 #include "ui/aura/window_tree_host.h" | 34 #include "ui/aura/window_tree_host.h" |
| 35 #include "ui/compositor/compositor.h" | 35 #include "ui/compositor/compositor.h" |
| 36 #include "ui/compositor/layer.h" | 36 #include "ui/compositor/layer.h" |
| 37 #include "ui/display/display.h" |
| 38 #include "ui/display/screen.h" |
| 37 #include "ui/events/event_target_iterator.h" | 39 #include "ui/events/event_target_iterator.h" |
| 38 #include "ui/gfx/canvas.h" | 40 #include "ui/gfx/canvas.h" |
| 39 #include "ui/gfx/path.h" | 41 #include "ui/gfx/path.h" |
| 40 #include "ui/gfx/scoped_canvas.h" | 42 #include "ui/gfx/scoped_canvas.h" |
| 41 #include "ui/gfx/screen.h" | |
| 42 | 43 |
| 43 namespace aura { | 44 namespace aura { |
| 44 | 45 |
| 45 class ScopedCursorHider { | 46 class ScopedCursorHider { |
| 46 public: | 47 public: |
| 47 explicit ScopedCursorHider(Window* window) | 48 explicit ScopedCursorHider(Window* window) |
| 48 : window_(window), | 49 : window_(window), |
| 49 hid_cursor_(false) { | 50 hid_cursor_(false) { |
| 50 if (!window_->IsRootWindow()) | 51 if (!window_->IsRootWindow()) |
| 51 return; | 52 return; |
| 52 const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains( | 53 const bool cursor_is_in_bounds = window_->GetBoundsInScreen().Contains( |
| 53 Env::GetInstance()->last_mouse_location()); | 54 Env::GetInstance()->last_mouse_location()); |
| 54 client::CursorClient* cursor_client = client::GetCursorClient(window_); | 55 client::CursorClient* cursor_client = client::GetCursorClient(window_); |
| 55 if (cursor_is_in_bounds && cursor_client && | 56 if (cursor_is_in_bounds && cursor_client && |
| 56 cursor_client->IsCursorVisible()) { | 57 cursor_client->IsCursorVisible()) { |
| 57 cursor_client->HideCursor(); | 58 cursor_client->HideCursor(); |
| 58 hid_cursor_ = true; | 59 hid_cursor_ = true; |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 ~ScopedCursorHider() { | 62 ~ScopedCursorHider() { |
| 62 if (!window_->IsRootWindow()) | 63 if (!window_->IsRootWindow()) |
| 63 return; | 64 return; |
| 64 | 65 |
| 65 // Update the device scale factor of the cursor client only when the last | 66 // Update the device scale factor of the cursor client only when the last |
| 66 // mouse location is on this root window. | 67 // mouse location is on this root window. |
| 67 if (hid_cursor_) { | 68 if (hid_cursor_) { |
| 68 client::CursorClient* cursor_client = client::GetCursorClient(window_); | 69 client::CursorClient* cursor_client = client::GetCursorClient(window_); |
| 69 if (cursor_client) { | 70 if (cursor_client) { |
| 70 const gfx::Display& display = | 71 const display::Display& display = |
| 71 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 72 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
| 72 cursor_client->SetDisplay(display); | 73 cursor_client->SetDisplay(display); |
| 73 cursor_client->ShowCursor(); | 74 cursor_client->ShowCursor(); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 Window* window_; | 80 Window* window_; |
| 80 bool hid_cursor_; | 81 bool hid_cursor_; |
| 81 | 82 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 const gfx::Size& min_size = delegate_->GetMinimumSize(); | 315 const gfx::Size& min_size = delegate_->GetMinimumSize(); |
| 315 final_bounds.set_width(std::max(min_size.width(), final_bounds.width())); | 316 final_bounds.set_width(std::max(min_size.width(), final_bounds.width())); |
| 316 final_bounds.set_height(std::max(min_size.height(), | 317 final_bounds.set_height(std::max(min_size.height(), |
| 317 final_bounds.height())); | 318 final_bounds.height())); |
| 318 } | 319 } |
| 319 SetBoundsInternal(final_bounds); | 320 SetBoundsInternal(final_bounds); |
| 320 } | 321 } |
| 321 } | 322 } |
| 322 | 323 |
| 323 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, | 324 void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen, |
| 324 const gfx::Display& dst_display) { | 325 const display::Display& dst_display) { |
| 325 Window* root = GetRootWindow(); | 326 Window* root = GetRootWindow(); |
| 326 if (root) { | 327 if (root) { |
| 327 aura::client::ScreenPositionClient* screen_position_client = | 328 aura::client::ScreenPositionClient* screen_position_client = |
| 328 aura::client::GetScreenPositionClient(root); | 329 aura::client::GetScreenPositionClient(root); |
| 329 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); | 330 screen_position_client->SetBounds(this, new_bounds_in_screen, dst_display); |
| 330 return; | 331 return; |
| 331 } | 332 } |
| 332 SetBounds(new_bounds_in_screen); | 333 SetBounds(new_bounds_in_screen); |
| 333 } | 334 } |
| 334 | 335 |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 layer_name = "Unnamed Window"; | 1116 layer_name = "Unnamed Window"; |
| 1116 | 1117 |
| 1117 if (id_ != -1) | 1118 if (id_ != -1) |
| 1118 layer_name += " " + base::IntToString(id_); | 1119 layer_name += " " + base::IntToString(id_); |
| 1119 | 1120 |
| 1120 layer()->set_name(layer_name); | 1121 layer()->set_name(layer_name); |
| 1121 #endif | 1122 #endif |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 } // namespace aura | 1125 } // namespace aura |
| OLD | NEW |