03-10-2008, 10:39 AM | #1 |
Junior Member
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; } Robin |
03-15-2008, 08:13 PM | #2 |
Connoisseur
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. |
Advert | |
|
03-19-2008, 02:00 PM | #3 | |
Junior Member
Posts: 2
Karma: 10
Join Date: Mar 2008
Location: Oxfordshire, UK
Device: iRex Iliad
|
Quote:
Hopefully the ipdf source will help for that. Thanks! Robin |
|
03-19-2008, 03:50 PM | #4 |
Addict
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.
|
03-19-2008, 03:53 PM | #5 |
Addicted to Porting
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 |
Advert | |
|
03-20-2008, 01:12 AM | #6 |
Member
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.
|
03-22-2008, 07:19 AM | #7 | |
Evangelist
Posts: 423
Karma: 1517132
Join Date: Jun 2006
Location: Madrid, Spain
Device: quaderno, remarkable2, yotaphone2, prs950, iliad, onhandpc, newton
|
Quote:
|
|
Thread Tools | Search this Thread |
|
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 06:18 AM |
iLiad non-GTK+ apps not getting button event from X | ericshliao | iRex Developer's Corner | 7 | 08-30-2009 07:52 AM |
Is a gtk version possible? | frandavid100 | Calibre | 14 | 12-16-2008 04:09 PM |
iLiad Compiling GTK apps for iliad | rudysplif | iRex Developer's Corner | 3 | 03-17-2008 01:59 PM |
iLiad Need help getting started with gtk | tribble | iRex Developer's Corner | 4 | 06-05-2007 01:38 PM |