OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/utility/partial_screenshot_controller.h" | 5 #include "ash/utility/partial_screenshot_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
10 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "ui/compositor/paint_recorder.h" | 14 #include "ui/compositor/paint_recorder.h" |
15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
16 #include "ui/events/event_handler.h" | 16 #include "ui/events/event_handler.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/screen.h" |
18 #include "ui/wm/core/cursor_manager.h" | 19 #include "ui/wm/core/cursor_manager.h" |
19 | 20 |
20 namespace ash { | 21 namespace ash { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // The size to increase the invalidated area in the layer to repaint. The area | 25 // The size to increase the invalidated area in the layer to repaint. The area |
25 // should be slightly bigger than the actual region because the region indicator | 26 // should be slightly bigger than the actual region because the region indicator |
26 // rectangles are drawn outside of the selected region. | 27 // rectangles are drawn outside of the selected region. |
27 const int kInvalidateRegionAdditionalSize = 3; | 28 const int kInvalidateRegionAdditionalSize = 3; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 138 |
138 void PartialScreenshotController::StartPartialScreenshotSession( | 139 void PartialScreenshotController::StartPartialScreenshotSession( |
139 ScreenshotDelegate* screenshot_delegate) { | 140 ScreenshotDelegate* screenshot_delegate) { |
140 // Already in a screenshot session. | 141 // Already in a screenshot session. |
141 if (screenshot_delegate_) { | 142 if (screenshot_delegate_) { |
142 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); | 143 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); |
143 return; | 144 return; |
144 } | 145 } |
145 | 146 |
146 screenshot_delegate_ = screenshot_delegate; | 147 screenshot_delegate_ = screenshot_delegate; |
147 Shell::GetScreen()->AddObserver(this); | 148 gfx::Screen::GetScreen()->AddObserver(this); |
148 for (aura::Window* root : Shell::GetAllRootWindows()) { | 149 for (aura::Window* root : Shell::GetAllRootWindows()) { |
149 layers_[root] = new PartialScreenshotLayer( | 150 layers_[root] = new PartialScreenshotLayer( |
150 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer()); | 151 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer()); |
151 } | 152 } |
152 | 153 |
153 cursor_setter_.reset(new ScopedCursorSetter( | 154 cursor_setter_.reset(new ScopedCursorSetter( |
154 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); | 155 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); |
155 | 156 |
156 EnableMouseWarp(false); | 157 EnableMouseWarp(false); |
157 } | 158 } |
(...skipping 20 matching lines...) Expand all Loading... |
178 if (!region.IsEmpty()) { | 179 if (!region.IsEmpty()) { |
179 screenshot_delegate_->HandleTakePartialScreenshot( | 180 screenshot_delegate_->HandleTakePartialScreenshot( |
180 root_window_, gfx::IntersectRects(root_window_->bounds(), region)); | 181 root_window_, gfx::IntersectRects(root_window_->bounds(), region)); |
181 } | 182 } |
182 Cancel(); | 183 Cancel(); |
183 } | 184 } |
184 | 185 |
185 void PartialScreenshotController::Cancel() { | 186 void PartialScreenshotController::Cancel() { |
186 root_window_ = nullptr; | 187 root_window_ = nullptr; |
187 screenshot_delegate_ = nullptr; | 188 screenshot_delegate_ = nullptr; |
188 Shell::GetScreen()->RemoveObserver(this); | 189 gfx::Screen::GetScreen()->RemoveObserver(this); |
189 STLDeleteValues(&layers_); | 190 STLDeleteValues(&layers_); |
190 cursor_setter_.reset(); | 191 cursor_setter_.reset(); |
191 EnableMouseWarp(true); | 192 EnableMouseWarp(true); |
192 } | 193 } |
193 | 194 |
194 void PartialScreenshotController::Update(const ui::LocatedEvent& event) { | 195 void PartialScreenshotController::Update(const ui::LocatedEvent& event) { |
195 // Update may happen without MaybeStart() if the partial screenshot session | 196 // Update may happen without MaybeStart() if the partial screenshot session |
196 // starts when dragging. | 197 // starts when dragging. |
197 if (!root_window_) | 198 if (!root_window_) |
198 MaybeStart(event); | 199 MaybeStart(event); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return; | 271 return; |
271 Cancel(); | 272 Cancel(); |
272 } | 273 } |
273 | 274 |
274 void PartialScreenshotController::OnDisplayMetricsChanged( | 275 void PartialScreenshotController::OnDisplayMetricsChanged( |
275 const gfx::Display& display, | 276 const gfx::Display& display, |
276 uint32_t changed_metrics) { | 277 uint32_t changed_metrics) { |
277 } | 278 } |
278 | 279 |
279 } // namespace ash | 280 } // namespace ash |
OLD | NEW |