Index: remoting/client/plugin/pepper_input_handler.h |
diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h |
index 0e63e0f10e90471edd0bc016d08f82bd2e36c9ec..ba4d2caf2033cb1467badf426cc2f935549d6f0c 100644 |
--- a/remoting/client/plugin/pepper_input_handler.h |
+++ b/remoting/client/plugin/pepper_input_handler.h |
@@ -6,10 +6,16 @@ |
#define REMOTING_CLIENT_PLUGIN_PEPPER_INPUT_HANDLER_H_ |
#include "base/compiler_specific.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "ppapi/cpp/mouse_lock.h" |
+#include "ppapi/cpp/point.h" |
+#include "ppapi/utility/completion_callback_factory.h" |
#include "remoting/protocol/input_stub.h" |
namespace pp { |
+class ImageData; |
class InputEvent; |
+class Instance; |
} // namespace pp |
namespace remoting { |
@@ -18,16 +24,70 @@ namespace protocol { |
class InputStub; |
} // namespace protocol |
-class PepperInputHandler { |
+class PepperInputHandler : public pp::MouseLock { |
public: |
- explicit PepperInputHandler(protocol::InputStub* input_stub); |
+ // |instance| must outlive |this|. |
+ PepperInputHandler(pp::Instance* instance, protocol::InputStub* input_stub); |
virtual ~PepperInputHandler(); |
bool HandleInputEvent(const pp::InputEvent& event); |
+ // Enables locking the mouse when the host sets a completely transparent mouse |
+ // cursor. |
+ void AllowMouseLock(); |
+ |
+ // Called when the plugin receives or loses focus. |
+ void DidChangeFocus(bool has_focus); |
+ |
+ // Sets the mouse cursor image. Passing NULL image will lock the mouse if |
+ // mouse lock is enabled. |
+ void SetMouseCursor(scoped_ptr<pp::ImageData> image, |
+ const pp::Point& hotspot); |
+ |
private: |
+ // pp::MouseLock interface. |
+ virtual void MouseLockLost() OVERRIDE; |
+ |
+ // Requests the browser to lock the mouse and hides the cursor. |
+ void RequestMouseLock(); |
+ |
+ // Requests the browser to cancel mouse lock and restores the cursor once |
+ // the lock is gone. |
+ void CancelMouseLock(); |
+ |
+ // Applies |cursor_image_| as the custom pointer or uses the standard arrow |
+ // pointer if |cursor_image_| is not available. |
+ void UpdateMouseCursor(); |
+ |
+ // Handles completion of the mouse lock request issued by RequestMouseLock(). |
+ void OnMouseLocked(int error); |
+ |
+ pp::Instance* instance_; |
protocol::InputStub* input_stub_; |
+ pp::CompletionCallbackFactory<PepperInputHandler> callback_factory_; |
+ |
+ // Custom cursor image sent by the host. |cursor_image_| is set to NULL when |
+ // the cursor image is completely transparent. This can be interpreted as |
+ // a mouse lock request if enabled by the webapp. |
+ scoped_ptr<pp::ImageData> cursor_image_; |
+ |
+ // Hot spot for |cursor_image_|. |
+ pp::Point cursor_hotspot_; |
+ |
+ // True if the plugin has focus. |
+ bool has_focus_; |
+ |
+ enum MouseLockState { |
Wez
2013/09/07 01:11:25
nit: This belongs at the top of the private sectio
alexeypa (please no reviews)
2013/09/09 18:29:46
Done.
|
+ MouseLockDisallowed, |
+ MouseLockOff, |
+ MouseLockRequestPending, |
+ MouseLockOn, |
+ MouseLockCancelling |
+ }; |
+ |
+ MouseLockState mouse_lock_state_; |
+ |
// Accumulated sub-pixel and sub-tick deltas from wheel events. |
float wheel_delta_x_; |
float wheel_delta_y_; |