diff options
author | jamiewalch <jamiewalch@chromium.org> | 2015-03-11 20:09:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-12 03:10:38 +0000 |
commit | 613d162f00dcbf9a5d76b0d25e8522e788f2d619 (patch) | |
tree | 0312d0c2d85277643a071865d7a9f49e801a53dd /remoting/client/plugin | |
parent | 7d9b408634e37977dc8b4dfc12775343eec83162 (diff) | |
download | chromium_src-613d162f00dcbf9a5d76b0d25e8522e788f2d619.zip chromium_src-613d162f00dcbf9a5d76b0d25e8522e788f2d619.tar.gz chromium_src-613d162f00dcbf9a5d76b0d25e8522e788f2d619.tar.bz2 |
Detect and release stuck modifier keys.
We consider a modifier key to be "stuck" if we have sent a keydown event for it and subsequent input event indicates that it is no longer active.
BUG=464534
Review URL: https://codereview.chromium.org/984183002
Cr-Commit-Position: refs/heads/master@{#320220}
Diffstat (limited to 'remoting/client/plugin')
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 1 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.cc | 33 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_input_handler.h | 16 |
3 files changed, 47 insertions, 3 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index 5d09ac4..d4ad35f 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -189,6 +189,7 @@ ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) input_tracker_(&mouse_input_filter_), touch_input_scaler_(&input_tracker_), key_mapper_(&touch_input_scaler_), + input_handler_(&input_tracker_), cursor_setter_(this), empty_cursor_filter_(&cursor_setter_), text_input_controller_(this), diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc index a9eb420..e4bbac2 100644 --- a/remoting/client/plugin/pepper_input_handler.cc +++ b/remoting/client/plugin/pepper_input_handler.cc @@ -13,6 +13,8 @@ #include "ppapi/cpp/touch_point.h" #include "ppapi/cpp/var.h" #include "remoting/proto/event.pb.h" +#include "remoting/protocol/input_event_tracker.h" +#include "remoting/protocol/input_stub.h" #include "ui/events/keycodes/dom4/keycode_converter.h" namespace remoting { @@ -106,8 +108,10 @@ protocol::MouseEvent MakeMouseEvent(const pp::MouseInputEvent& pp_mouse_event, } // namespace -PepperInputHandler::PepperInputHandler() +PepperInputHandler::PepperInputHandler( + protocol::InputEventTracker* input_tracker) : input_stub_(nullptr), + input_tracker_(input_tracker), has_focus_(false), send_mouse_input_when_unfocused_(false), send_mouse_move_deltas_(false), @@ -118,6 +122,8 @@ PepperInputHandler::PepperInputHandler() } bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) { + ReleaseAllIfModifiersStuck(event); + switch (event.GetType()) { // Touch input cases. case PP_INPUTEVENT_TYPE_TOUCHSTART: @@ -259,4 +265,29 @@ void PepperInputHandler::DidChangeFocus(bool has_focus) { has_focus_ = has_focus; } +void PepperInputHandler::ReleaseAllIfModifiersStuck( + const pp::InputEvent& event) { + switch (event.GetType()) { + case PP_INPUTEVENT_TYPE_MOUSEMOVE: + case PP_INPUTEVENT_TYPE_MOUSEENTER: + case PP_INPUTEVENT_TYPE_MOUSELEAVE: + // Don't check modifiers on every mouse move event. + break; + + case PP_INPUTEVENT_TYPE_KEYUP: + // PPAPI doesn't always set modifiers correctly on KEYUP events. See + // crbug.com/464791 for details. + break; + + default: { + uint32_t modifiers = event.GetModifiers(); + input_tracker_->ReleaseAllIfModifiersStuck( + (modifiers & PP_INPUTEVENT_MODIFIER_ALTKEY) != 0, + (modifiers & PP_INPUTEVENT_MODIFIER_CONTROLKEY) != 0, + (modifiers & PP_INPUTEVENT_MODIFIER_METAKEY) != 0, + (modifiers & PP_INPUTEVENT_MODIFIER_SHIFTKEY) != 0); + } + } +} + } // namespace remoting diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h index 299077f..e5828262 100644 --- a/remoting/client/plugin/pepper_input_handler.h +++ b/remoting/client/plugin/pepper_input_handler.h @@ -6,7 +6,6 @@ #define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ #include "base/memory/scoped_ptr.h" -#include "remoting/protocol/input_stub.h" namespace pp { class InputEvent; @@ -16,11 +15,15 @@ namespace remoting { namespace protocol { class InputStub; +class InputEventTracker; } // namespace protocol class PepperInputHandler { public: - PepperInputHandler(); + // Create a PepperInputHandler using the specified InputEventTracker to + // handle auto-release. The InputEventTracker instance must remain valid + // 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) { @@ -44,9 +47,18 @@ class PepperInputHandler { void DidChangeFocus(bool has_focus); private: + // Check for any missed "keyup" events for modifiers. These can sometimes be + // missed due to OS-level keyboard shortcuts such as "lock screen" that cause + // focus to switch to another application. If any modifier keys are held that + // 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. + protocol::InputEventTracker* input_tracker_; + // True if the plugin has focus. bool has_focus_; |