Skip to content

Commit

Permalink
Revert "Implement zcr_extended_keyboard::peek_key."
Browse files Browse the repository at this point in the history
This reverts commit e3739ab.

Reason for revert:

Tree closing compile failure per

https://ci.chromium.org/p/chromium/builders/ci/WebKit%20Linux%20MSAN

Original change's description:
> Implement zcr_extended_keyboard::peek_key.
>
> BUG=1180433
> TEST=Ran exo_unittests.
>
> Change-Id: I787963980a795b41fb52b6d2690d427e66d9286d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2796852
> Reviewed-by: Jun Mukai <mukai@chromium.org>
> Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#868389}

Bug: 1180433
Change-Id: I0c179a57e69d086e3b46bac3a293ae934532ba49
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2799111
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Noel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#868393}
  • Loading branch information
Noel Gordon authored and Chromium LUCI CQ committed Apr 1, 2021
1 parent b65c677 commit 7914ac9
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 311 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MockKeyboardDelegate : public exo::KeyboardDelegate {
MOCK_METHOD(void,
OnKeyboardEnter,
(exo::Surface*,
(const base::flat_map<ui::DomCode, exo::KeyState>&)),
(const base::flat_map<ui::DomCode, ui::DomCode>&)),
(override));
MOCK_METHOD(void, OnKeyboardLeave, (exo::Surface*), (override));
MOCK_METHOD(uint32_t,
Expand Down
1 change: 0 additions & 1 deletion components/exo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static_library("exo") {
"frame_sink_resource_manager.cc",
"frame_sink_resource_manager.h",
"input_trace.h",
"key_state.h",
"keyboard_delegate.h",
"keyboard_device_configuration_delegate.h",
"keyboard_observer.h",
Expand Down
26 changes: 0 additions & 26 deletions components/exo/key_state.h

This file was deleted.

59 changes: 24 additions & 35 deletions components/exo/keyboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,28 +294,22 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) {
switch (event->type()) {
case ui::ET_KEY_PRESSED: {
auto it = pressed_keys_.find(physical_code);
if (it == pressed_keys_.end() && !event->handled() &&
if (it == pressed_keys_.end() && !consumed_by_ime && !event->handled() &&
physical_code != ui::DomCode::NONE) {
for (auto& observer : observer_list_)
observer.OnKeyboardKey(event->time_stamp(), event->code(), true);

if (!consumed_by_ime) {
// Process key press event if not already handled and not already
// pressed.
uint32_t serial = delegate_->OnKeyboardKey(event->time_stamp(),
event->code(), true);
if (AreKeyboardKeyAcksNeeded()) {
pending_key_acks_.insert(
{serial,
{*event, base::TimeTicks::Now() +
expiration_delay_for_pending_key_acks_}});
event->SetHandled();
}
// Process key press event if not already handled and not already
// pressed.
uint32_t serial =
delegate_->OnKeyboardKey(event->time_stamp(), event->code(), true);
if (AreKeyboardKeyAcksNeeded()) {
pending_key_acks_.insert(
{serial,
{*event, base::TimeTicks::Now() +
expiration_delay_for_pending_key_acks_}});
event->SetHandled();
}
// Keep track of both the physical code and potentially re-written
// code that this event generated.
pressed_keys_.emplace(physical_code,
KeyState{event->code(), consumed_by_ime});
pressed_keys_.insert({physical_code, event->code()});
} else if (it != pressed_keys_.end() && !event->handled()) {
// Non-repeate key events for already pressed key can be sent in some
// cases (e.g. Holding 'A' key then holding 'B' key then releasing 'A'
Expand All @@ -330,23 +324,18 @@ void Keyboard::OnKeyEvent(ui::KeyEvent* event) {
// Process key release event if currently pressed.
auto it = pressed_keys_.find(physical_code);
if (it != pressed_keys_.end()) {
for (auto& observer : observer_list_)
observer.OnKeyboardKey(event->time_stamp(), it->second.code, false);

if (!it->second.consumed_by_ime) {
// We use the code that was generated when the physical key was
// pressed rather than the current event code. This allows events
// to be re-written before dispatch, while still allowing the
// client to track the state of the physical keyboard.
uint32_t serial = delegate_->OnKeyboardKey(event->time_stamp(),
it->second.code, false);
if (AreKeyboardKeyAcksNeeded()) {
pending_key_acks_.insert(
{serial,
{*event, base::TimeTicks::Now() +
expiration_delay_for_pending_key_acks_}});
event->SetHandled();
}
// We use the code that was generate when the physical key was
// pressed rather than the current event code. This allows events
// to be re-written before dispatch, while still allowing the
// client to track the state of the physical keyboard.
uint32_t serial =
delegate_->OnKeyboardKey(event->time_stamp(), it->second, false);
if (AreKeyboardKeyAcksNeeded()) {
pending_key_acks_.insert(
{serial,
{*event, base::TimeTicks::Now() +
expiration_delay_for_pending_key_acks_}});
event->SetHandled();
}
pressed_keys_.erase(it);
}
Expand Down
3 changes: 1 addition & 2 deletions components/exo/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/observer_list.h"
#include "components/exo/key_state.h"
#include "components/exo/keyboard_observer.h"
#include "components/exo/seat_observer.h"
#include "components/exo/surface_observer.h"
Expand Down Expand Up @@ -119,7 +118,7 @@ class Keyboard : public ui::EventHandler,
// Set of currently pressed keys. First value is a platform code and second
// value is the code that was delivered to client. See Seat.h for more
// details.
base::flat_map<ui::DomCode, KeyState> pressed_keys_;
base::flat_map<ui::DomCode, ui::DomCode> pressed_keys_;

// Key state changes that are expected to be acknowledged.
using KeyStateChange = std::pair<ui::KeyEvent, base::TimeTicks>;
Expand Down
3 changes: 1 addition & 2 deletions components/exo/keyboard_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "base/containers/flat_map.h"
#include "base/strings/string_piece.h"
#include "base/time/time.h"
#include "components/exo/key_state.h"

namespace ui {
enum class DomCode;
Expand All @@ -30,7 +29,7 @@ class KeyboardDelegate {
// Called when keyboard focus enters a new valid target surface.
virtual void OnKeyboardEnter(
Surface* surface,
const base::flat_map<ui::DomCode, KeyState>& pressed_keys) = 0;
const base::flat_map<ui::DomCode, ui::DomCode>& pressed_keys) = 0;

// Called when keyboard focus leaves a valid target surface.
virtual void OnKeyboardLeave(Surface* surface) = 0;
Expand Down
9 changes: 1 addition & 8 deletions components/exo/keyboard_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ class KeyboardObserver {

// Called at the top of the keyboard's destructor, to give observers a change
// to remove themselves.
virtual void OnKeyboardDestroying(Keyboard* keyboard) {}

// Called just before KeyboardDelegate::OnKeyboardKey().
// KeyboardDelegate::OnKeyboardKey() may not be called, specifically if IME
// consumed the key event, but this is always.
virtual void OnKeyboardKey(base::TimeTicks time_stamp,
ui::DomCode code,
bool pressed) {}
virtual void OnKeyboardDestroying(Keyboard* keyboard) = 0;
};

} // namespace exo
Expand Down
Loading

0 comments on commit 7914ac9

Please sign in to comment.