comparison src/main/beos/SDL_BeApp.cc @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
36 /* Flag to tell whether or not the Be application is active or not */ 36 /* Flag to tell whether or not the Be application is active or not */
37 int SDL_BeAppActive = 0; 37 int SDL_BeAppActive = 0;
38 static SDL_Thread *SDL_AppThread = NULL; 38 static SDL_Thread *SDL_AppThread = NULL;
39 39
40 static int 40 static int
41 StartBeApp (void *unused) 41 StartBeApp(void *unused)
42 { 42 {
43 BApplication *App; 43 BApplication *App;
44 44
45 App = new BApplication ("application/x-SDL-executable"); 45 App = new BApplication("application/x-SDL-executable");
46 46
47 App->Run (); 47 App->Run();
48 delete App; 48 delete App;
49 return (0); 49 return (0);
50 } 50 }
51 51
52 /* Initialize the Be Application, if it's not already started */ 52 /* Initialize the Be Application, if it's not already started */
53 int 53 int
54 SDL_InitBeApp (void) 54 SDL_InitBeApp(void)
55 { 55 {
56 /* Create the BApplication that handles appserver interaction */ 56 /* Create the BApplication that handles appserver interaction */
57 if (SDL_BeAppActive <= 0) { 57 if (SDL_BeAppActive <= 0) {
58 SDL_AppThread = SDL_CreateThread (StartBeApp, NULL); 58 SDL_AppThread = SDL_CreateThread(StartBeApp, NULL);
59 if (SDL_AppThread == NULL) { 59 if (SDL_AppThread == NULL) {
60 SDL_SetError ("Couldn't create BApplication thread"); 60 SDL_SetError("Couldn't create BApplication thread");
61 return (-1); 61 return (-1);
62 } 62 }
63 63
64 /* Change working to directory to that of executable */ 64 /* Change working to directory to that of executable */
65 app_info info; 65 app_info info;
66 if (B_OK == be_app->GetAppInfo (&info)) { 66 if (B_OK == be_app->GetAppInfo(&info)) {
67 entry_ref ref = info.ref; 67 entry_ref ref = info.ref;
68 BEntry entry; 68 BEntry entry;
69 if (B_OK == entry.SetTo (&ref)) { 69 if (B_OK == entry.SetTo(&ref)) {
70 BPath path; 70 BPath path;
71 if (B_OK == path.SetTo (&entry)) { 71 if (B_OK == path.SetTo(&entry)) {
72 if (B_OK == path.GetParent (&path)) { 72 if (B_OK == path.GetParent(&path)) {
73 chdir (path.Path ()); 73 chdir(path.Path());
74 } 74 }
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 do { 79 do {
80 SDL_Delay (10); 80 SDL_Delay(10);
81 } 81 }
82 while ((be_app == NULL) || be_app->IsLaunching ()); 82 while ((be_app == NULL) || be_app->IsLaunching());
83 83
84 /* Mark the application active */ 84 /* Mark the application active */
85 SDL_BeAppActive = 0; 85 SDL_BeAppActive = 0;
86 } 86 }
87 87
92 return (0); 92 return (0);
93 } 93 }
94 94
95 /* Quit the Be Application, if there's nothing left to do */ 95 /* Quit the Be Application, if there's nothing left to do */
96 void 96 void
97 SDL_QuitBeApp (void) 97 SDL_QuitBeApp(void)
98 { 98 {
99 /* Decrement the application reference count */ 99 /* Decrement the application reference count */
100 --SDL_BeAppActive; 100 --SDL_BeAppActive;
101 101
102 /* If the reference count reached zero, clean up the app */ 102 /* If the reference count reached zero, clean up the app */
103 if (SDL_BeAppActive == 0) { 103 if (SDL_BeAppActive == 0) {
104 if (SDL_AppThread != NULL) { 104 if (SDL_AppThread != NULL) {
105 if (be_app != NULL) { /* Not tested */ 105 if (be_app != NULL) { /* Not tested */
106 be_app->PostMessage (B_QUIT_REQUESTED); 106 be_app->PostMessage(B_QUIT_REQUESTED);
107 } 107 }
108 SDL_WaitThread (SDL_AppThread, NULL); 108 SDL_WaitThread(SDL_AppThread, NULL);
109 SDL_AppThread = NULL; 109 SDL_AppThread = NULL;
110 } 110 }
111 /* be_app should now be NULL since be_app has quit */ 111 /* be_app should now be NULL since be_app has quit */
112 } 112 }
113 } 113 }