Index: SDL-1.2.7/src/main/qtopia/SDL_qtopia_main.cc =================================================================== --- SDL-1.2.7.orig/src/main/qtopia/SDL_qtopia_main.cc 2003-12-14 07:25:53.000000000 +0100 +++ /dev/null 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ - -/* Include the SDL main definition header */ -#include "SDL_main.h" -#include -#include -#ifdef main -#undef main -#endif -#ifdef QWS -#include -#include -#include -#include - -// Workaround for OPIE to remove taskbar icon. Also fixes -// some issues in Qtopia where there are left-over qcop files in /tmp/. -// I'm guessing this will also clean up the taskbar in the Sharp version -// of Qtopia. -static inline void cleanupQCop() { - QString appname(qApp->argv()[0]); - int slash = appname.findRev("/"); - if(slash != -1) { appname = appname.mid(slash+1); } - QString cmd = QPEApplication::qpeDir() + "bin/qcop QPE/System 'closing(QString)' '"+appname+"'"; - system(cmd.latin1()); - cmd = "/tmp/qcop-msg-"+appname; - unlink(cmd.latin1()); -} - -static QPEApplication *app; -#endif - -extern int SDL_main(int argc, char *argv[]); - -int main(int argc, char *argv[]) -{ -#ifdef QWS - // This initializes the Qtopia application. It needs to be done here - // because it parses command line options. - app = new QPEApplication(argc, argv); - QWidget dummy; - app->showMainWidget(&dummy); - atexit(cleanupQCop); -#endif - // Exit here because if return is used, the application - // doesn't seem to quit correctly. - exit(SDL_main(argc, argv)); -} Index: SDL-1.2.7/src/video/qtopia/SDL_qmain.cc =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ SDL-1.2.7/src/video/qtopia/SDL_qmain.cc 2005-03-13 18:04:59.218302232 +0100 @@ -0,0 +1,99 @@ +/* Include the SDL main definition header */ +#include "SDL_main.h" +#include + +#include +#include +#include + + +#ifdef QWS +#include +#include +#include + + + +static QWidget *dummyW = 0; +static QPEApplication *theApp = 0; +static char **cmdline= 0; +static int size = 0; + +static void parse_cmd_line() { + /* + * find the number + */ + char buf[1024]; + int available = 0; + char *string_start = 0; + int fd = ::open( "/proc/self/cmdline", O_RDONLY ); + if ( fd < 0 ) { + qWarning( "Error getting the cmdline, can't be" ); + goto error_out; + } + + available = ::read( fd, &buf, sizeof(buf) ); + if ( available <= 0 ) + goto error_out; + + /* + * find out the number of arguments + */ + size = 0; + for (int i = 0; i < available; ++i ) + if ( buf[i] == '\0' ) + ++size; + + /* now create a the cmdline */ + cmdline = new char*[size+1]; + cmdline[size] = '\0'; // parnoid... + + string_start = &buf[0]; + for ( int i = 0; i < size; ++i ) { + /* + * find the end of the string + */ + size_t sz = ::strlen(string_start); + cmdline[i] = new char[sz+1]; + memcpy( cmdline[i], string_start, sz+1 ); + string_start += (sz+1); // +1 for '\0' +1 to set it beyond + } + + ::close(fd); + + return; + +/* error code */ +error_out: + cmdline = new char*[2]; + cmdline[0] = "unknown_app"; + cmdline[1] = '\0'; + size = 1; +} + +static void free_cmd_line() { + /* + * free each string and then free the array + */ + for ( int i = 0; i < size; ++i ) + delete [] cmdline[i]; + + delete [] cmdline; +} + +static void __attribute__((constructor)) initialize_qpe_app() { + parse_cmd_line(); + + theApp = new QPEApplication( size, cmdline ); + dummyW = new QWidget; + theApp->showMainWidget(dummyW); +} + +static void __attribute__((destructor)) deinitialize_qpe_app() { + free_cmd_line(); + delete dummyW; + delete theApp; +} + + +#endif Index: SDL-1.2.7/src/main/Makefile.am =================================================================== --- SDL-1.2.7.orig/src/main/Makefile.am 2004-02-18 18:22:01.000000000 +0100 +++ SDL-1.2.7/src/main/Makefile.am 2005-03-13 18:03:46.321636109 +0100 @@ -21,11 +21,7 @@ if TARGET_MACOSX MAINLIB_ARCH_SRCS = macosx/SDLMain.m macosx/SDLMain.h else -if TARGET_QTOPIA -MAINLIB_ARCH_SRCS = qtopia/SDL_qtopia_main.cc -else MAINLIB_ARCH_SRCS = dummy/SDL_dummy_main.c -endif # !TARGET_QTOPIA endif # !TARGET_MACOSX endif # !TARGET_WIN32 libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS) Index: SDL-1.2.7/src/video/qtopia/Makefile.am =================================================================== --- SDL-1.2.7.orig/src/video/qtopia/Makefile.am 2002-05-28 21:24:11.000000000 +0200 +++ SDL-1.2.7/src/video/qtopia/Makefile.am 2005-03-13 18:03:46.322635967 +0100 @@ -15,4 +15,5 @@ SDL_syswm.cc \ SDL_syswm_c.h \ SDL_sysevents.cc \ - SDL_sysevents_c.h + SDL_sysevents_c.h \ + SDL_qmain.cc