Add ICU message format support
[chromium-blink-merge.git] / ui / base / idle / idle_query_x11.cc
blob1b1d5b5997e7559007f794d7e89d9b693b61b032
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 "ui/base/idle/idle_query_x11.h"
7 #include <X11/extensions/scrnsaver.h>
9 #include "ui/gfx/x/x11_types.h"
11 namespace ui {
13 class IdleData {
14 public:
15 IdleData() {
16 int event_base;
17 int error_base;
18 if (XScreenSaverQueryExtension(gfx::GetXDisplay(), &event_base,
19 &error_base)) {
20 mit_info.reset(XScreenSaverAllocInfo());
24 ~IdleData() {
27 gfx::XScopedPtr<XScreenSaverInfo> mit_info;
30 IdleQueryX11::IdleQueryX11() : idle_data_(new IdleData()) {}
32 IdleQueryX11::~IdleQueryX11() {}
34 int IdleQueryX11::IdleTime() {
35 if (!idle_data_->mit_info)
36 return 0;
38 if (XScreenSaverQueryInfo(gfx::GetXDisplay(),
39 RootWindow(gfx::GetXDisplay(), 0),
40 idle_data_->mit_info.get())) {
41 return (idle_data_->mit_info->idle) / 1000;
42 } else {
43 return 0;
47 } // namespace ui