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

Side by Side Diff: src/platform/power_manager/xidle-example.cc

Issue 1035001: Fix off-by-one bug for the negative transition in XIdle::AddIdleTimeout, which (Closed)
Patch Set: Update to address Dan's comments Created 10 years, 9 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
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 <inttypes.h> 5 #include <inttypes.h>
6 #include <cstdio> 6 #include <cstdio>
7 #include "power_manager/xidle.h" 7 #include "power_manager/xidle.h"
8 #include "base/logging.h"
Daniel Erat 2010/03/16 21:40:01 alphabetize these?
8 9
9 int main(int argc, char *argv[]) { 10 int main(int argc, char *argv[]) {
10 power_manager::XIdle idle; 11 power_manager::XIdle idle;
11 idle.Init(); 12 Display* display = XOpenDisplay(NULL);
Daniel Erat 2010/03/16 21:40:01 it'd be good to CHECK(display) here; that's what X
13 bool init = idle.Init(display);
14 CHECK(init);
12 idle.AddIdleTimeout(2000); 15 idle.AddIdleTimeout(2000);
13 idle.AddIdleTimeout(5000); 16 idle.AddIdleTimeout(5000);
14 bool is_idle; 17 bool is_idle;
15 int64 idle_time; 18 int64 idle_time;
16 while (idle.Monitor(&is_idle, &idle_time)) { 19 while (idle.Monitor(&is_idle, &idle_time)) {
17 if (is_idle) 20 if (is_idle)
18 printf("User has been idle for %" PRIi64 " milliseconds\n", idle_time); 21 printf("User has been idle for %" PRIi64 " milliseconds\n", idle_time);
19 else 22 else
20 printf("User is active\n"); 23 printf("User is active\n");
21 } 24 }
25 XCloseDisplay(display);
22 return 0; 26 return 0;
23 } 27 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698