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

Side by Side Diff: ash/utility/screenshot_controller.cc

Issue 1936753002: Rename gfx::Display/Screen to display::Display/Screen in ash/utility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/screenshot_controller.h" 5 #include "ash/utility/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 "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "ui/aura/client/capture_client.h" 15 #include "ui/aura/client/capture_client.h"
16 #include "ui/aura/client/screen_position_client.h" 16 #include "ui/aura/client/screen_position_client.h"
17 #include "ui/aura/window_targeter.h" 17 #include "ui/aura/window_targeter.h"
18 #include "ui/compositor/paint_recorder.h" 18 #include "ui/compositor/paint_recorder.h"
19 #include "ui/display/screen.h"
19 #include "ui/events/event.h" 20 #include "ui/events/event.h"
20 #include "ui/events/event_handler.h" 21 #include "ui/events/event_handler.h"
21 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
22 #include "ui/gfx/screen.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 #include "ui/wm/core/cursor_manager.h" 24 #include "ui/wm/core/cursor_manager.h"
25 25
26 namespace ash { 26 namespace ash {
27 27
28 namespace { 28 namespace {
29 29
30 // The size to increase the invalidated area in the layer to repaint. The area 30 // The size to increase the invalidated area in the layer to repaint. The area
31 // should be slightly bigger than the actual region because the region indicator 31 // should be slightly bigger than the actual region because the region indicator
32 // rectangles are drawn outside of the selected region. 32 // rectangles are drawn outside of the selected region.
(...skipping 13 matching lines...) Expand all
46 46
47 aura::Window* FindWindowForEvent(ui::LocatedEvent* event) { 47 aura::Window* FindWindowForEvent(ui::LocatedEvent* event) {
48 aura::Window* target = static_cast<aura::Window*>(event->target()); 48 aura::Window* target = static_cast<aura::Window*>(event->target());
49 aura::Window* target_root = target->GetRootWindow(); 49 aura::Window* target_root = target->GetRootWindow();
50 50
51 aura::client::ScreenPositionClient* position_client = 51 aura::client::ScreenPositionClient* position_client =
52 aura::client::GetScreenPositionClient(target_root); 52 aura::client::GetScreenPositionClient(target_root);
53 gfx::Point location = event->location(); 53 gfx::Point location = event->location();
54 position_client->ConvertPointToScreen(target, &location); 54 position_client->ConvertPointToScreen(target, &location);
55 55
56 gfx::Display display = 56 display::Display display =
57 gfx::Screen::GetScreen()->GetDisplayNearestPoint(location); 57 display::Screen::GetScreen()->GetDisplayNearestPoint(location);
58 58
59 aura::Window* root_window = Shell::GetInstance() 59 aura::Window* root_window = Shell::GetInstance()
60 ->window_tree_host_manager() 60 ->window_tree_host_manager()
61 ->GetRootWindowForDisplayId(display.id()); 61 ->GetRootWindowForDisplayId(display.id());
62 62
63 position_client->ConvertPointFromScreen(root_window, &location); 63 position_client->ConvertPointFromScreen(root_window, &location);
64 64
65 gfx::Point target_location = event->location(); 65 gfx::Point target_location = event->location();
66 event->set_location(location); 66 event->set_location(location);
67 67
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 192
193 void ScreenshotController::StartWindowScreenshotSession( 193 void ScreenshotController::StartWindowScreenshotSession(
194 ScreenshotDelegate* screenshot_delegate) { 194 ScreenshotDelegate* screenshot_delegate) {
195 if (screenshot_delegate_) { 195 if (screenshot_delegate_) {
196 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); 196 DCHECK_EQ(screenshot_delegate_, screenshot_delegate);
197 return; 197 return;
198 } 198 }
199 screenshot_delegate_ = screenshot_delegate; 199 screenshot_delegate_ = screenshot_delegate;
200 mode_ = WINDOW; 200 mode_ = WINDOW;
201 201
202 gfx::Screen::GetScreen()->AddObserver(this); 202 display::Screen::GetScreen()->AddObserver(this);
203 for (aura::Window* root : Shell::GetAllRootWindows()) { 203 for (aura::Window* root : Shell::GetAllRootWindows()) {
204 layers_[root] = new ScreenshotLayer( 204 layers_[root] = new ScreenshotLayer(
205 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer()); 205 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer());
206 } 206 }
207 SetSelectedWindow(wm::GetActiveWindow()); 207 SetSelectedWindow(wm::GetActiveWindow());
208 208
209 cursor_setter_.reset(new ScopedCursorSetter( 209 cursor_setter_.reset(new ScopedCursorSetter(
210 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); 210 Shell::GetInstance()->cursor_manager(), ui::kCursorCross));
211 211
212 EnableMouseWarp(true); 212 EnableMouseWarp(true);
213 } 213 }
214 214
215 void ScreenshotController::StartPartialScreenshotSession( 215 void ScreenshotController::StartPartialScreenshotSession(
216 ScreenshotDelegate* screenshot_delegate) { 216 ScreenshotDelegate* screenshot_delegate) {
217 // Already in a screenshot session. 217 // Already in a screenshot session.
218 if (screenshot_delegate_) { 218 if (screenshot_delegate_) {
219 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); 219 DCHECK_EQ(screenshot_delegate_, screenshot_delegate);
220 return; 220 return;
221 } 221 }
222 222
223 screenshot_delegate_ = screenshot_delegate; 223 screenshot_delegate_ = screenshot_delegate;
224 mode_ = PARTIAL; 224 mode_ = PARTIAL;
225 gfx::Screen::GetScreen()->AddObserver(this); 225 display::Screen::GetScreen()->AddObserver(this);
226 for (aura::Window* root : Shell::GetAllRootWindows()) { 226 for (aura::Window* root : Shell::GetAllRootWindows()) {
227 layers_[root] = new ScreenshotLayer( 227 layers_[root] = new ScreenshotLayer(
228 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer()); 228 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer());
229 } 229 }
230 230
231 cursor_setter_.reset(new ScopedCursorSetter( 231 cursor_setter_.reset(new ScopedCursorSetter(
232 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); 232 Shell::GetInstance()->cursor_manager(), ui::kCursorCross));
233 233
234 EnableMouseWarp(false); 234 EnableMouseWarp(false);
235 } 235 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 root_window_, gfx::IntersectRects(root_window_->bounds(), region)); 276 root_window_, gfx::IntersectRects(root_window_->bounds(), region));
277 } 277 }
278 Cancel(); 278 Cancel();
279 } 279 }
280 280
281 void ScreenshotController::Cancel() { 281 void ScreenshotController::Cancel() {
282 mode_ = NONE; 282 mode_ = NONE;
283 root_window_ = nullptr; 283 root_window_ = nullptr;
284 SetSelectedWindow(nullptr); 284 SetSelectedWindow(nullptr);
285 screenshot_delegate_ = nullptr; 285 screenshot_delegate_ = nullptr;
286 gfx::Screen::GetScreen()->RemoveObserver(this); 286 display::Screen::GetScreen()->RemoveObserver(this);
287 STLDeleteValues(&layers_); 287 STLDeleteValues(&layers_);
288 cursor_setter_.reset(); 288 cursor_setter_.reset();
289 EnableMouseWarp(true); 289 EnableMouseWarp(true);
290 } 290 }
291 291
292 void ScreenshotController::Update(const ui::LocatedEvent& event) { 292 void ScreenshotController::Update(const ui::LocatedEvent& event) {
293 // Update may happen without MaybeStart() if the partial screenshot session 293 // Update may happen without MaybeStart() if the partial screenshot session
294 // starts when dragging. 294 // starts when dragging.
295 if (!root_window_) 295 if (!root_window_)
296 MaybeStart(event); 296 MaybeStart(event);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 break; 428 break;
429 default: 429 default:
430 // Do nothing. 430 // Do nothing.
431 break; 431 break;
432 } 432 }
433 break; 433 break;
434 } 434 }
435 event->StopPropagation(); 435 event->StopPropagation();
436 } 436 }
437 437
438 void ScreenshotController::OnDisplayAdded(const gfx::Display& new_display) { 438 void ScreenshotController::OnDisplayAdded(const display::Display& new_display) {
439 if (!screenshot_delegate_) 439 if (!screenshot_delegate_)
440 return; 440 return;
441 Cancel(); 441 Cancel();
442 } 442 }
443 443
444 void ScreenshotController::OnDisplayRemoved(const gfx::Display& old_display) { 444 void ScreenshotController::OnDisplayRemoved(
445 const display::Display& old_display) {
445 if (!screenshot_delegate_) 446 if (!screenshot_delegate_)
446 return; 447 return;
447 Cancel(); 448 Cancel();
448 } 449 }
449 450
450 void ScreenshotController::OnDisplayMetricsChanged(const gfx::Display& display, 451 void ScreenshotController::OnDisplayMetricsChanged(
451 uint32_t changed_metrics) {} 452 const display::Display& display,
453 uint32_t changed_metrics) {}
452 454
453 void ScreenshotController::OnWindowDestroying(aura::Window* window) { 455 void ScreenshotController::OnWindowDestroying(aura::Window* window) {
454 SetSelectedWindow(nullptr); 456 SetSelectedWindow(nullptr);
455 } 457 }
456 458
457 } // namespace ash 459 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698