开发者

Capturing events in X11 even after the loss of focus

I am trying to develop an application which responds to multiple digital pens (IRIS Pens) so that if any of the pen writes on paper; I relay the output to a single screen. Thus making a multi-input whiteboard for myself.

In Ubuntu these pens are recognized as mouse and thus can be handled in a similar manner as mouse events are handled.

So now what I plan to do is to handle these events in C/C++ using XLib and pass these events to a Java Swing application using JNI callback. I am able to do this but when the X11 window looses focus no events are transferred to the Swing frame. I also tried to use the root window in X11 but it does not seem to work.

Any help would b开发者_JAVA技巧e really appreciated. Thanking you in advance.


How about maximizing the C/X11 window in front of the Java one, and making it transparent? You should be able to see the Java window while still focusing on the C/X11 one.

Since you are using Ubuntu, you can achieve this using the "Opacity, brightness and saturation" plugin for Compiz. It is in the compiz-plugins-main package, and you can activate it with Compiz Settings Manager (from the compizconfig-settings-manager package). When you activate the plugin, alt+wheel is bound by default to change the transparency of the focused window.


Try reading the mouse directly. I don't remember the exact location, but you should find it in something like '/dev/input/mouseX', where X is the number of your device, ranging from 0 to n-1 devices..

When you read the packet, your application should block until the mouse moves and then your read function will return a raw mouse packet which describes the delta (which is probably more useful then the screen coordinates, in your case) and the mouse button statuses.

The raw packet can be decoded as described here: http://www.computer-engineering.org/ps2mouse/


Create a modal dialog and set it to XmDIALOG_SYSTEM_MODAL (the actual name of the property depends on your toolkit: Motif, Gtk, Qt, ...). Dialogs like this block the whole display and can never loose focus.

The drawback is of course that you can't do anything else while this dialog is on the screen.

This entry in the X11 FAQ might help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜