Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Unified Diff: src/platform/power_manager/xidle.h

Issue 652147: Add xidle library to power_manager for testing how long the user has been idle (Closed)
Patch Set: Fix issues pointed out by rtc Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/power_manager/testrunner.cc ('k') | src/platform/power_manager/xidle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/power_manager/xidle.h
diff --git a/src/platform/power_manager/xidle.h b/src/platform/power_manager/xidle.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe3825677356ab12d064f858074457a6ea8f12de
--- /dev/null
+++ b/src/platform/power_manager/xidle.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SRC_PLATFORM_POWER_MANAGER_XIDLE_H_
+#define SRC_PLATFORM_POWER_MANAGER_XIDLE_H_
+
+#include <X11/extensions/scrnsaver.h>
+#include <X11/Xlib.h>
+#include "base/basictypes.h"
+
+namespace chromeos {
+
+// \brief Connect to the local X Server and determine how long the user has
+// been idle, in milliseconds.
+//
+// Creating a new XIdle object connects to the local X Server. When the object
+// is destroyed, the connection is also destroyed.
+//
+// \example
+// chromeos::XIdle idle;
+// uint64 idleTime;
+// if (idle.getIdleTime(&idleTime))
+// std::cout << "User has been idle for " << idleTime << " milliseconds\n";
+// \end_example
+
+class XIdle {
+ public:
+ XIdle();
+ ~XIdle();
+
+ // Return how long the X Server has been idle, in milliseconds.
+ // If success, return true; otherwise return false.
+ bool getIdleTime(uint64 *idle);
+ private:
+ Display *display_;
+ XScreenSaverInfo *info_;
+ int event_base_, error_base_;
+ bool valid_;
+ DISALLOW_COPY_AND_ASSIGN(XIdle);
+};
+
+} // namespace chromeos
+
+#endif // SRC_PLATFORM_POWER_MANAGER_XIDLE_H_
« no previous file with comments | « src/platform/power_manager/testrunner.cc ('k') | src/platform/power_manager/xidle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698