]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/libsdl/libsdl-qpe-1.2.7/pygame.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / libsdl / libsdl-qpe-1.2.7 / pygame.patch
1 Index: SDL-1.2.7/src/main/qtopia/SDL_qtopia_main.cc
2 ===================================================================
3 --- SDL-1.2.7.orig/src/main/qtopia/SDL_qtopia_main.cc   2003-12-14 07:25:53.000000000 +0100
4 +++ /dev/null   1970-01-01 00:00:00.000000000 +0000
5 @@ -1,47 +0,0 @@
6 -
7 -/* Include the SDL main definition header */
8 -#include "SDL_main.h"
9 -#include <stdlib.h>
10 -#include <unistd.h>
11 -#ifdef main
12 -#undef main
13 -#endif
14 -#ifdef QWS
15 -#include <qpe/qpeapplication.h>
16 -#include <qapplication.h>
17 -#include <qpe/qpeapplication.h>
18 -#include <stdlib.h>
19 -
20 -// Workaround for OPIE to remove taskbar icon. Also fixes
21 -// some issues in Qtopia where there are left-over qcop files in /tmp/.
22 -// I'm guessing this will also clean up the taskbar in the Sharp version
23 -// of Qtopia.
24 -static inline void cleanupQCop() {
25 -  QString appname(qApp->argv()[0]);
26 -  int slash = appname.findRev("/");
27 -  if(slash != -1) {  appname = appname.mid(slash+1); }
28 -  QString cmd = QPEApplication::qpeDir() + "bin/qcop QPE/System 'closing(QString)' '"+appname+"'";
29 -  system(cmd.latin1());
30 -  cmd = "/tmp/qcop-msg-"+appname;
31 -  unlink(cmd.latin1());
32 -}
33 -
34 -static QPEApplication *app;
35 -#endif
36 -
37 -extern int SDL_main(int argc, char *argv[]);
38 -
39 -int main(int argc, char *argv[])
40 -{
41 -#ifdef QWS
42 -  // This initializes the Qtopia application. It needs to be done here
43 -  // because it parses command line options.
44 -  app = new QPEApplication(argc, argv);
45 -  QWidget dummy;
46 -  app->showMainWidget(&dummy);
47 -  atexit(cleanupQCop);
48 -#endif
49 -  // Exit here because if return is used, the application
50 -  // doesn't seem to quit correctly.
51 -  exit(SDL_main(argc, argv));
52 -}
53 Index: SDL-1.2.7/src/video/qtopia/SDL_qmain.cc
54 ===================================================================
55 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
56 +++ SDL-1.2.7/src/video/qtopia/SDL_qmain.cc     2005-09-24 19:55:14.000000000 +0200
57 @@ -0,0 +1,99 @@
58 +/* Include the SDL main definition header */
59 +#include "SDL_main.h"
60 +#include <stdlib.h>
61 +
62 +#include <sys/types.h>
63 +#include <fcntl.h>
64 +#include <unistd.h>
65 +
66 +
67 +#ifdef QWS
68 +#include <qpe/qpeapplication.h>
69 +#include <stdlib.h>
70 +#include <string.h>
71 +
72 +
73 +
74 +static QWidget        *dummyW = 0;
75 +static QPEApplication *theApp = 0;
76 +static char          **cmdline= 0;
77 +static int             size   = 0;
78 +
79 +static void parse_cmd_line() {
80 +    /*
81 +     * find the number
82 +     */
83 +    char buf[1024];
84 +    int available = 0;
85 +    char *string_start = 0;
86 +    int fd = ::open( "/proc/self/cmdline", O_RDONLY );
87 +    if ( fd < 0 ) {
88 +        qWarning( "Error getting  the cmdline, can't be" );
89 +        goto error_out;
90 +    }
91 +
92 +    available = ::read( fd, &buf, sizeof(buf) );
93 +    if ( available <= 0 )
94 +        goto error_out;
95 +
96 +    /*
97 +     * find out the number of arguments
98 +     */
99 +    size = 0;
100 +    for (int i = 0; i < available; ++i )
101 +        if ( buf[i] == '\0' )
102 +            ++size;
103 +
104 +    /* now create a the cmdline */
105 +    cmdline = new char*[size+1];
106 +    cmdline[size] = '\0'; // parnoid...
107 +
108 +    string_start = &buf[0];
109 +    for ( int i = 0; i < size; ++i ) {
110 +       /*
111 +        * find the end of the string
112 +        */
113 +        size_t sz  = ::strlen(string_start);
114 +        cmdline[i] = new char[sz+1];
115 +       memcpy( cmdline[i], string_start, sz+1 );       
116 +        string_start += (sz+1); // +1 for '\0' +1 to set it beyond
117 +    }
118 +
119 +    ::close(fd);
120 +
121 +    return;
122 +
123 +/* error code */
124 +error_out:
125 +    cmdline = new char*[2];
126 +    cmdline[0] = "unknown_app";
127 +    cmdline[1] = '\0';
128 +    size = 1;
129 +}
130 +
131 +static void free_cmd_line() {
132 +    /*
133 +     * free each string and then free the array
134 +     */
135 +    for ( int i = 0; i < size; ++i )
136 +        delete [] cmdline[i];
137 +
138 +    delete [] cmdline;
139 +}
140 +
141 +static void __attribute__((constructor)) initialize_qpe_app() {
142 +    parse_cmd_line();
143 +
144 +    theApp = new QPEApplication( size, cmdline );
145 +    dummyW = new QWidget;
146 +    theApp->showMainWidget(dummyW);
147 +}
148 +
149 +static void __attribute__((destructor)) deinitialize_qpe_app() {
150 +    free_cmd_line();
151 +    delete dummyW;
152 +    delete theApp;
153 +}
154 +
155 +
156 +#endif
157 Index: SDL-1.2.7/src/main/Makefile.am
158 ===================================================================
159 --- SDL-1.2.7.orig/src/main/Makefile.am 2004-02-18 18:22:01.000000000 +0100
160 +++ SDL-1.2.7/src/main/Makefile.am      2005-09-24 19:56:40.000000000 +0200
161 @@ -21,11 +21,7 @@
162  if TARGET_MACOSX
163  MAINLIB_ARCH_SRCS = macosx/SDLMain.m macosx/SDLMain.h
164  else
165 -if TARGET_QTOPIA
166 -MAINLIB_ARCH_SRCS = qtopia/SDL_qtopia_main.cc
167 -else
168  MAINLIB_ARCH_SRCS = dummy/SDL_dummy_main.c
169 -endif # !TARGET_QTOPIA
170  endif # !TARGET_MACOSX
171  endif # !TARGET_WIN32
172  libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS)
173 Index: SDL-1.2.7/src/video/qtopia/Makefile.am
174 ===================================================================
175 --- SDL-1.2.7.orig/src/video/qtopia/Makefile.am 2002-05-28 21:24:11.000000000 +0200
176 +++ SDL-1.2.7/src/video/qtopia/Makefile.am      2005-09-24 19:56:40.000000000 +0200
177 @@ -15,4 +15,5 @@
178         SDL_syswm.cc            \
179         SDL_syswm_c.h           \
180         SDL_sysevents.cc        \
181 -       SDL_sysevents_c.h       
182 +       SDL_sysevents_c.h       \
183 +       SDL_qmain.cc
184 Index: SDL-1.2.7/configure.in
185 ===================================================================
186 --- SDL-1.2.7.orig/configure.in 2004-02-22 22:31:47.000000000 +0100
187 +++ SDL-1.2.7/configure.in      2005-09-24 19:58:30.000000000 +0200
188 @@ -1806,7 +1806,7 @@
189          # Set up files for the main() stub
190          if test "x$video_qtopia" = "xyes"; then
191            SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
192 -          SDL_LIBS="-lSDLmain $SDL_LIBS"
193 +
194          fi
195          # Set up files for the audio library
196          # We use the OSS and ALSA API's, not the Sun audio API