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 #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 |
OLD | NEW |