comparison src/main/beos/SDL_BeApp.cc @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 376665398b25
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
35 35
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 StartBeApp(void *unused) 40 static int
41 StartBeApp (void *unused)
41 { 42 {
42 BApplication *App; 43 BApplication *App;
43 44
44 App = new BApplication("application/x-SDL-executable"); 45 App = new BApplication ("application/x-SDL-executable");
45 46
46 App->Run(); 47 App->Run ();
47 delete App; 48 delete App;
48 return(0); 49 return (0);
49 } 50 }
50 51
51 /* Initialize the Be Application, if it's not already started */ 52 /* Initialize the Be Application, if it's not already started */
52 int SDL_InitBeApp(void) 53 int
54 SDL_InitBeApp (void)
53 { 55 {
54 /* Create the BApplication that handles appserver interaction */ 56 /* Create the BApplication that handles appserver interaction */
55 if ( SDL_BeAppActive <= 0 ) { 57 if (SDL_BeAppActive <= 0) {
56 SDL_AppThread = SDL_CreateThread(StartBeApp, NULL); 58 SDL_AppThread = SDL_CreateThread (StartBeApp, NULL);
57 if ( SDL_AppThread == NULL ) { 59 if (SDL_AppThread == NULL) {
58 SDL_SetError("Couldn't create BApplication thread"); 60 SDL_SetError ("Couldn't create BApplication thread");
59 return(-1); 61 return (-1);
60 } 62 }
61
62 /* Change working to directory to that of executable */
63 app_info info;
64 if (B_OK == be_app->GetAppInfo(&info)) {
65 entry_ref ref = info.ref;
66 BEntry entry;
67 if (B_OK == entry.SetTo(&ref)) {
68 BPath path;
69 if (B_OK == path.SetTo(&entry)) {
70 if (B_OK == path.GetParent(&path)) {
71 chdir(path.Path());
72 }
73 }
74 }
75 }
76
77 do {
78 SDL_Delay(10);
79 } while ( (be_app == NULL) || be_app->IsLaunching() );
80 63
81 /* Mark the application active */ 64 /* Change working to directory to that of executable */
82 SDL_BeAppActive = 0; 65 app_info info;
83 } 66 if (B_OK == be_app->GetAppInfo (&info)) {
67 entry_ref ref = info.ref;
68 BEntry entry;
69 if (B_OK == entry.SetTo (&ref)) {
70 BPath path;
71 if (B_OK == path.SetTo (&entry)) {
72 if (B_OK == path.GetParent (&path)) {
73 chdir (path.Path ());
74 }
75 }
76 }
77 }
84 78
85 /* Increment the application reference count */ 79 do {
86 ++SDL_BeAppActive; 80 SDL_Delay (10);
81 }
82 while ((be_app == NULL) || be_app->IsLaunching ());
87 83
88 /* The app is running, and we're ready to go */ 84 /* Mark the application active */
89 return(0); 85 SDL_BeAppActive = 0;
86 }
87
88 /* Increment the application reference count */
89 ++SDL_BeAppActive;
90
91 /* The app is running, and we're ready to go */
92 return (0);
90 } 93 }
91 94
92 /* Quit the Be Application, if there's nothing left to do */ 95 /* Quit the Be Application, if there's nothing left to do */
93 void SDL_QuitBeApp(void) 96 void
97 SDL_QuitBeApp (void)
94 { 98 {
95 /* Decrement the application reference count */ 99 /* Decrement the application reference count */
96 --SDL_BeAppActive; 100 --SDL_BeAppActive;
97 101
98 /* If the reference count reached zero, clean up the app */ 102 /* If the reference count reached zero, clean up the app */
99 if ( SDL_BeAppActive == 0 ) { 103 if (SDL_BeAppActive == 0) {
100 if ( SDL_AppThread != NULL ) { 104 if (SDL_AppThread != NULL) {
101 if ( be_app != NULL ) { /* Not tested */ 105 if (be_app != NULL) { /* Not tested */
102 be_app->PostMessage(B_QUIT_REQUESTED); 106 be_app->PostMessage (B_QUIT_REQUESTED);
103 } 107 }
104 SDL_WaitThread(SDL_AppThread, NULL); 108 SDL_WaitThread (SDL_AppThread, NULL);
105 SDL_AppThread = NULL; 109 SDL_AppThread = NULL;
106 } 110 }
107 /* be_app should now be NULL since be_app has quit */ 111 /* be_app should now be NULL since be_app has quit */
108 } 112 }
109 } 113 }
114
115 /* vi: set ts=4 sw=4 expandtab: */