PDA

View Full Version : Discussion about developing an onscreen keyboard in Qt



montylee
2nd January 2009, 09:38
I want to make a small Qt application which will show an onscreen keyboard with 2-3 keys only. When i press a button on the on-screen keyboard using mouse, the corresponding key event should be sent to the active window. Active window in this case should not be the Qt application but the last active window on which the user clicked.

An example of the above description can be found by running the Gnome on-screen keyboard i.e. GoK (http://www.gok.ca/).

So, if the user has a text editor open in the background, he should be able to send keystrokes to the text editor by clicking on the onscreen keyboard application made in Qt. The onscreen keyboard should be visible at all times and should stay on top of other applications.

Now, i don't know how to send events to the other application from Qt application i.e. how to make Qt application as an overlay application so that it stays in view all the time (similar to GoK) and sends events to other applications.

I searched on the net and found that GoK uses AT SPI for sending key events but it might not be useful in my case as i don't want dependency on any window manager and AT SPI seems to be dependent on GNOME.

Also, i think i can send events to other application using XSendEvent API of xwindows but i don't want X11 dependency either as my onscreen keyboard will run on an embedded device without X11.

I found that i might be able to use DBus as an alternative to AT SPI but i don't know for sure.

Please help me if anybody has an idea about it. I know how to send events to the linux applications by writing to the device file (/dev/input/event*) but i have no idea how to send events to other application without using X11 APIs.

wysota
2nd January 2009, 10:24
I don't think DBus itself will allow you to send events to an arbitrary application. In my opinion you should go with X11 and have an ifdef block in your code to handle special cases and those probably depend on the "windowing system" that is running on the device. If you use Qtopia then there is a chance you can communicate with the layer but you have to check its API, maybe there is a way to do what you want.

montylee
2nd January 2009, 19:36
ya, i can put the X11 code inside ifdef but i want to know what solution i can use in case X11 is not present.
Not sure if QTopia will have any specific APIs for this as this requirement is valid for a normal desktop as well, so even Qt should have support for it.
I think we can also use Qt's sendEvent or postEvent to send events to other windows but i am not sure if using these APIs we can send events to other applications.

and how can we show an overlay window which always stays on top but still allows focus to be on other applications (just like GoK does)?

wysota
2nd January 2009, 19:54
Qt uses X11 so it doesn't need any support for non-X11 environments. Qtopia doesn't use X11 (or at least it doesn't have to), it uses its own integrated pseudo-window manager, so the window manager might have support for transfering events into another application. At worst you can probably use QCopChannel for that although I guess the other application would need to be aware of it (like with D-Bus).

montylee
2nd January 2009, 20:21
ya, Qtopia uses its own window manager. I am not sure whether to use Qtopia or Qt/Embedded. Does Qt/Embedded has its own window manager too?

Basically the on-screen keyboard will be used for opera browser, so when user clicks buttons on the on-screen keyboard it should be propagated to opera.

wysota
2nd January 2009, 20:24
Qt/Embedded and Qtopia are/used to be the same thing. Now we have Qt Embedded which is a "middle" layer for embedded systems (including the wm) and Qt Extended (which used to be called Qtopia Core, I think) which is an "upper" layer for embedded systems that contains things like GSM support, text messages, contacts, etc.

Doesn't Opera need X11 (and Qt3 by the way)?

montylee
2nd January 2009, 21:09
thanks for the info regarding Qtopia and Qt/Embedded.
Opera does need Qt3 and we have Qt3 libraries on the embedded hardware so opera runs fine on it. I am not sure if Opera needs X11, it shouldn't since our older hardware doesn't have X11.

I still don't know what to do for transfering events to other applications.