Date: Sat, 13 Jan 2007 19:25:17 +0100 From: Kurt Jaeger <pi@c0mplx.org> To: adam@ipwebdev.com Cc: perl@freebsd.org, krion@freebsd.org Subject: X11::IdleTime bug && fix Message-ID: <20070113182517.GA16611@home.c0mplx.org>
next in thread | raw e-mail | index | archive | help
Hi! I've recently tried the perl module X11::IdleTime and it seems to always report 4 seconds idle-time to me: hdog$ sleep 10; ./idle Your mouse and keyboard have been idle for 4 seconds. This seems strange. I checked the source and the following diff fixes a small bug with the sequence the mit_info struct is free()ed and used (and some usage bug of XScreenSaverQueryInfo()). Hope this helps. ------------ --- IdleTime.pm.orig Thu Feb 10 17:54:42 2005 +++ IdleTime.pm Sat Jan 13 19:19:35 2007 @@ -6,12 +6,13 @@ require Exporter; @ISA = qw(Exporter); @EXPORT = qw(GetIdleTime); -$VERSION = '0.01'; +$VERSION = '0.03'; use Inline ( C => 'DATA', VERSION => '0.03', NAME => 'X11::IdleTime', + INC => '-I/usr/X11R6/include/', LIBS => '-L/usr/X11R6/lib/ -lX11 -lXext -lXss', ); @@ -62,12 +63,22 @@ static XScreenSaverInfo *mit_info; Display *display; int screen; + Bool extavail; + XEvent myevent; + int event_base, error_base; mit_info = XScreenSaverAllocInfo(); - if((display=XOpenDisplay(NULL)) == NULL) { return(-1); } + if((display=XOpenDisplay(NULL)) == NULL) { return(-2); } screen = DefaultScreen(display); + + extavail = XScreenSaverQueryExtension(display, &event_base, + &error_base); + if ( extavail == False ) { + return(-1); + } + XScreenSaverQueryInfo(display, RootWindow(display,screen), mit_info); + idle_time = (mit_info->idle) / 1000; XFree(mit_info); XCloseDisplay(display); - idle_time = (mit_info->idle) / 1000; return idle_time; } -------------------- -- pi@c0mplx.org +49 171 3101372 13 years to go !
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070113182517.GA16611>