Re-land: C++ readability review
[chromium-blink-merge.git] / remoting / client / plugin / pepper_input_handler.h
blobe5828262352a99afa6396d55431fc212cf6c6dbf
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"
10 namespace pp {
11 class InputEvent;
12 } // namespace pp
14 namespace remoting {
16 namespace protocol {
17 class InputStub;
18 class InputEventTracker;
19 } // namespace protocol
21 class PepperInputHandler {
22 public:
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
34 // focus.
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);
49 private:
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.
63 bool has_focus_;
65 // True if the plugin should respond to mouse input even if it does not have
66 // keyboard focus.
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.
74 float wheel_delta_x_;
75 float wheel_delta_y_;
76 float wheel_ticks_x_;
77 float wheel_ticks_y_;
79 DISALLOW_COPY_AND_ASSIGN(PepperInputHandler);
82 } // namespace remoting
84 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_