OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 __PLATFORM_WINDOW_MANAGER_MOTION_EVENT_COALESCER_H__ | 5 #ifndef WINDOW_MANAGER_MOTION_EVENT_COALESCER_H_ |
6 #define __PLATFORM_WINDOW_MANAGER_MOTION_EVENT_COALESCER_H__ | 6 #define WINDOW_MANAGER_MOTION_EVENT_COALESCER_H_ |
7 | 7 |
8 #include <glib.h> // for gboolean and gint | 8 #include <glib.h> // for gboolean and gint |
9 | 9 |
10 #include <chromeos/callback.h> | 10 #include <chromeos/callback.h> |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace window_manager { |
14 | 14 |
15 // Rate-limits how quickly motion events are processed by saving them as | 15 // Rate-limits how quickly motion events are processed by saving them as |
16 // they're generated and then periodically invoking a callback (but only if | 16 // they're generated and then periodically invoking a callback (but only if |
17 // new motion events have been received). | 17 // new motion events have been received). |
18 class MotionEventCoalescer { | 18 class MotionEventCoalescer { |
19 public: | 19 public: |
20 // The constructor takes ownership of 'cb'. | 20 // The constructor takes ownership of 'cb'. |
21 MotionEventCoalescer(Closure* cb, int timeout_ms); | 21 MotionEventCoalescer(chromeos::Closure* cb, int timeout_ms); |
22 ~MotionEventCoalescer(); | 22 ~MotionEventCoalescer(); |
23 | 23 |
24 int x() const { return x_; } | 24 int x() const { return x_; } |
25 int y() const { return y_; } | 25 int y() const { return y_; } |
26 | 26 |
27 // Start or stop the timer. | 27 // Start or stop the timer. |
28 void Start(); | 28 void Start(); |
29 void Stop(); | 29 void Stop(); |
30 | 30 |
31 // Is the timer currently running? | 31 // Is the timer currently running? |
(...skipping 29 matching lines...) Expand all Loading... |
61 bool have_queued_position_; | 61 bool have_queued_position_; |
62 | 62 |
63 // The most-recently-received position. | 63 // The most-recently-received position. |
64 int x_; | 64 int x_; |
65 int y_; | 65 int y_; |
66 | 66 |
67 // Callback that gets periodically invoked when there's a new position to | 67 // Callback that gets periodically invoked when there's a new position to |
68 // handle. | 68 // handle. |
69 // TODO: When we're using a callback library that supports parameters, we | 69 // TODO: When we're using a callback library that supports parameters, we |
70 // should just pass the position directly to the callback. | 70 // should just pass the position directly to the callback. |
71 scoped_ptr<Closure> cb_; | 71 scoped_ptr<chromeos::Closure> cb_; |
72 }; | 72 }; |
73 | 73 |
74 } // namespace chromeos | 74 } // namespace window_manager |
75 | 75 |
76 #endif | 76 #endif |
OLD | NEW |