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
3 // found in the LICENSE file.
5 #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_
6 #define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_
8 #include "base/memory/scoped_ptr.h"
18 class InputEventTracker
;
19 } // namespace protocol
21 class PepperInputHandler
{
23 // Create a PepperInputHandler using the specified InputEventTracker to
24 // handle auto-release. The InputEventTracker instance must remain valid
25 // for the lifetime of the PepperInputHandler.
26 explicit PepperInputHandler(protocol::InputEventTracker
* input_tracker
);
28 // Sets the input stub to which processed events will be passed.
29 void set_input_stub(protocol::InputStub
* input_stub
) {
30 input_stub_
= input_stub
;
33 // Enable or disable sending mouse input when the plugin does not have input
35 void set_send_mouse_input_when_unfocused(bool send
) {
36 send_mouse_input_when_unfocused_
= send
;
39 void set_send_mouse_move_deltas(bool enable
) {
40 send_mouse_move_deltas_
= enable
;
43 // Processes PPAPI events and dispatches them to |input_stub_|.
44 bool HandleInputEvent(const pp::InputEvent
& event
);
46 // Must be called when the plugin receives or loses focus.
47 void DidChangeFocus(bool has_focus
);
50 // Check for any missed "keyup" events for modifiers. These can sometimes be
51 // missed due to OS-level keyboard shortcuts such as "lock screen" that cause
52 // focus to switch to another application. If any modifier keys are held that
53 // are not indicated as active on |event|, release all keys.
54 void ReleaseAllIfModifiersStuck(const pp::InputEvent
& event
);
56 // Receives input events generated from PPAPI input.
57 protocol::InputStub
* input_stub_
;
59 // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck.
60 protocol::InputEventTracker
* input_tracker_
;
62 // True if the plugin has focus.
65 // True if the plugin should respond to mouse input even if it does not have
67 bool send_mouse_input_when_unfocused_
;
69 // True if the plugin should include mouse move deltas, in addition to
70 // absolute position information, in mouse events.
71 bool send_mouse_move_deltas_
;
73 // Accumulated sub-pixel and sub-tick deltas from wheel events.
79 DISALLOW_COPY_AND_ASSIGN(PepperInputHandler
);
82 } // namespace remoting
84 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_