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

Unified Diff: ash/utility/screenshot_controller.cc

Issue 2393703002: Fix partial screenshot/window screenshot when holding Alt+Tab. (Closed)
Patch Set: capture 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/utility/screenshot_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/utility/screenshot_controller.cc
diff --git a/ash/utility/screenshot_controller.cc b/ash/utility/screenshot_controller.cc
index 64e4f99785f09fd729063fb9d05434708c248969..9bd71f8e442e9eab816b0fbdc6efa84146136299 100644
--- a/ash/utility/screenshot_controller.cc
+++ b/ash/utility/screenshot_controller.cc
@@ -12,7 +12,6 @@
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "base/memory/ptr_util.h"
-#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_targeter.h"
#include "ui/compositor/paint_recorder.h"
@@ -62,17 +61,10 @@ class ScreenshotWindowTargeter : public aura::WindowTargeter {
gfx::Point target_location = event->location();
event->set_location(location);
-
- // Ignore capture window when finding the target for located event.
Evan Stade 2016/10/06 16:32:34 so I noticed this bit of code as well, which seems
oshima 2016/10/06 20:07:53 This is to deal with menu windows, so please do no
- aura::client::CaptureClient* original_capture_client =
- aura::client::GetCaptureClient(root_window);
- aura::client::SetCaptureClient(root_window, nullptr);
-
aura::Window* selected =
static_cast<aura::Window*>(FindTargetForEvent(root_window, event));
// Restore State.
- aura::client::SetCaptureClient(root_window, original_capture_client);
event->set_location(target_location);
return selected;
}
@@ -255,15 +247,20 @@ void ScreenshotController::StartWindowScreenshotSession(
DCHECK_EQ(screenshot_delegate_, screenshot_delegate);
return;
}
- screenshot_delegate_ = screenshot_delegate;
- mode_ = WINDOW;
- display::Screen::GetScreen()->AddObserver(this);
for (aura::Window* root : Shell::GetAllRootWindows()) {
+ // Since we'll be pre-handling all mouse events, break any existing
+ // captures.
+ aura::client::GetCaptureClient(root)->SetCapture(nullptr);
layers_[root] = base::MakeUnique<ScreenshotLayer>(
Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(),
true);
}
+
+ screenshot_delegate_ = screenshot_delegate;
+ mode_ = WINDOW;
+
+ display::Screen::GetScreen()->AddObserver(this);
SetSelectedWindow(wm::GetActiveWindow());
cursor_setter_.reset(new ScopedCursorSetter(
@@ -281,15 +278,19 @@ void ScreenshotController::StartPartialScreenshotSession(
return;
}
- screenshot_delegate_ = screenshot_delegate;
- mode_ = PARTIAL;
- display::Screen::GetScreen()->AddObserver(this);
for (aura::Window* root : Shell::GetAllRootWindows()) {
+ // Since we'll be pre-handling all mouse events, break any existing
+ // captures.
+ aura::client::GetCaptureClient(root)->SetCapture(nullptr);
layers_[root] = base::MakeUnique<ScreenshotLayer>(
Shell::GetContainer(root, kShellWindowId_OverlayContainer)->layer(),
draw_overlay_immediately);
}
+ screenshot_delegate_ = screenshot_delegate;
+ mode_ = PARTIAL;
+ display::Screen::GetScreen()->AddObserver(this);
+
if (!pen_events_only_) {
cursor_setter_.reset(new ScopedCursorSetter(
Shell::GetInstance()->cursor_manager(), ui::kCursorCross));
« 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