| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ | 5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ |
| 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ | 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 | 10 |
| 11 namespace pp { | 11 namespace pp { |
| 12 class InputEvent; | 12 class InputEvent; |
| 13 } // namespace pp | 13 } // namespace pp |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 namespace protocol { | 17 namespace protocol { |
| 18 class InputStub; | 18 class InputStub; |
| 19 class InputEventTracker; | 19 class InputEventTracker; |
| 20 } // namespace protocol | 20 } // namespace protocol |
| 21 | 21 |
| 22 class PepperInputHandler { | 22 class PepperInputHandler { |
| 23 public: | 23 public: |
| 24 // Create a PepperInputHandler using the specified InputEventTracker to | 24 // Create a PepperInputHandler using the specified InputEventTracker to |
| 25 // handle auto-release. The InputEventTracker instance must remain valid | 25 // handle auto-release. The InputEventTracker instance must remain valid |
| 26 // for the lifetime of the PepperInputHandler. | 26 // for the lifetime of the PepperInputHandler. |
| 27 explicit PepperInputHandler(protocol::InputEventTracker* input_tracker); | 27 explicit PepperInputHandler(protocol::InputEventTracker* input_tracker); |
| 28 | 28 |
| 29 // Sets the input stub to which processed events will be passed. | |
| 30 void set_input_stub(protocol::InputStub* input_stub) { | |
| 31 input_stub_ = input_stub; | |
| 32 } | |
| 33 | |
| 34 // Enable or disable sending mouse input when the plugin does not have input | 29 // Enable or disable sending mouse input when the plugin does not have input |
| 35 // focus. | 30 // focus. |
| 36 void set_send_mouse_input_when_unfocused(bool send) { | 31 void set_send_mouse_input_when_unfocused(bool send) { |
| 37 send_mouse_input_when_unfocused_ = send; | 32 send_mouse_input_when_unfocused_ = send; |
| 38 } | 33 } |
| 39 | 34 |
| 40 void set_send_mouse_move_deltas(bool enable) { | 35 void set_send_mouse_move_deltas(bool enable) { |
| 41 send_mouse_move_deltas_ = enable; | 36 send_mouse_move_deltas_ = enable; |
| 42 } | 37 } |
| 43 | 38 |
| 44 // Enable or disable detection of stuck modifier keys. | 39 // Enable or disable detection of stuck modifier keys. |
| 45 void set_detect_stuck_modifiers(bool detect) { | 40 void set_detect_stuck_modifiers(bool detect) { |
| 46 detect_stuck_modifiers_ = detect; | 41 detect_stuck_modifiers_ = detect; |
| 47 } | 42 } |
| 48 | 43 |
| 49 // Processes PPAPI events and dispatches them to |input_stub_|. | 44 // Processes PPAPI events and dispatches them to |input_tracker_|. |
| 50 bool HandleInputEvent(const pp::InputEvent& event); | 45 bool HandleInputEvent(const pp::InputEvent& event); |
| 51 | 46 |
| 52 // Must be called when the plugin receives or loses focus. | 47 // Must be called when the plugin receives or loses focus. |
| 53 void DidChangeFocus(bool has_focus); | 48 void DidChangeFocus(bool has_focus); |
| 54 | 49 |
| 55 private: | 50 private: |
| 56 // Check for any missed "keyup" events for modifiers. These can sometimes be | 51 // Check for any missed "keyup" events for modifiers. These can sometimes be |
| 57 // missed due to OS-level keyboard shortcuts such as "lock screen" that cause | 52 // missed due to OS-level keyboard shortcuts such as "lock screen" that cause |
| 58 // focus to switch to another application. If any modifier keys are held that | 53 // focus to switch to another application. If any modifier keys are held that |
| 59 // are not indicated as active on |event|, release all keys. | 54 // are not indicated as active on |event|, release all keys. |
| 60 void ReleaseAllIfModifiersStuck(const pp::InputEvent& event); | 55 void ReleaseAllIfModifiersStuck(const pp::InputEvent& event); |
| 61 | 56 |
| 62 // Receives input events generated from PPAPI input. | 57 // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck |
| 63 protocol::InputStub* input_stub_; | 58 // and receives input events generated from PPAPI input. |
| 64 | |
| 65 // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck. | |
| 66 protocol::InputEventTracker* input_tracker_; | 59 protocol::InputEventTracker* input_tracker_; |
| 67 | 60 |
| 68 // True if the plugin has focus. | 61 // True if the plugin has focus. |
| 69 bool has_focus_; | 62 bool has_focus_; |
| 70 | 63 |
| 71 // True if the plugin should respond to mouse input even if it does not have | 64 // True if the plugin should respond to mouse input even if it does not have |
| 72 // keyboard focus. | 65 // keyboard focus. |
| 73 bool send_mouse_input_when_unfocused_; | 66 bool send_mouse_input_when_unfocused_; |
| 74 | 67 |
| 75 // True if the plugin should include mouse move deltas, in addition to | 68 // True if the plugin should include mouse move deltas, in addition to |
| 76 // absolute position information, in mouse events. | 69 // absolute position information, in mouse events. |
| 77 bool send_mouse_move_deltas_; | 70 bool send_mouse_move_deltas_; |
| 78 | 71 |
| 79 // Accumulated sub-pixel and sub-tick deltas from wheel events. | 72 // Accumulated sub-pixel and sub-tick deltas from wheel events. |
| 80 float wheel_delta_x_; | 73 float wheel_delta_x_; |
| 81 float wheel_delta_y_; | 74 float wheel_delta_y_; |
| 82 float wheel_ticks_x_; | 75 float wheel_ticks_x_; |
| 83 float wheel_ticks_y_; | 76 float wheel_ticks_y_; |
| 84 | 77 |
| 85 // Whether or not to check for stuck modifier keys on keyboard input events. | 78 // Whether or not to check for stuck modifier keys on keyboard input events. |
| 86 bool detect_stuck_modifiers_; | 79 bool detect_stuck_modifiers_; |
| 87 | 80 |
| 88 DISALLOW_COPY_AND_ASSIGN(PepperInputHandler); | 81 DISALLOW_COPY_AND_ASSIGN(PepperInputHandler); |
| 89 }; | 82 }; |
| 90 | 83 |
| 91 } // namespace remoting | 84 } // namespace remoting |
| 92 | 85 |
| 93 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ | 86 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ |
| OLD | NEW |