OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "ppapi/cpp/instance_handle.h" |
9 | 10 |
10 /// @file | 11 /// @file |
11 /// This file defines the API for locking the target of mouse events to a | 12 /// This file defines the API for locking the target of mouse events to a |
12 /// specific module instance. | 13 /// specific module instance. |
13 | 14 |
14 namespace pp { | 15 namespace pp { |
15 | 16 |
16 class CompletionCallback; | 17 class CompletionCallback; |
17 class Instance; | |
18 | 18 |
19 /// This class allows you to associate the <code>PPP_MouseLock</code> and | 19 /// This class allows you to associate the <code>PPP_MouseLock</code> and |
20 /// <code>PPB_MouseLock</code> C-based interfaces with an object. It associates | 20 /// <code>PPB_MouseLock</code> C-based interfaces with an object. It associates |
21 /// itself with the given instance, and registers as the global handler for | 21 /// itself with the given instance, and registers as the global handler for |
22 /// handling the <code>PPP_MouseLock</code> interface that the browser calls. | 22 /// handling the <code>PPP_MouseLock</code> interface that the browser calls. |
23 /// | 23 /// |
24 /// You would typically use this class by inheritance on your instance or by | 24 /// You would typically use this class by inheritance on your instance or by |
25 /// composition. | 25 /// composition. |
26 /// | 26 /// |
27 /// <strong>Example (inheritance):</strong> | 27 /// <strong>Example (inheritance):</strong> |
(...skipping 15 matching lines...) Expand all Loading... |
43 /// MyInstance() : mouse_lock_(this) { | 43 /// MyInstance() : mouse_lock_(this) { |
44 /// } | 44 /// } |
45 /// | 45 /// |
46 /// MyMouseLock mouse_lock_; | 46 /// MyMouseLock mouse_lock_; |
47 /// }; | 47 /// }; |
48 /// </code> | 48 /// </code> |
49 class MouseLock { | 49 class MouseLock { |
50 public: | 50 public: |
51 /// A constructor for creating a <code>MouseLock</code>. | 51 /// A constructor for creating a <code>MouseLock</code>. |
52 /// | 52 /// |
53 /// @param[in] instance The instance that will own the new | 53 /// @param[in] instance The instance with which this resource will be |
54 /// <code>MouseLock</code>. | 54 /// associated. |
55 explicit MouseLock(Instance* instance); | 55 explicit MouseLock(const InstanceHandle& instance); |
56 | 56 |
57 /// Destructor. | 57 /// Destructor. |
58 virtual ~MouseLock(); | 58 virtual ~MouseLock(); |
59 | 59 |
60 /// PPP_MouseLock functions exposed as virtual functions for you to override. | 60 /// PPP_MouseLock functions exposed as virtual functions for you to override. |
61 virtual void MouseLockLost() = 0; | 61 virtual void MouseLockLost() = 0; |
62 | 62 |
63 /// LockMouse() requests the mouse to be locked. The browser will permit | 63 /// LockMouse() requests the mouse to be locked. The browser will permit |
64 /// mouse lock only while the tab is in fullscreen mode. | 64 /// mouse lock only while the tab is in fullscreen mode. |
65 /// | 65 /// |
(...skipping 17 matching lines...) Expand all Loading... |
83 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. | 83 /// @return An int32_t containing an error code from <code>pp_errors.h</code>. |
84 int32_t LockMouse(const CompletionCallback& cc); | 84 int32_t LockMouse(const CompletionCallback& cc); |
85 | 85 |
86 /// UnlockMouse causes the mouse to be unlocked, allowing it to track user | 86 /// UnlockMouse causes the mouse to be unlocked, allowing it to track user |
87 /// movement again. This is an asynchronous operation. The module instance | 87 /// movement again. This is an asynchronous operation. The module instance |
88 /// will be notified using the <code>PPP_MouseLock</code> interface when it | 88 /// will be notified using the <code>PPP_MouseLock</code> interface when it |
89 /// has lost the mouse lock. | 89 /// has lost the mouse lock. |
90 void UnlockMouse(); | 90 void UnlockMouse(); |
91 | 91 |
92 private: | 92 private: |
93 Instance* associated_instance_; | 93 InstanceHandle associated_instance_; |
94 }; | 94 }; |
95 | 95 |
96 } // namespace pp | 96 } // namespace pp |
97 | 97 |
98 #endif // PPAPI_CPP_MOUSE_LOCK_H_ | 98 #endif // PPAPI_CPP_MOUSE_LOCK_H_ |
OLD | NEW |