Skip to content

Commit

Permalink
Capture Mode: use Env event handler
Browse files Browse the repository at this point in the history
When ephemeral UI is present, capture mode was not handling events (such
as ENTER and ESC). This is based on the priority and order the event
handlers are added to the list. This CL bumps the priority up and uses
the Env event handler instead of the Shell one in order to move its
position higher up in the targets list.

Bug: 1166391
Test: manual
Change-Id: I3db050ff374ddb0883e88b197af81dcb4bd232ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2715649
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: Sammie Quon <sammiequon@chromium.org>
Commit-Queue: Richard Chui <richui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#856962}
  • Loading branch information
Richard Chui authored and Chromium LUCI CQ committed Feb 24, 2021
1 parent c5e427a commit 98ed3e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions ash/capture_mode/capture_mode_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "base/stl_util.h"
#include "cc/paint/paint_flags.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/cursor/cursor_factory.h"
Expand Down Expand Up @@ -551,7 +552,8 @@ CaptureModeSession::CaptureModeSession(CaptureModeController* controller)
display::Screen::GetScreen()->AddObserver(this);
// Our event handling code assumes the capture bar widget has been initialized
// already. So we start handling events after everything has been setup.
Shell::Get()->AddPreTargetHandler(this);
aura::Env::GetInstance()->AddPreTargetHandler(
this, ui::EventTarget::Priority::kSystem);

capture_mode_util::TriggerAccessibilityAlert(l10n_util::GetStringFUTF8(
IDS_ASH_SCREEN_CAPTURE_ALERT_OPEN,
Expand All @@ -564,7 +566,7 @@ CaptureModeSession::CaptureModeSession(CaptureModeController* controller)
}

CaptureModeSession::~CaptureModeSession() {
Shell::Get()->RemovePreTargetHandler(this);
aura::Env::GetInstance()->RemovePreTargetHandler(this);
display::Screen::GetScreen()->RemoveObserver(this);
current_root_->RemoveObserver(this);
TabletModeController::Get()->RemoveObserver(this);
Expand Down
10 changes: 5 additions & 5 deletions ash/capture_mode/video_recording_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ VideoRecordingWatcher::VideoRecordingWatcher(

// Note the following:
// 1- We add |this| as a pre-target handler of the |window_being_recorded_| as
// opposed to |Shell|. This ensures that we only get mouse events when the
// opposed to |Env|. This ensures that we only get mouse events when the
// window being recorded is the target. This is more efficient since we
// won't get any event when the curosr is in a different display, or
// targeting a different window.
// 2- We use the |kSystem| priority to ensure that we get these events before
// other pre-target handlers can consume them (e.g. when opening a capture
// mode session to take a screenshot while recording a video).
// 2- We use the |kAccessibility| priority to ensure that we get these events
// before other pre-target handlers can consume them (e.g. when opening a
// capture mode session to take a screenshot while recording a video).
window_being_recorded_->AddPreTargetHandler(
this, ui::EventTarget::Priority::kSystem);
this, ui::EventTarget::Priority::kAccessibility);
}

VideoRecordingWatcher::~VideoRecordingWatcher() {
Expand Down

0 comments on commit 98ed3e7

Please sign in to comment.