Mercurial > pidgin.yaz
comparison src/idle.c @ 3905:3e508dd31b76
[gaim-migrate @ 4058]
IdleTracker
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 05 Nov 2002 22:34:05 +0000 |
parents | 6b0cb60162f4 |
children | 511c2b63caa4 |
comparison
equal
deleted
inserted
replaced
3904:98ede8f38be6 | 3905:3e508dd31b76 |
---|---|
25 #include <time.h> | 25 #include <time.h> |
26 #include <stdio.h> | 26 #include <stdio.h> |
27 #include <unistd.h> | 27 #include <unistd.h> |
28 | 28 |
29 #ifdef USE_SCREENSAVER | 29 #ifdef USE_SCREENSAVER |
30 #ifndef _WIN32 | |
30 #include <X11/Xlib.h> | 31 #include <X11/Xlib.h> |
31 #include <X11/Xutil.h> | 32 #include <X11/Xutil.h> |
32 #include <X11/extensions/scrnsaver.h> | 33 #include <X11/extensions/scrnsaver.h> |
33 #include <gdk/gdkx.h> | 34 #include <gdk/gdkx.h> |
35 #else | |
36 #include "IdleTracker.h" | |
37 #endif | |
34 #endif /* USE_SCREENSAVER */ | 38 #endif /* USE_SCREENSAVER */ |
35 | 39 |
36 #include "multi.h" | 40 #include "multi.h" |
37 #include "gaim.h" | 41 #include "gaim.h" |
38 #include "prpl.h" | 42 #include "prpl.h" |
41 gint check_idle(gpointer data) | 45 gint check_idle(gpointer data) |
42 { | 46 { |
43 struct gaim_connection *gc = data; | 47 struct gaim_connection *gc = data; |
44 time_t t; | 48 time_t t; |
45 #ifdef USE_SCREENSAVER | 49 #ifdef USE_SCREENSAVER |
50 #ifndef _WIN32 | |
46 static XScreenSaverInfo *mit_info = NULL; | 51 static XScreenSaverInfo *mit_info = NULL; |
52 #endif | |
47 #endif | 53 #endif |
48 time_t idle_time; | 54 time_t idle_time; |
49 | 55 |
50 /* Not idle, really... :) */ | 56 /* Not idle, really... :) */ |
51 update_idle_times(); | 57 update_idle_times(); |
55 time(&t); | 61 time(&t); |
56 | 62 |
57 | 63 |
58 #ifdef USE_SCREENSAVER | 64 #ifdef USE_SCREENSAVER |
59 if (report_idle == IDLE_SCREENSAVER) { | 65 if (report_idle == IDLE_SCREENSAVER) { |
66 #ifndef _WIN32 | |
60 int event_base, error_base; | 67 int event_base, error_base; |
61 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) { | 68 if (XScreenSaverQueryExtension(GDK_DISPLAY(), &event_base, &error_base)) { |
62 if (mit_info == NULL) { | 69 if (mit_info == NULL) { |
63 mit_info = XScreenSaverAllocInfo(); | 70 mit_info = XScreenSaverAllocInfo(); |
64 } | 71 } |
65 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info); | 72 XScreenSaverQueryInfo(GDK_DISPLAY(), GDK_ROOT_WINDOW(), mit_info); |
66 idle_time = (mit_info->idle) / 1000; | 73 idle_time = (mit_info->idle) / 1000; |
67 } else | 74 } else |
68 idle_time = 0; | 75 idle_time = 0; |
76 #else | |
77 /* IdleTracker monitors usage of all other apps by setting a hook function */ | |
78 idle_time = (GetTickCount() - IdleTrackerGetLastTickCount()) / 1000; | |
79 #endif | |
69 } else | 80 } else |
70 #endif /* USE_SCREENSAVER */ | 81 #endif /* USE_SCREENSAVER */ |
71 idle_time = t - gc->lastsent; | 82 idle_time = t - gc->lastsent; |
72 | 83 |
73 if ((away_options & OPT_AWAY_AUTO) && (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) { | 84 if ((away_options & OPT_AWAY_AUTO) && (idle_time > (60 * auto_away)) && (!gc->is_auto_away)) { |