Notify normalizing input filters on blur.
Previously, ReleaseAllKeys was not notifying the normalizing input filter
because that filter exists above InputEventTracker in the input pipeline.
In fact, the input "pipeline" was more like a tree, with both the touch
input scaler and the pepper input handler feeding into the input tracker.
This CL establishes a linear pipeline, as described in the header comment.
BUG=590404
Review URL: https://codereview.chromium.org/1760633003
Cr-Commit-Position: refs/heads/master@{#379398}
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index b57f1886..a90b5071 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -151,8 +151,7 @@
initialized_(false),
plugin_task_runner_(new PepperMainThreadTaskRunner()),
context_(plugin_task_runner_.get()),
- input_tracker_(&mouse_input_filter_),
- touch_input_scaler_(&input_tracker_),
+ touch_input_scaler_(&mouse_input_filter_),
key_mapper_(&touch_input_scaler_),
input_handler_(&input_tracker_),
cursor_setter_(this),
@@ -649,7 +648,7 @@
DCHECK(key_filter.empty());
normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_));
}
- input_handler_.set_input_stub(normalizing_input_filter_.get());
+ input_tracker_.set_input_stub(normalizing_input_filter_.get());
// Try initializing 3D video renderer.
video_renderer_.reset(new PepperVideoRenderer3D());
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index 9eba3d1..52b6efd 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -263,10 +263,10 @@
// Input pipeline components, in reverse order of distance from input source.
protocol::MouseInputFilter mouse_input_filter_;
- protocol::InputEventTracker input_tracker_;
TouchInputScaler touch_input_scaler_;
KeyEventMapper key_mapper_;
scoped_ptr<protocol::InputFilter> normalizing_input_filter_;
+ protocol::InputEventTracker input_tracker_;
PepperInputHandler input_handler_;
// Cursor shape handling components, in reverse order to that in which they
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc
index c25c566..4b652649 100644
--- a/remoting/client/plugin/pepper_input_handler.cc
+++ b/remoting/client/plugin/pepper_input_handler.cc
@@ -111,8 +111,7 @@
PepperInputHandler::PepperInputHandler(
protocol::InputEventTracker* input_tracker)
- : input_stub_(nullptr),
- input_tracker_(input_tracker),
+ : input_tracker_(input_tracker),
has_focus_(false),
send_mouse_input_when_unfocused_(false),
send_mouse_move_deltas_(false),
@@ -133,10 +132,8 @@
case PP_INPUTEVENT_TYPE_TOUCHMOVE:
case PP_INPUTEVENT_TYPE_TOUCHEND:
case PP_INPUTEVENT_TYPE_TOUCHCANCEL: {
- if (!input_stub_)
- return true;
pp::TouchInputEvent pp_touch_event(event);
- input_stub_->InjectTouchEvent(MakeTouchEvent(pp_touch_event));
+ input_tracker_->InjectTouchEvent(MakeTouchEvent(pp_touch_event));
return true;
}
@@ -148,10 +145,8 @@
case PP_INPUTEVENT_TYPE_KEYDOWN:
case PP_INPUTEVENT_TYPE_KEYUP: {
- if (!input_stub_)
- return true;
pp::KeyboardInputEvent pp_key_event(event);
- input_stub_->InjectKeyEvent(MakeKeyEvent(pp_key_event));
+ input_tracker_->InjectKeyEvent(MakeKeyEvent(pp_key_event));
return true;
}
@@ -159,8 +154,6 @@
case PP_INPUTEVENT_TYPE_MOUSEUP: {
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
- if (!input_stub_)
- return true;
pp::MouseInputEvent pp_mouse_event(event);
protocol::MouseEvent mouse_event(
@@ -181,7 +174,7 @@
if (mouse_event.has_button()) {
bool is_down = (event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN);
mouse_event.set_button_down(is_down);
- input_stub_->InjectMouseEvent(mouse_event);
+ input_tracker_->InjectMouseEvent(mouse_event);
}
return true;
@@ -192,11 +185,9 @@
case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
- if (!input_stub_)
- return true;
pp::MouseInputEvent pp_mouse_event(event);
- input_stub_->InjectMouseEvent(
+ input_tracker_->InjectMouseEvent(
MakeMouseEvent(pp_mouse_event, send_mouse_move_deltas_));
return true;
@@ -205,8 +196,6 @@
case PP_INPUTEVENT_TYPE_WHEEL: {
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
- if (!input_stub_)
- return true;
pp::WheelInputEvent pp_wheel_event(event);
@@ -246,7 +235,7 @@
mouse_event.set_wheel_ticks_x(ticks_x);
mouse_event.set_wheel_ticks_y(ticks_y);
- input_stub_->InjectMouseEvent(mouse_event);
+ input_tracker_->InjectMouseEvent(mouse_event);
}
return true;
}
diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h
index 3c00221..1d07c9f 100644
--- a/remoting/client/plugin/pepper_input_handler.h
+++ b/remoting/client/plugin/pepper_input_handler.h
@@ -26,11 +26,6 @@
// for the lifetime of the PepperInputHandler.
explicit PepperInputHandler(protocol::InputEventTracker* input_tracker);
- // Sets the input stub to which processed events will be passed.
- void set_input_stub(protocol::InputStub* input_stub) {
- input_stub_ = input_stub;
- }
-
// Enable or disable sending mouse input when the plugin does not have input
// focus.
void set_send_mouse_input_when_unfocused(bool send) {
@@ -46,7 +41,7 @@
detect_stuck_modifiers_ = detect;
}
- // Processes PPAPI events and dispatches them to |input_stub_|.
+ // Processes PPAPI events and dispatches them to |input_tracker_|.
bool HandleInputEvent(const pp::InputEvent& event);
// Must be called when the plugin receives or loses focus.
@@ -59,10 +54,8 @@
// are not indicated as active on |event|, release all keys.
void ReleaseAllIfModifiersStuck(const pp::InputEvent& event);
- // Receives input events generated from PPAPI input.
- protocol::InputStub* input_stub_;
-
- // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck.
+ // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck
+ // and receives input events generated from PPAPI input.
protocol::InputEventTracker* input_tracker_;
// True if the plugin has focus.
diff --git a/remoting/protocol/input_event_tracker.cc b/remoting/protocol/input_event_tracker.cc
index 60c4bfd..c232c013 100644
--- a/remoting/protocol/input_event_tracker.cc
+++ b/remoting/protocol/input_event_tracker.cc
@@ -10,9 +10,10 @@
namespace remoting {
namespace protocol {
+InputEventTracker::InputEventTracker() {}
+
InputEventTracker::InputEventTracker(InputStub* input_stub)
- : input_stub_(input_stub),
- mouse_button_state_(0) {
+ : input_stub_(input_stub) {
}
InputEventTracker::~InputEventTracker() {}
@@ -26,6 +27,8 @@
}
void InputEventTracker::ReleaseAll() {
+ DCHECK(input_stub_);
+
// Release all pressed keys.
for (auto keycode : pressed_keys_) {
KeyEvent event;
@@ -91,6 +94,8 @@
}
void InputEventTracker::InjectKeyEvent(const KeyEvent& event) {
+ DCHECK(input_stub_);
+
// We don't need to track the keyboard lock states of key down events.
// Pressed keys will be released with |lock_states| set to 0.
// The lock states of auto generated key up events don't matter as long as
@@ -108,10 +113,13 @@
}
void InputEventTracker::InjectTextEvent(const TextEvent& event) {
+ DCHECK(input_stub_);
input_stub_->InjectTextEvent(event);
}
void InputEventTracker::InjectMouseEvent(const MouseEvent& event) {
+ DCHECK(input_stub_);
+
if (event.has_x() && event.has_y()) {
mouse_pos_ = webrtc::DesktopVector(event.x(), event.y());
}
@@ -130,6 +138,7 @@
}
void InputEventTracker::InjectTouchEvent(const TouchEvent& event) {
+ DCHECK(input_stub_);
// We only need the IDs to cancel all touch points in ReleaseAll(). Other
// fields do not have to be tracked here as long as the host keeps track of
// them.
diff --git a/remoting/protocol/input_event_tracker.h b/remoting/protocol/input_event_tracker.h
index ff19b1d..1511fa5 100644
--- a/remoting/protocol/input_event_tracker.h
+++ b/remoting/protocol/input_event_tracker.h
@@ -23,9 +23,14 @@
// |input_stub| for all currently-pressed keys and buttons when necessary.
class InputEventTracker : public InputStub {
public:
- explicit InputEventTracker(protocol::InputStub* input_stub);
+ InputEventTracker();
+ explicit InputEventTracker(InputStub* input_stub);
~InputEventTracker() override;
+ void set_input_stub(InputStub* input_stub) {
+ input_stub_ = input_stub;
+ }
+
// Returns true if the key with the specified USB code is currently pressed.
bool IsKeyPressed(ui::DomCode usb_keycode) const;
@@ -49,12 +54,12 @@
void InjectTouchEvent(const TouchEvent& event) override;
private:
- protocol::InputStub* input_stub_;
+ InputStub* input_stub_ = nullptr;
std::set<ui::DomCode> pressed_keys_;
webrtc::DesktopVector mouse_pos_;
- uint32_t mouse_button_state_;
+ uint32_t mouse_button_state_ = 0;
std::set<uint32_t> touch_point_ids_;