Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-10-2008, 09:39 AM   #1
robinwatts
Junior Member
robinwatts began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2008
Location: Oxfordshire, UK
Device: iRex Iliad
Problems porting GTK apps

Hi all,

I've just been given an iRex Iliad and told to port an app to it. I can't really say what the app is (commerical reasons etc), but suffice to say it works on many different mobile platforms already.

One of the targets for the build is desktop linux using GTK, so I figured it shouldn't be too hard to get up and running.

Sadly, I'm getting very strange results; sometimes the window appears, sometimes it doesn't. When it does appear, sometimes the window is empty, sometimes the contents of the window are shifted around the place.

I've produced a cutdown test app to show the problems I'm experiencing... any hints anyone can give would be gratefully received, cos I'm running out of ideas...

I'm using firmware 2.12, with a copy of the devkit I downloaded the other day. Other apps (such as Gargoyle and Dillo) seem to run fine, just not those I've built myself. Has anyone else experienced such problems?

I attach the text of main.c below, and I compile it using the following script:

Code:
#!/bin/sh

export PKG_CONFIG_PATH=/usr/local/arm/oe/arm-linux/lib/pkgconfig
arm-linux-gcc `pkg-config --cflags gtk+-2.0` main.c -o gtk-test `pkg-config --libs gtk+-2.0` -Wl,-rpath /usr/local/arm/oe/arm-linux/lib
arm-linux-strip gtk-test
Code:
#include "assert.h"

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#include <gdk/gdkx.h>

#define Alien_DisplayWidth 768
#define Alien_DisplayHeight 1024

static void destroy(GtkObject *object,
                    gpointer   data)
{
    gtk_main_quit();
}

int main(int argc, char *argv[])
{
    GtkWidget *topLevel;
    GtkWidget *vbox;
    GtkWidget *dArea = NULL;

    /* Start GTK */
    gtk_set_locale();
    gtk_init(&argc, &argv);

    /* Create a window, set it to full size, and hook up the destroy */
    topLevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_usize(topLevel,
                         Alien_DisplayWidth,
                         Alien_DisplayHeight);
    gtk_signal_connect(GTK_OBJECT(topLevel), "destroy",
                       GTK_SIGNAL_FUNC(destroy), NULL);

    gtk_widget_set_events(topLevel, GDK_EXPOSURE_MASK);

    /* Create a drawable area in that window */
    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(topLevel), vbox);
    dArea = gtk_drawing_area_new();
    gtk_drawing_area_size(GTK_DRAWING_AREA(dArea),
                          Alien_DisplayWidth,
                          Alien_DisplayHeight);
    gtk_box_pack_start(GTK_BOX(vbox), dArea, TRUE, TRUE, 0);

    /* Create the window */
    gtk_widget_realize(topLevel);
    gtk_widget_show_all(topLevel);

    /* Make a bitmap and fill the drawing area with it */
    {
	unsigned char *p;
	int x, y;
        unsigned char *rgbBitmap = calloc(Alien_DisplayWidth*Alien_DisplayHeight, 3);

        if(rgbBitmap == NULL)
        {
            printf("Failed to allocate temporary bitmap!\n");
            exit(1);
        }

        p = rgbBitmap;
        for(y = 0; y < Alien_DisplayHeight; y++)
        {
            for (x = 0; x < Alien_DisplayWidth; x++)
            {
                *p++ = 256*y/Alien_DisplayHeight;
                *p++ = 256*x/Alien_DisplayWidth;
                *p++ = p[-1];
            }
        }
        p = rgbBitmap;
        for (x = 0; x < Alien_DisplayWidth; x++)
        {
            *p++ = 255;
            *p++ = 255;
            *p++ = 255;
        }
        for (y = 1; y < Alien_DisplayHeight; y++)
        {
            *p++ = 255;
            *p++ = 255;
            *p++ = 255;
            p += (Alien_DisplayWidth-2)*3;
            *p++ = 0;
            *p++ = 0;
            *p++ = 0;
        }
        for (x = 0; x < Alien_DisplayWidth; x++)
        {
            *--p = 0;
            *--p = 0;
            *--p = 0;
        }

        gdk_rgb_init();
        gdk_draw_rgb_image(dArea->window,
                           dArea->style->fg_gc[GTK_STATE_NORMAL],
                           0, 0, Alien_DisplayWidth, Alien_DisplayHeight,
                           GDK_RGB_DITHER_NONE,
                           rgbBitmap, Alien_DisplayWidth*3);
    }

    assert( dArea->window != NULL );

    /* MAIN LOOP */
    gtk_main();

    assert( dArea->window == NULL );

    gtk_exit(0);

    return 0;
}
Thanks in advance for any help you can offer!

Robin
robinwatts is offline   Reply With Quote
Old 03-15-2008, 07:13 PM   #2
alanine
Connoisseur
alanine has a complete set of Star Wars action figures.alanine has a complete set of Star Wars action figures.alanine has a complete set of Star Wars action figures.alanine has a complete set of Star Wars action figures.
 
Posts: 54
Karma: 399
Join Date: Sep 2007
Device: iLiad v2
GTK+ alone doesn't do screen refreshes for the e-ink screen.

Have a look at liberdm/erdm.h, link liberdm and use dmDisplay(...) to refresh screen.

You may want to study ipdf source as an example in detail.
alanine is offline   Reply With Quote
Advert
Old 03-19-2008, 01:00 PM   #3
robinwatts
Junior Member
robinwatts began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2008
Location: Oxfordshire, UK
Device: iRex Iliad
Quote:
Originally Posted by alanine View Post
GTK+ alone doesn't do screen refreshes for the e-ink screen.

Have a look at liberdm/erdm.h, link liberdm and use dmDisplay(...) to refresh screen.

You may want to study ipdf source as an example in detail.
Thanks for this. I've now got displaying working OK. Next thing is to figure out how to detect the hardware buttons, and how to hide the toolbar along the bottom.

Hopefully the ipdf source will help for that.

Thanks!

Robin
robinwatts is offline   Reply With Quote
Old 03-19-2008, 02:50 PM   #4
daudi
Addict
daudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-booksdaudi has learned how to read e-books
 
Posts: 281
Karma: 904
Join Date: Oct 2007
Location: Kent, UK
Device: iRex iLiad, Psion 5MX, nokia n800
There are probably other places to look but this thread might help a bit to get started with the buttons.
daudi is offline   Reply With Quote
Old 03-19-2008, 02:53 PM   #5
Adam B.
Addicted to Porting
Adam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the rough
 
Adam B.'s Avatar
 
Posts: 1,697
Karma: 7194
Join Date: Oct 2006
Location: Indianapolis, IN
Device: iRex iLiad, Nokia 770, Samsung i760
You can only detect presses from the buttons on the left hand side. And to allow them to work when running from the conentlister, you'll have to set the gtk wmclass and title of the app to "sh".

You can find some info from when I first ported FBReader here: http://forum.irexnet.com/viewtopic.php?t=1110
Adam B. is offline   Reply With Quote
Advert
Old 03-20-2008, 12:12 AM   #6
Luka Trifunovic
Member
Luka Trifunovic began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Mar 2008
Device: None
Maybe it would be better to make some kind of "driver" that will refresh screen whenever something new should be displayed. It is better solution than to modify code for each application.
Luka Trifunovic is offline   Reply With Quote
Old 03-22-2008, 06:19 AM   #7
Antartica
Evangelist
Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.Antartica ought to be getting tired of karma fortunes by now.
 
Antartica's Avatar
 
Posts: 423
Karma: 1517132
Join Date: Jun 2006
Location: Madrid, Spain
Device: quaderno, remarkable2, yotaphone2, prs950, iliad, onhandpc, newton
Quote:
Originally Posted by Luka Trifunovic View Post
Maybe it would be better to make some kind of "driver" that will refresh screen whenever something new should be displayed. It is better solution than to modify code for each application.
That's the idea of the xepdmgr daemon that I mentioned in the other thread, but that leaves unsolved the problem of the hardware buttons (they are directed to the window with class "sh"... so an unmodified app would not receive the button presses).
Antartica is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DR800 dillo2 & porting non gtk+ based programs Iñigo iRex Developer's Corner 8 05-18-2010 05:18 AM
iLiad non-GTK+ apps not getting button event from X ericshliao iRex Developer's Corner 7 08-30-2009 06:52 AM
Is a gtk version possible? frandavid100 Calibre 14 12-16-2008 03:09 PM
iLiad Compiling GTK apps for iliad rudysplif iRex Developer's Corner 3 03-17-2008 12:59 PM
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 11:08 PM.


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