Spark should capture keyboard event out of Spark for idle

org.jivesoftware.sparkimpl.plugin.idle.UserIdlePlugin .

This Plugin can’t capture keyboard event when I am at other application (eg. Word) . So if I use other application for a long time and only use keyboard, Spark will be idle (away), but I am not away !

This problem does not appear in MSN, etc.

UserIdlePlugin use global EventQueue capture KeyEvent, this is only useful when current focus on Spark.

I know Java can’t capture low level keyboard event unless use native method.

I found use JNA(Java Native Access, https://jna.dev.java.net/ ) can achieve. For examples, on Windows, implements a LowLevelKeyboardProc and set this hook in system.

Attachment is a patch for UserIdlePlugin in trunk which can capture system key event on Win32. This use jna’s lib (jna.jar & platform.jar ) .download link : https://jna.dev.java.net/servlets/ProjectDocumentList?folderID=12329&expandFolde r=12329&folderID=0 . On other os, jna does not seem to provide support.
update.diff.zip (1467 Bytes)

What version of Spark are you using? What about the latest RC1 version? I think there was a ticket for this in the bug tracker and it may be already fixed or will be fixed in the future.

In current trunk, not yet fixed. The only way is that use native hook, Java not support this.

are you certain because I’m not having any issues with my idle status - at least not that i have noticed. I use spark about 8hrs a day every day.

This is not an obvious problem. Only when you use another application, and Do not touch the mouse.

Yes. You are right. And here’s a ticket i have filed more than a year ago SPARK-1068. I usually use big idle timeout so i’m not noticing this issue. Can you attach a diff patch file for the source, instead of the compiled java file?

I have uploaded a diff patch file for UserIdlePlugin.java, and it needs jna libraries.

This is only useful in Windows at present :

If (isWindows) keyhook; else addGlobalListener for old behaviour

Have attached your patch. Not sure about jna libraries though. Should i attach them too somehow or they should only be imported or such?

Only add these two jar(jna.jar & platform.jar ) in classpath. On my computer( Windows XP and 7 ), it’s ok.

worked great on my system - just need to know the proper protocol for adding new jars…etc

Also - getting some help in testing would be great, but initial build/run worked as desired.

I may have a fairly large unit test for you here soon. This sounds like the issue my agents are seeing when using Fastpath through the day. It’s Repair/Sales Internal Callcenter support, so lots of going back and forth between many applications, and most are alt-tabbers by now. So this might resolve the issue.

They are reporting sporatic freeze/unable to type in spark windows and unable to interact with a toaster popup.

I thought it was just a client hardware issues.

Try the latest nightly on http://bamboo.igniterealtime.org/browse/SPARK-INSTALL4J-188/artifact/Install4j

We have licensed the useridle plugin as LGPL and included the jna & plattform.jar.

Since several libs in Spark are LGPL or GPL, we have to cope with the Apache-(L)GPL issue. Actually, we are not using LGPL code in the Spark core. We are considering (that is cstux, myself and the dev team) the LGPL parts to be plugins to Spark with a different license. The same applies actually to Openfire