summaryrefslogtreecommitdiff
path: root/packages/libsdl/libsdl-qpe-1.2.7/pygame.patch
blob: 4b39267a8ad00b992a97fee1f6069cb12f4966a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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 <stdlib.h>
-#include <unistd.h>
-#ifdef main
-#undef main
-#endif
-#ifdef QWS
-#include <qpe/qpeapplication.h>
-#include <qapplication.h>
-#include <qpe/qpeapplication.h>
-#include <stdlib.h>
-
-// 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-09-24 19:55:14.000000000 +0200
@@ -0,0 +1,99 @@
+/* Include the SDL main definition header */
+#include "SDL_main.h"
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+#ifdef QWS
+#include <qpe/qpeapplication.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+
+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-09-24 19:56:40.000000000 +0200
@@ -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-09-24 19:56:40.000000000 +0200
@@ -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
Index: SDL-1.2.7/configure.in
===================================================================
--- SDL-1.2.7.orig/configure.in	2004-02-22 22:31:47.000000000 +0100
+++ SDL-1.2.7/configure.in	2005-09-24 19:58:30.000000000 +0200
@@ -1806,7 +1806,7 @@
         # Set up files for the main() stub
         if test "x$video_qtopia" = "xyes"; then
           SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
-          SDL_LIBS="-lSDLmain $SDL_LIBS"
+
         fi
         # Set up files for the audio library
         # We use the OSS and ALSA API's, not the Sun audio API