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

Unified Diff: chrome/browser/sync/engine/idle_query_linux.cc

Issue 553051: Add support for UserIdleTime to Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 | « chrome/browser/sync/engine/idle_query_linux.h ('k') | chrome/browser/sync/engine/syncer_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/idle_query_linux.cc
===================================================================
--- chrome/browser/sync/engine/idle_query_linux.cc (revision 0)
+++ chrome/browser/sync/engine/idle_query_linux.cc (revision 0)
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#include "chrome/browser/sync/engine/idle_query_linux.h"
+
+#include <X11/Xlib.h>
+#include <X11/extensions/scrnsaver.h>
William Hesse 2010/01/27 16:17:17 I'm not sure that we have this include file listed
+
+namespace browser_sync {
+
+class IdleData {
+ public:
+ IdleData() {
+ int event_base;
+ int error_base;
+ display = XOpenDisplay(NULL);
+ if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
+ mit_info = XScreenSaverAllocInfo();
+ } else {
+ mit_info = NULL;
+ }
+ }
+
+ ~IdleData() {
+ if (display) {
+ XCloseDisplay(display);
+ display = NULL;
+ }
+ if (mit_info) {
+ XFree(mit_info);
+ }
+ }
+
+ XScreenSaverInfo *mit_info;
+ Display *display;
+};
+
+IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {
+}
+
+IdleQueryLinux::~IdleQueryLinux() {
+}
+
+int IdleQueryLinux::IdleTime() {
+ if (!idle_data_->mit_info || !idle_data_->display) {
+ return 0;
+ }
+
+ if (XScreenSaverQueryInfo(idle_data_->display,
+ RootWindow(idle_data_->display, 0),
+ idle_data_->mit_info)) {
+ return (idle_data_->mit_info->idle) / 1000;
+ } else {
+ return 0;
+ }
+}
+} // namespace browser_sync
Property changes on: chrome/browser/sync/engine/idle_query_linux.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/sync/engine/idle_query_linux.h ('k') | chrome/browser/sync/engine/syncer_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698