Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 08-20-2009, 12:35 AM   #1
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
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);
    }
}
I just can't figure out why do these x apps can't respond to iLiad button event. Does anybody have an idea how to solve or trace the problem?

Last edited by ericshliao; 08-20-2009 at 12:38 AM.
ericshliao is offline   Reply With Quote
Old 08-21-2009, 03:17 AM   #2
Max
Connoisseur
Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.
 
Max's Avatar
 
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:

http://www.mobileread.com/forums/sho...hlight=wmclass
http://forum.irexnet.com/viewtopic.php?t=1110
Max is offline   Reply With Quote
 
Enthusiast
Old 08-21-2009, 05:40 AM   #3
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
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.
ericshliao is offline   Reply With Quote
Old 08-21-2009, 05:45 AM   #4
Max
Connoisseur
Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.Max has a complete set of Star Wars action figures.
 
Max's Avatar
 
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.
Max is offline   Reply With Quote
Old 08-21-2009, 08:46 PM   #5
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Quote:
Originally Posted by Max View Post
If you are launching the program from a shell script remember that the class and title of the windows should be sh.
Yes, I know this. Thanx.
For GTK+ based app, I know how to set WM_CLASS, but for QT app, I don't find any proper funtion to do the task.
ericshliao is offline   Reply With Quote
Old 08-30-2009, 12:44 AM   #6
hansel
JSR FFD2
hansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheesehansel can extract oil from cheese
 
hansel's Avatar
 
Posts: 305
Karma: 1045
Join Date: Aug 2008
Location: Rotterdam, Netherlands, Europe, Sol 3
Device: iliad
Hi,

Just back from holidays...

Quote:
Originally Posted by ericshliao View Post
I know how to set WM_CLASS, but for QT app, I don't find any proper funtion to do the task.
You can set/get it by calling Xlib functions directly

http://tronche.com/gui/x/xlib/ICC/cl...ClassHint.html
hansel is offline   Reply With Quote
Old 08-30-2009, 03:21 AM   #7
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
Karma: 687
Join Date: Nov 2007
Device: Dell X51v; iLiad v2
Ha! Thanx. I've never thought of this approach.
ericshliao is offline   Reply With Quote
Old 08-30-2009, 06:52 AM   #8
ericshliao
Guru
ericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enoughericshliao will become famous soon enough
 
Posts: 974
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
ericshliao is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 10:30 PM.


MobileRead.com is a privately owned, operated and funded community.