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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium 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 #include "chrome/browser/sync/engine/idle_query_linux.h"
5
6 #include <X11/Xlib.h>
7 #include <X11/extensions/scrnsaver.h>
William Hesse 2010/01/27 16:17:17 I'm not sure that we have this include file listed
8
9 namespace browser_sync {
10
11 class IdleData {
12 public:
13 IdleData() {
14 int event_base;
15 int error_base;
16 display = XOpenDisplay(NULL);
17 if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
18 mit_info = XScreenSaverAllocInfo();
19 } else {
20 mit_info = NULL;
21 }
22 }
23
24 ~IdleData() {
25 if (display) {
26 XCloseDisplay(display);
27 display = NULL;
28 }
29 if (mit_info) {
30 XFree(mit_info);
31 }
32 }
33
34 XScreenSaverInfo *mit_info;
35 Display *display;
36 };
37
38 IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {
39 }
40
41 IdleQueryLinux::~IdleQueryLinux() {
42 }
43
44 int IdleQueryLinux::IdleTime() {
45 if (!idle_data_->mit_info || !idle_data_->display) {
46 return 0;
47 }
48
49 if (XScreenSaverQueryInfo(idle_data_->display,
50 RootWindow(idle_data_->display, 0),
51 idle_data_->mit_info)) {
52 return (idle_data_->mit_info->idle) / 1000;
53 } else {
54 return 0;
55 }
56 }
57 } // namespace browser_sync
OLDNEW
« 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