Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 PPAPI_CPP_MOUSE_LOCK_H_ | 5 #ifndef PPAPI_CPP_MOUSE_LOCK_H_ |
| 6 #define PPAPI_CPP_MOUSE_LOCK_H_ | 6 #define PPAPI_CPP_MOUSE_LOCK_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
| 9 | 9 |
| 10 /// @file | |
| 11 /// This file defines the API for locking the target of mouse events to a | |
| 12 /// specific module instance. | |
| 13 | |
| 10 namespace pp { | 14 namespace pp { |
| 11 | 15 |
| 12 class CompletionCallback; | 16 class CompletionCallback; |
| 13 class Instance; | 17 class Instance; |
| 14 | 18 |
| 15 // This class allows you to associate the PPP_MouseLock and PPB_MouseLock | 19 /// This class allows you to associate the <codee>PPP_MouseLock</code> and |
| 16 // C-based interfaces with an object. It associates itself with the given | 20 /// <code>PPB_MouseLock</code> C-based interfaces with an object. It associates |
| 17 // instance, and registers as the global handler for handling the PPP_MouseLock | 21 /// itself with the given instance, and registers as the global handler for |
| 18 // interface that the browser calls. | 22 /// handling the <code>PPP_MouseLock</code> interface that the browser calls. |
| 19 // | 23 /// |
| 20 // You would typically use this either via inheritance on your instance: | 24 /// You would typically implement this class using inheritance on your instance |
|
yzshen1
2011/12/21 23:04:14
nit: I think we usually use 'implement interface'
jond
2012/01/03 17:48:28
Done.
| |
| 21 // class MyInstance : public pp::Instance, public pp::MouseLock { | 25 /// or by composition. |
| 22 // class MyInstance() : pp::MouseLock(this) { | 26 /// |
| 23 // } | 27 /// <strong>Example (inheritance):</strong> |
| 24 // ... | 28 /// <code> |
| 25 // }; | 29 /// class MyInstance : public pp::Instance, public pp::MouseLock { |
| 26 // | 30 /// class MyInstance() : pp::MouseLock(this) { |
| 27 // or by composition: | 31 /// } |
| 28 // class MyMouseLock : public pp::MouseLock { | 32 /// ... |
| 29 // ... | 33 /// }; |
| 30 // }; | 34 /// </code> |
| 31 // | 35 /// |
| 32 // class MyInstance : public pp::Instance { | 36 /// <strong>Example (composition):</strong> |
| 33 // MyInstance() : mouse_lock_(this) { | 37 /// <code> |
| 34 // } | 38 /// class MyMouseLock : public pp::MouseLock { |
| 35 // | 39 /// ... |
| 36 // MyMouseLock mouse_lock_; | 40 /// }; |
| 37 // }; | 41 /// |
| 42 /// class MyInstance : public pp::Instance { | |
| 43 /// MyInstance() : mouse_lock_(this) { | |
| 44 /// } | |
| 45 /// | |
| 46 /// MyMouseLock mouse_lock_; | |
| 47 /// }; | |
| 48 /// </code> | |
| 38 class MouseLock { | 49 class MouseLock { |
| 39 public: | 50 public: |
| 51 /// A constructor for creating a <code>MouseLock</code>. | |
| 52 /// | |
| 53 /// @param[in] instance The instance that will own the new | |
| 54 /// <code>MouseLock</code>. | |
| 40 explicit MouseLock(Instance* instance); | 55 explicit MouseLock(Instance* instance); |
| 56 | |
| 57 /// Destructor. | |
|
yzshen1
2011/12/21 23:04:14
Comment like this (as well as the one for construc
jond
2012/01/03 17:48:28
Done.
| |
| 41 virtual ~MouseLock(); | 58 virtual ~MouseLock(); |
| 42 | 59 |
| 43 // PPP_MouseLock functions exposed as virtual functions for you to override. | 60 /// PPP_MouseLock functions exposed as virtual functions for you to override. |
| 44 virtual void MouseLockLost() = 0; | 61 virtual void MouseLockLost() = 0; |
| 45 | 62 |
| 46 // PPB_MouseLock functions for you to call. | 63 /// LockMouse() requests the mouse to be locked. The browser will permit |
| 64 /// mouse lock only while the tab is in fullscreen mode. | |
| 65 /// | |
| 66 /// While the mouse is locked, the cursor is implicitly hidden from the user. | |
| 67 /// Any movement of the mouse will generate a | |
| 68 /// <code>PP_INPUTEVENT_TYPE_MOUSEMOVE</code> event. The | |
| 69 /// <code>GetPosition()</code> function in <code>InputEvent()</code> | |
| 70 /// reports the last known mouse position just as mouse lock was | |
| 71 /// entered. The <code>GetMovement()</code> function provides relative | |
| 72 /// movement information indicating what the change in position of the mouse | |
| 73 /// would be had it not been locked. | |
| 74 /// | |
| 75 /// The browser may revoke the mouse lock for reasons including (but not | |
| 76 /// limited to) the user pressing the ESC key, the user activating another | |
| 77 /// program using a reserved keystroke (e.g. ALT+TAB), or some other system | |
| 78 /// event. | |
| 79 /// | |
| 80 /// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | |
| 81 /// completion. | |
| 82 /// | |
| 83 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
| 47 int32_t LockMouse(const CompletionCallback& cc); | 84 int32_t LockMouse(const CompletionCallback& cc); |
| 85 | |
| 86 /// UnlockMouse causes the mouse to be unlocked, allowing it to track user | |
| 87 /// movement again. This is an asynchronous operation. The module instance | |
| 88 /// will be notified using the <code>PPP_MouseLock</code> interface when it | |
| 89 /// has lost the mouse lock. | |
| 48 void UnlockMouse(); | 90 void UnlockMouse(); |
| 49 | 91 |
| 50 private: | 92 private: |
| 51 Instance* associated_instance_; | 93 Instance* associated_instance_; |
| 52 }; | 94 }; |
| 53 | 95 |
| 54 } // namespace pp | 96 } // namespace pp |
| 55 | 97 |
| 56 #endif // PPAPI_CPP_MOUSE_LOCK_H_ | 98 #endif // PPAPI_CPP_MOUSE_LOCK_H_ |
| OLD | NEW |