19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Include the SDL main definition header */
39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_main.h"
49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h>
59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <unistd.h>
69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef main
79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#undef main
89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef QWS
109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <qpe/qpeapplication.h>
119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <qapplication.h>
129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <qpe/qpeapplication.h>
139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <stdlib.h>
149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// Workaround for OPIE to remove taskbar icon. Also fixes
169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// some issues in Qtopia where there are left-over qcop files in /tmp/.
179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// I'm guessing this will also clean up the taskbar in the Sharp version
189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall// of Qtopia.
199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic inline void cleanupQCop() {
209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  QString appname(qApp->argv()[0]);
219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  int slash = appname.findRev("/");
229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  if(slash != -1) {  appname = appname.mid(slash+1); }
239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  QString cmd = QPEApplication::qpeDir() + "bin/qcop QPE/System 'closing(QString)' '"+appname+"'";
249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  system(cmd.latin1());
259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  cmd = "/tmp/qcop-msg-"+appname;
269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  unlink(cmd.latin1());
279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstatic QPEApplication *app;
309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern int SDL_main(int argc, char *argv[]);
339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall
349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint main(int argc, char *argv[])
359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{
369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifdef QWS
379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  // This initializes the Qtopia application. It needs to be done here
389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  // because it parses command line options.
399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  app = new QPEApplication(argc, argv);
409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  QWidget dummy;
419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  app->showMainWidget(&dummy);
429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  atexit(cleanupQCop);
439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif
449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  // Exit here because if return is used, the application
459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  // doesn't seem to quit correctly.
469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall  exit(SDL_main(argc, argv));
479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}
48