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

Side by Side Diff: src/platform/power_manager/xidle.cc

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, 9 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 unified diff | Download patch
« no previous file with comments | « src/platform/power_manager/xidle.h ('k') | src/platform/power_manager/xidle-example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "power_manager/xidle.h"
6 #include <X11/extensions/scrnsaver.h>
7 #include <X11/Xlib.h>
8
9 namespace chromeos {
10
11 XIdle::XIdle() {
12 display_ = XOpenDisplay(NULL);
13 info_ = XScreenSaverAllocInfo();
14 valid_ = display_ &&
15 XScreenSaverQueryExtension(display_, &event_base_, &error_base_);
16 }
17
18 XIdle::~XIdle() {
19 if (info_)
20 XFree(info_);
21 if (display_)
22 XCloseDisplay(display_);
23 }
24
25 bool XIdle::getIdleTime(uint64 *idle) {
26 if (valid_ &&
27 XScreenSaverQueryInfo(display_, DefaultRootWindow(display_), info_)) {
28 *idle = info_->idle;
29 return true;
30 }
31 return false;
32 }
33
34 } // namespace chromeos
OLDNEW
« no previous file with comments | « src/platform/power_manager/xidle.h ('k') | src/platform/power_manager/xidle-example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698