![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
non-GTK+ apps not getting button event from X
Based on my current experience, all GTK+ apps can respond to iLiad buttons without any problem. But I found that I can't make QT based app (djview4) and wxWidgets based app (xCHM) respond to iLiad button, even though I can control iLiad led flash and use touch-pen as mouse in these apps.
My current understanding is: Contentlister will grab all iLiad button-events by calling button driver. Then, a button-event will be translated to an X event and transferred to the foreground x-client using the following function in programManager.c: Code:
void pm_SendKey(KeySym keysym) { XKeyEvent xev; Display *display; Window window, root; int screen; display = gdk_x11_display_get_xdisplay(gdk_display_get_default()); root = gdk_x11_get_default_root_xwindow(); window = pm_getWinOnTop(); if (window == -1) { CL_ERRORPRINTF("Failed: no valid window found"); return; } if (window == g_myWin) { CL_PMPRINTF("ContentLister window 0x%x", (unsigned int)window); display = XOpenDisplay(NULL); screen = DefaultScreen(display); root = RootWindow(display, screen); } // create and send a keypress event followed by a keyrelease event xev.type = KeyPress; xev.display = display; xev.root = root; xev.window = window; xev.subwindow = None; xev.time = pm_fake_timestamp(); xev.x = 1; xev.y = 1; xev.x_root = 1; xev.y_root = 1; xev.same_screen = 1; xev.state = 0; xev.keycode = XKeysymToKeycode(display, keysym); // CL_ERRORPRINTF("Sending keypress...."); XSendEvent(xev.display, window, 1, KeyPressMask, (XEvent *) & xev); // We check to see if this is the UP key // so we don't send the release event for that, because it // can crash the contentLister with a BadWindow error (req.code 25) if ( keysym == GDK_F5 ) { CL_ERRORPRINTF("NOT Sending keyrelease for UP key...."); } else { // usleep(2000); // MvdW: this usleep doesn't seem to be nescessary xev.type = KeyRelease; xev.time = pm_fake_timestamp(); XSendEvent(xev.display, window, 1, KeyReleaseMask, (XEvent *) & xev); } //XSync(xev.display, 1); XSync(xev.display, FALSE); if (window == g_myWin) { CL_PMPRINTF("Before XCloseDisplay()"); XCloseDisplay(display); } } Last edited by ericshliao; 08-20-2009 at 12:38 AM. |
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() ![]() ![]() ![]() Posts: 79
Karma: 380
Join Date: Mar 2008
Location: Girona, Spain
Device: iLiad, DR1000s
|
As I understand, contentlister use the wmclass/name of the window to find it.
I don't know how to do it in QT based app and wxWidgets based app. Look this for more info: https://www.mobileread.com/forums/sho...hlight=wmclass http://forum.irexnet.com/viewtopic.php?t=1110 |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
Ah, I forgot to try this approach. Thanx for reminding me. I should not forget it.
![]() I remembered that I tried to set it in djview4 but still got no response when pushing page-flip button. Maybe I didn't do it corretly. I will try again. |
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() ![]() ![]() Posts: 79
Karma: 380
Join Date: Mar 2008
Location: Girona, Spain
Device: iLiad, DR1000s
|
If you are launching the program from a shell script remember that the class and title of the windows should be sh.
|
![]() |
![]() |
![]() |
#5 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
JSR FFD2
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
|
Hi,
Just back from holidays... Quote:
http://tronche.com/gui/x/xlib/ICC/cl...ClassHint.html |
|
![]() |
![]() |
![]() |
#7 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
![]() |
![]() |
![]() |
![]() |
#8 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() Posts: 976
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
|
It's so great! This approach works.
![]() Now LED and buttons on iLiad can be used in QT4 apps. I borrowed some code from trayicon_x11.cpp and made some modification. This is the code that I use in djview4 for iLiad: Code:
#include <X11/Xlib.h> #include <X11/Xutil.h> #include <QX11Info> Display *dsp = QX11Info::display(); WId leader = winId(); // set the class hint XClassHint classhint; classhint.res_name = (char*)"sh"; classhint.res_class = (char*)"sh"; XSetClassHint(dsp, leader, &classhint); // set the Window Manager hints XWMHints *hints; hints = XGetWMHints(dsp, leader); // init hints hints->flags = WindowGroupHint | IconWindowHint | StateHint; // set the window group hint hints->window_group = leader; // set the window hint hints->initial_state = WithdrawnState; // initial state //hints->icon_window = icon; // in WM, this should be winId() of separate widget hints->icon_x = 0; hints->icon_y = 0; XSetWMHints(dsp, leader, hints); // set the window hints for WM to use. XFree( hints ); //end setting WM hints |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is a gtk version possible? | frandavid100 | Calibre | 14 | 12-16-2008 03:09 PM |
iLiad Problems porting GTK apps | robinwatts | iRex Developer's Corner | 6 | 03-22-2008 06:19 AM |
iLiad Compiling GTK apps for iliad | rudysplif | iRex Developer's Corner | 3 | 03-17-2008 12:59 PM |
iLiad Changing the GTK+ Theme | yokos | iRex Developer's Corner | 0 | 02-20-2008 09:47 AM |
iLiad Need help getting started with gtk | tribble | iRex Developer's Corner | 4 | 06-05-2007 12:38 PM |