OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SRC_PLATFORM_POWER_MANAGER_XIDLE_H_ |
| 6 #define SRC_PLATFORM_POWER_MANAGER_XIDLE_H_ |
| 7 |
| 8 #include <X11/extensions/scrnsaver.h> |
| 9 #include <X11/Xlib.h> |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 namespace chromeos { |
| 13 |
| 14 // \brief Connect to the local X Server and determine how long the user has |
| 15 // been idle, in milliseconds. |
| 16 // |
| 17 // Creating a new XIdle object connects to the local X Server. When the object |
| 18 // is destroyed, the connection is also destroyed. |
| 19 // |
| 20 // \example |
| 21 // chromeos::XIdle idle; |
| 22 // uint64 idleTime; |
| 23 // if (idle.getIdleTime(&idleTime)) |
| 24 // std::cout << "User has been idle for " << idleTime << " milliseconds\n"; |
| 25 // \end_example |
| 26 |
| 27 class XIdle { |
| 28 public: |
| 29 XIdle(); |
| 30 ~XIdle(); |
| 31 |
| 32 // Return how long the X Server has been idle, in milliseconds. |
| 33 // If success, return true; otherwise return false. |
| 34 bool getIdleTime(uint64 *idle); |
| 35 private: |
| 36 Display *display_; |
| 37 XScreenSaverInfo *info_; |
| 38 int event_base_, error_base_; |
| 39 bool valid_; |
| 40 DISALLOW_COPY_AND_ASSIGN(XIdle); |
| 41 }; |
| 42 |
| 43 } // namespace chromeos |
| 44 |
| 45 #endif // SRC_PLATFORM_POWER_MANAGER_XIDLE_H_ |
OLD | NEW |