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

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

Issue 2393703002: Fix partial screenshot/window screenshot when holding Alt+Tab. (Closed)
Patch Set: unit test Created 4 years, 2 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 | ash/utility/screenshot_controller_unittest.cc » ('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 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/common/shell_window_ids.h" 9 #include "ash/common/shell_window_ids.h"
10 #include "ash/display/mouse_cursor_event_filter.h" 10 #include "ash/display/mouse_cursor_event_filter.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 ScreenshotDelegate* screenshot_delegate) { 253 ScreenshotDelegate* screenshot_delegate) {
254 if (screenshot_delegate_) { 254 if (screenshot_delegate_) {
255 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); 255 DCHECK_EQ(screenshot_delegate_, screenshot_delegate);
256 return; 256 return;
257 } 257 }
258 screenshot_delegate_ = screenshot_delegate; 258 screenshot_delegate_ = screenshot_delegate;
259 mode_ = WINDOW; 259 mode_ = WINDOW;
260 260
261 display::Screen::GetScreen()->AddObserver(this); 261 display::Screen::GetScreen()->AddObserver(this);
262 for (aura::Window* root : Shell::GetAllRootWindows()) { 262 for (aura::Window* root : Shell::GetAllRootWindows()) {
263 // Since we'll be pre-handling all mouse events, break any existing
264 // captures.
265 aura::client::GetCaptureClient(root)->SetCapture(nullptr);
sky 2016/10/05 15:57:35 I'm mildly worried about side effects this may hav
Evan Stade 2016/10/05 17:21:37 I was actually thinking that any side effects woul
sky 2016/10/06 15:45:50 Sorry for not being clear on side effects. I was m
Evan Stade 2016/10/06 16:32:34 done (I assume you meant to move the whole loop?)
263 layers_[root] = base::MakeUnique<ScreenshotLayer>( 266 layers_[root] = base::MakeUnique<ScreenshotLayer>(
264 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), 267 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(),
265 true); 268 true);
266 } 269 }
267 SetSelectedWindow(wm::GetActiveWindow()); 270 SetSelectedWindow(wm::GetActiveWindow());
268 271
269 cursor_setter_.reset(new ScopedCursorSetter( 272 cursor_setter_.reset(new ScopedCursorSetter(
270 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); 273 Shell::GetInstance()->cursor_manager(), ui::kCursorCross));
271 274
272 EnableMouseWarp(true); 275 EnableMouseWarp(true);
273 } 276 }
274 277
275 void ScreenshotController::StartPartialScreenshotSession( 278 void ScreenshotController::StartPartialScreenshotSession(
276 ScreenshotDelegate* screenshot_delegate, 279 ScreenshotDelegate* screenshot_delegate,
277 bool draw_overlay_immediately) { 280 bool draw_overlay_immediately) {
278 // Already in a screenshot session. 281 // Already in a screenshot session.
279 if (screenshot_delegate_) { 282 if (screenshot_delegate_) {
280 DCHECK_EQ(screenshot_delegate_, screenshot_delegate); 283 DCHECK_EQ(screenshot_delegate_, screenshot_delegate);
281 return; 284 return;
282 } 285 }
283 286
284 screenshot_delegate_ = screenshot_delegate; 287 screenshot_delegate_ = screenshot_delegate;
285 mode_ = PARTIAL; 288 mode_ = PARTIAL;
286 display::Screen::GetScreen()->AddObserver(this); 289 display::Screen::GetScreen()->AddObserver(this);
287 for (aura::Window* root : Shell::GetAllRootWindows()) { 290 for (aura::Window* root : Shell::GetAllRootWindows()) {
291 // Since we'll be pre-handling all mouse events, break any existing
292 // captures.
293 aura::client::GetCaptureClient(root)->SetCapture(nullptr);
288 layers_[root] = base::MakeUnique<ScreenshotLayer>( 294 layers_[root] = base::MakeUnique<ScreenshotLayer>(
289 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(), 295 Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(),
290 draw_overlay_immediately); 296 draw_overlay_immediately);
291 } 297 }
292 298
293 if (!pen_events_only_) { 299 if (!pen_events_only_) {
294 cursor_setter_.reset(new ScopedCursorSetter( 300 cursor_setter_.reset(new ScopedCursorSetter(
295 Shell::GetInstance()->cursor_manager(), ui::kCursorCross)); 301 Shell::GetInstance()->cursor_manager(), ui::kCursorCross));
296 } 302 }
297 303
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 548
543 void ScreenshotController::OnDisplayMetricsChanged( 549 void ScreenshotController::OnDisplayMetricsChanged(
544 const display::Display& display, 550 const display::Display& display,
545 uint32_t changed_metrics) {} 551 uint32_t changed_metrics) {}
546 552
547 void ScreenshotController::OnWindowDestroying(aura::Window* window) { 553 void ScreenshotController::OnWindowDestroying(aura::Window* window) {
548 SetSelectedWindow(nullptr); 554 SetSelectedWindow(nullptr);
549 } 555 }
550 556
551 } // namespace ash 557 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/utility/screenshot_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698