Commit b6a16014 authored by Jennifer Apacible's avatar Jennifer Apacible Committed by Commit Bot

[Picture in Picture] Activate controls using enter / space keys.

This change adds in KeyEvent handling to support keyboard usage with
the controls buttons. They should be activated when the 'enter' or
'space' keys are used.

The previous implementation of OnKeyEvent used an OverlayWindowViews
tracking of which control is being focused, which is now obsolete.

Bug: 866291
Change-Id: I8a59337aa7aef5c95da081a9b5f33762462eeaef
Reviewed-on: https://chromium-review.googlesource.com/1146283Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577172}
parent 11ee0960
...@@ -493,6 +493,22 @@ void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() { ...@@ -493,6 +493,22 @@ void OverlayWindowViews::OnNativeWidgetWorkspaceChanged() {
// does not trigger this function. http://crbug.com/819673 // does not trigger this function. http://crbug.com/819673
} }
void OverlayWindowViews::OnKeyEvent(ui::KeyEvent* event) {
if (event->type() != ui::ET_KEY_RELEASED)
return;
if (event->key_code() == ui::VKEY_RETURN ||
event->key_code() == ui::VKEY_SPACE) {
if (play_pause_controls_view_->HasFocus()) {
TogglePlayPause();
} else if (close_controls_view_->HasFocus()) {
controller_->Close(true /* should_pause_video */);
}
event->SetHandled();
}
}
void OverlayWindowViews::OnMouseEvent(ui::MouseEvent* event) { void OverlayWindowViews::OnMouseEvent(ui::MouseEvent* event) {
switch (event->type()) { switch (event->type()) {
// Only show the media controls when the mouse is hovering over the window. // Only show the media controls when the mouse is hovering over the window.
......
...@@ -42,6 +42,7 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget { ...@@ -42,6 +42,7 @@ class OverlayWindowViews : public content::OverlayWindow, public views::Widget {
gfx::Size GetMinimumSize() const override; gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override; gfx::Size GetMaximumSize() const override;
void OnNativeWidgetWorkspaceChanged() override; void OnNativeWidgetWorkspaceChanged() override;
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override; void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override; void OnGestureEvent(ui::GestureEvent* event) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment