Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / client / plugin / pepper_input_handler.h
blob0218e5f928f7619f5cd58d3c236a3e40fe1969d7
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 // Enable or disable detection of stuck modifier keys.
44 void set_detect_stuck_modifiers(bool detect) {
45 detect_stuck_modifiers_ = detect;
48 // Processes PPAPI events and dispatches them to |input_stub_|.
49 bool HandleInputEvent(const pp::InputEvent& event);
51 // Must be called when the plugin receives or loses focus.
52 void DidChangeFocus(bool has_focus);
54 private:
55 // Check for any missed "keyup" events for modifiers. These can sometimes be
56 // missed due to OS-level keyboard shortcuts such as "lock screen" that cause
57 // focus to switch to another application. If any modifier keys are held that
58 // are not indicated as active on |event|, release all keys.
59 void ReleaseAllIfModifiersStuck(const pp::InputEvent& event);
61 // Receives input events generated from PPAPI input.
62 protocol::InputStub* input_stub_;
64 // Tracks input events to manage auto-release in ReleaseAllIfModifiersStuck.
65 protocol::InputEventTracker* input_tracker_;
67 // True if the plugin has focus.
68 bool has_focus_;
70 // True if the plugin should respond to mouse input even if it does not have
71 // keyboard focus.
72 bool send_mouse_input_when_unfocused_;
74 // True if the plugin should include mouse move deltas, in addition to
75 // absolute position information, in mouse events.
76 bool send_mouse_move_deltas_;
78 // Accumulated sub-pixel and sub-tick deltas from wheel events.
79 float wheel_delta_x_;
80 float wheel_delta_y_;
81 float wheel_ticks_x_;
82 float wheel_ticks_y_;
84 // Whether or not to check for stuck modifier keys on keyboard input events.
85 bool detect_stuck_modifiers_;
87 DISALLOW_COPY_AND_ASSIGN(PepperInputHandler);
90 } // namespace remoting
92 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_