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

Side by Side Diff: chrome/browser/idle_query_linux.cc

Issue 7015007: Use GetXDisplay() instead of XOpenDisplay() in IdleQueryLinux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/idle_query_linux.h" 5 #include "chrome/browser/idle_query_linux.h"
6 6
7 #include <X11/Xlib.h>
8 #include <X11/extensions/scrnsaver.h> 7 #include <X11/extensions/scrnsaver.h>
8 #include "ui/base/x/x11_util.h"
9 9
10 namespace browser { 10 namespace browser {
11 11
12 class IdleData { 12 class IdleData {
13 public: 13 public:
14 IdleData() { 14 IdleData() {
15 int event_base; 15 int event_base;
16 int error_base; 16 int error_base;
17 display = XOpenDisplay(NULL); 17 if (XScreenSaverQueryExtension(ui::GetXDisplay(), &event_base,
18 if (XScreenSaverQueryExtension(display, &event_base, &error_base)) { 18 &error_base)) {
19 mit_info = XScreenSaverAllocInfo(); 19 mit_info = XScreenSaverAllocInfo();
20 } else { 20 } else {
21 mit_info = NULL; 21 mit_info = NULL;
22 } 22 }
23 } 23 }
24 24
25 ~IdleData() { 25 ~IdleData() {
26 if (display) {
27 XCloseDisplay(display);
28 display = NULL;
29 }
30 if (mit_info) 26 if (mit_info)
31 XFree(mit_info); 27 XFree(mit_info);
32 } 28 }
33 29
34 XScreenSaverInfo *mit_info; 30 XScreenSaverInfo *mit_info;
35 Display *display;
36 }; 31 };
37 32
38 IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {} 33 IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {}
39 34
40 IdleQueryLinux::~IdleQueryLinux() {} 35 IdleQueryLinux::~IdleQueryLinux() {}
41 36
42 int IdleQueryLinux::IdleTime() { 37 int IdleQueryLinux::IdleTime() {
43 if (!idle_data_->mit_info || !idle_data_->display) 38 if (!idle_data_->mit_info)
44 return 0; 39 return 0;
45 40
46 if (XScreenSaverQueryInfo(idle_data_->display, 41 if (XScreenSaverQueryInfo(ui::GetXDisplay(),
47 RootWindow(idle_data_->display, 0), 42 RootWindow(ui::GetXDisplay(), 0),
48 idle_data_->mit_info)) { 43 idle_data_->mit_info)) {
49 return (idle_data_->mit_info->idle) / 1000; 44 return (idle_data_->mit_info->idle) / 1000;
50 } else { 45 } else {
51 return 0; 46 return 0;
52 } 47 }
53 } 48 }
54 49
55 } // namespace browser 50 } // namespace browser
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698