comparison src/idle.c @ 1028:e4147c8604cc

[gaim-migrate @ 1038] This is a little more efficient. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 26 Oct 2000 11:48:42 +0000
parents a375efb2884e
children 740c6f933fe0
comparison
equal deleted inserted replaced
1027:a375efb2884e 1028:e4147c8604cc
40 gint check_idle(struct gaim_connection *gc) 40 gint check_idle(struct gaim_connection *gc)
41 { 41 {
42 time_t t; 42 time_t t;
43 #ifdef USE_SCREENSAVER 43 #ifdef USE_SCREENSAVER
44 static XScreenSaverInfo *mit_info = NULL; 44 static XScreenSaverInfo *mit_info = NULL;
45 Display *d; 45 static Display *d = NULL;
46 time_t idle_time; 46 time_t idle_time;
47 #endif 47 #endif
48 48
49 /* Not idle, really... :) */ 49 /* Not idle, really... :) */
50 update_all_buddies(); 50 update_all_buddies();
62 } 62 }
63 */ 63 */
64 64
65 #ifdef USE_SCREENSAVER 65 #ifdef USE_SCREENSAVER
66 if (report_idle == IDLE_SCREENSAVER) { 66 if (report_idle == IDLE_SCREENSAVER) {
67 d = XOpenDisplay((char *)NULL); 67 if (!d)
68 d = XOpenDisplay((char *)NULL);
68 if (mit_info == NULL) { 69 if (mit_info == NULL) {
69 mit_info = XScreenSaverAllocInfo (); 70 mit_info = XScreenSaverAllocInfo ();
70 } 71 }
71 XScreenSaverQueryInfo (d, DefaultRootWindow(d), mit_info); 72 XScreenSaverQueryInfo (d, DefaultRootWindow(d), mit_info);
72 idle_time = (mit_info->idle)/1000; 73 idle_time = (mit_info->idle)/1000;
73 XCloseDisplay(d);
74 } else 74 } else
75 #endif /* USE_SCREENSAVER */ 75 #endif /* USE_SCREENSAVER */
76 idle_time = t - gc->lastsent; 76 idle_time = t - gc->lastsent;
77 77
78 if (idle_time > 600) { /* 10 minutes! */ 78 if (idle_time > 600) { /* 10 minutes! */