Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / idle_query_x11.cc
blob845ec5b6a5117c02d28c812092b1008dc0412447
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/idle_query_x11.h"
7 #include <X11/extensions/scrnsaver.h>
8 #include "ui/gfx/x/x11_types.h"
10 namespace chrome {
12 class IdleData {
13 public:
14 IdleData() {
15 int event_base;
16 int error_base;
17 if (XScreenSaverQueryExtension(gfx::GetXDisplay(), &event_base,
18 &error_base)) {
19 mit_info = XScreenSaverAllocInfo();
20 } else {
21 mit_info = NULL;
25 ~IdleData() {
26 if (mit_info)
27 XFree(mit_info);
30 XScreenSaverInfo *mit_info;
33 IdleQueryX11::IdleQueryX11() : idle_data_(new IdleData()) {}
35 IdleQueryX11::~IdleQueryX11() {}
37 int IdleQueryX11::IdleTime() {
38 if (!idle_data_->mit_info)
39 return 0;
41 if (XScreenSaverQueryInfo(gfx::GetXDisplay(),
42 RootWindow(gfx::GetXDisplay(), 0),
43 idle_data_->mit_info)) {
44 return (idle_data_->mit_info->idle) / 1000;
45 } else {
46 return 0;
50 } // namespace chrome