Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_wimppoll.c @ 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 |
---|---|
48 #if !SDL_THREADS_DISABLED | 48 #if !SDL_THREADS_DISABLED |
49 #include <pthread.h> | 49 #include <pthread.h> |
50 #endif | 50 #endif |
51 | 51 |
52 /* Local functions */ | 52 /* Local functions */ |
53 void WIMP_Poll (_THIS, int waitTime); | 53 void WIMP_Poll(_THIS, int waitTime); |
54 void WIMP_SetFocus (int win); | 54 void WIMP_SetFocus(int win); |
55 | 55 |
56 /* SDL_riscossprite functions */ | 56 /* SDL_riscossprite functions */ |
57 void WIMP_PlotSprite (_THIS, int x, int y); | 57 void WIMP_PlotSprite(_THIS, int x, int y); |
58 void WIMP_ModeChanged (_THIS); | 58 void WIMP_ModeChanged(_THIS); |
59 void WIMP_PaletteChanged (_THIS); | 59 void WIMP_PaletteChanged(_THIS); |
60 | 60 |
61 | 61 |
62 extern void WIMP_PollMouse (_THIS); | 62 extern void WIMP_PollMouse(_THIS); |
63 extern void RISCOS_PollKeyboard (); | 63 extern void RISCOS_PollKeyboard(); |
64 | 64 |
65 #if SDL_THREADS_DISABLED | 65 #if SDL_THREADS_DISABLED |
66 /* Timer running function */ | 66 /* Timer running function */ |
67 extern void RISCOS_CheckTimer (); | 67 extern void RISCOS_CheckTimer(); |
68 #else | 68 #else |
69 extern int riscos_using_threads; | 69 extern int riscos_using_threads; |
70 #endif | 70 #endif |
71 | 71 |
72 /* Mouse cursor handling */ | 72 /* Mouse cursor handling */ |
73 extern void WIMP_ReshowCursor (_THIS); | 73 extern void WIMP_ReshowCursor(_THIS); |
74 extern void WIMP_RestoreWimpCursor (); | 74 extern void WIMP_RestoreWimpCursor(); |
75 | 75 |
76 int hasFocus = 0; | 76 int hasFocus = 0; |
77 int mouseInWindow = 0; | 77 int mouseInWindow = 0; |
78 | 78 |
79 /* Flag to ensure window is correct size after a mode change */ | 79 /* Flag to ensure window is correct size after a mode change */ |
80 static int resizeOnOpen = 0; | 80 static int resizeOnOpen = 0; |
81 | 81 |
82 void | 82 void |
83 WIMP_PumpEvents (_THIS) | 83 WIMP_PumpEvents(_THIS) |
84 { | 84 { |
85 WIMP_Poll (this, 0); | 85 WIMP_Poll(this, 0); |
86 if (hasFocus) | 86 if (hasFocus) |
87 RISCOS_PollKeyboard (); | 87 RISCOS_PollKeyboard(); |
88 if (mouseInWindow) | 88 if (mouseInWindow) |
89 WIMP_PollMouse (this); | 89 WIMP_PollMouse(this); |
90 #if SDL_THREADS_DISABLED | 90 #if SDL_THREADS_DISABLED |
91 if (SDL_timer_running) | 91 if (SDL_timer_running) |
92 RISCOS_CheckTimer (); | 92 RISCOS_CheckTimer(); |
93 #endif | 93 #endif |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 void | 97 void |
98 WIMP_Poll (_THIS, int waitTime) | 98 WIMP_Poll(_THIS, int waitTime) |
99 { | 99 { |
100 _kernel_swi_regs regs; | 100 _kernel_swi_regs regs; |
101 int message[64]; | 101 int message[64]; |
102 unsigned int code; | 102 unsigned int code; |
103 int pollMask = 0; | 103 int pollMask = 0; |
107 | 107 |
108 if (this->PumpEvents != WIMP_PumpEvents) | 108 if (this->PumpEvents != WIMP_PumpEvents) |
109 return; | 109 return; |
110 | 110 |
111 if (waitTime > 0) { | 111 if (waitTime > 0) { |
112 _kernel_swi (OS_ReadMonotonicTime, ®s, ®s); | 112 _kernel_swi(OS_ReadMonotonicTime, ®s, ®s); |
113 waitTime += regs.r[0]; | 113 waitTime += regs.r[0]; |
114 } | 114 } |
115 | 115 |
116 while (doPoll) { | 116 while (doPoll) { |
117 #if !SDL_THREADS_DISABLED | 117 #if !SDL_THREADS_DISABLED |
118 /* Stop thread callbacks while program is paged out */ | 118 /* Stop thread callbacks while program is paged out */ |
119 if (riscos_using_threads) | 119 if (riscos_using_threads) |
120 __pthread_stop_ticker (); | 120 __pthread_stop_ticker(); |
121 #endif | 121 #endif |
122 | 122 |
123 if (waitTime <= 0) { | 123 if (waitTime <= 0) { |
124 regs.r[0] = pollMask; /* Poll Mask */ | 124 regs.r[0] = pollMask; /* Poll Mask */ |
125 /* For no wait time mask out null event so we wait until something happens */ | 125 /* For no wait time mask out null event so we wait until something happens */ |
126 if (waitTime < 0) | 126 if (waitTime < 0) |
127 regs.r[0] |= 1; | 127 regs.r[0] |= 1; |
128 regs.r[1] = (int) message; | 128 regs.r[1] = (int) message; |
129 _kernel_swi (Wimp_Poll, ®s, ®s); | 129 _kernel_swi(Wimp_Poll, ®s, ®s); |
130 } else { | 130 } else { |
131 regs.r[0] = pollMask; | 131 regs.r[0] = pollMask; |
132 regs.r[1] = (int) message; | 132 regs.r[1] = (int) message; |
133 regs.r[2] = waitTime; | 133 regs.r[2] = waitTime; |
134 _kernel_swi (Wimp_PollIdle, ®s, ®s); | 134 _kernel_swi(Wimp_PollIdle, ®s, ®s); |
135 } | 135 } |
136 | 136 |
137 /* Flag to specify if we post a SDL_SysWMEvent */ | 137 /* Flag to specify if we post a SDL_SysWMEvent */ |
138 sysEvent = 0; | 138 sysEvent = 0; |
139 | 139 |
143 case 0: /* Null Event - drop out for standard processing */ | 143 case 0: /* Null Event - drop out for standard processing */ |
144 doPoll = 0; | 144 doPoll = 0; |
145 break; | 145 break; |
146 | 146 |
147 case 1: /* Redraw window */ | 147 case 1: /* Redraw window */ |
148 _kernel_swi (Wimp_RedrawWindow, ®s, ®s); | 148 _kernel_swi(Wimp_RedrawWindow, ®s, ®s); |
149 if (message[0] == sdlWindow) { | 149 if (message[0] == sdlWindow) { |
150 while (regs.r[0]) { | 150 while (regs.r[0]) { |
151 WIMP_PlotSprite (this, message[1], message[2]); | 151 WIMP_PlotSprite(this, message[1], message[2]); |
152 _kernel_swi (Wimp_GetRectangle, ®s, ®s); | 152 _kernel_swi(Wimp_GetRectangle, ®s, ®s); |
153 } | 153 } |
154 } else { | 154 } else { |
155 /* TODO: Currently we just eat them - we may need to pass them on */ | 155 /* TODO: Currently we just eat them - we may need to pass them on */ |
156 while (regs.r[0]) { | 156 while (regs.r[0]) { |
157 _kernel_swi (Wimp_GetRectangle, ®s, ®s); | 157 _kernel_swi(Wimp_GetRectangle, ®s, ®s); |
158 } | 158 } |
159 } | 159 } |
160 break; | 160 break; |
161 | 161 |
162 case 2: /* Open window */ | 162 case 2: /* Open window */ |
166 message[3] = | 166 message[3] = |
167 message[1] + (this->screen->w << this->hidden->xeig); | 167 message[1] + (this->screen->w << this->hidden->xeig); |
168 message[4] = | 168 message[4] = |
169 message[2] + (this->screen->h << this->hidden->yeig); | 169 message[2] + (this->screen->h << this->hidden->yeig); |
170 } | 170 } |
171 _kernel_swi (Wimp_OpenWindow, ®s, ®s); | 171 _kernel_swi(Wimp_OpenWindow, ®s, ®s); |
172 break; | 172 break; |
173 | 173 |
174 case 3: /* Close window */ | 174 case 3: /* Close window */ |
175 if (message[0] == sdlWindow) { | 175 if (message[0] == sdlWindow) { |
176 /* Documentation makes it looks as if the following line is correct: | 176 /* Documentation makes it looks as if the following line is correct: |
177 ** if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, ®s, ®s); | 177 ** if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, ®s, ®s); |
178 ** However some programs don't process this message and so sit there invisibly | 178 ** However some programs don't process this message and so sit there invisibly |
179 ** in the background so I just post the quit message and hope the application | 179 ** in the background so I just post the quit message and hope the application |
180 ** does the correct thing. | 180 ** does the correct thing. |
181 */ | 181 */ |
182 SDL_PrivateQuit (); | 182 SDL_PrivateQuit(); |
183 } else | 183 } else |
184 sysEvent = 1; | 184 sysEvent = 1; |
185 doPoll = 0; | 185 doPoll = 0; |
186 break; | 186 break; |
187 | 187 |
188 case 4: /* Pointer_Leaving_Window */ | 188 case 4: /* Pointer_Leaving_Window */ |
189 if (message[0] == sdlWindow) { | 189 if (message[0] == sdlWindow) { |
190 mouseInWindow = 0; | 190 mouseInWindow = 0; |
191 //TODO: Lose buttons / dragging | 191 //TODO: Lose buttons / dragging |
192 /* Reset to default pointer */ | 192 /* Reset to default pointer */ |
193 WIMP_RestoreWimpCursor (); | 193 WIMP_RestoreWimpCursor(); |
194 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); | 194 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
195 } else | 195 } else |
196 sysEvent = 1; | 196 sysEvent = 1; |
197 break; | 197 break; |
198 | 198 |
199 case 5: /* Pointer_Entering_Window */ | 199 case 5: /* Pointer_Entering_Window */ |
200 if (message[0] == sdlWindow) { | 200 if (message[0] == sdlWindow) { |
201 mouseInWindow = 1; | 201 mouseInWindow = 1; |
202 WIMP_ReshowCursor (this); | 202 WIMP_ReshowCursor(this); |
203 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); | 203 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
204 } else | 204 } else |
205 sysEvent = 1; | 205 sysEvent = 1; |
206 break; | 206 break; |
207 | 207 |
208 case 6: /* Mouse_Click */ | 208 case 6: /* Mouse_Click */ |
209 if (hasFocus == 0) { | 209 if (hasFocus == 0) { |
210 /* First click gives focus if it's not a menu */ | 210 /* First click gives focus if it's not a menu */ |
211 /* we only count non-menu clicks on a window that has the focus */ | 211 /* we only count non-menu clicks on a window that has the focus */ |
212 WIMP_SetFocus (message[3]); | 212 WIMP_SetFocus(message[3]); |
213 } else | 213 } else |
214 doPoll = 0; // So PollMouse gets a chance to pick it up | 214 doPoll = 0; // So PollMouse gets a chance to pick it up |
215 break; | 215 break; |
216 | 216 |
217 case 7: /* User_Drag_Box - Used for mouse release */ | 217 case 7: /* User_Drag_Box - Used for mouse release */ |
232 break; | 232 break; |
233 | 233 |
234 case 11: /* Lose Caret */ | 234 case 11: /* Lose Caret */ |
235 hasFocus = 0; | 235 hasFocus = 0; |
236 if (message[0] == sdlWindow) | 236 if (message[0] == sdlWindow) |
237 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); | 237 SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
238 else | 238 else |
239 sysEvent = 1; | 239 sysEvent = 1; |
240 break; | 240 break; |
241 | 241 |
242 case 12: /* Gain Caret */ | 242 case 12: /* Gain Caret */ |
243 hasFocus = 1; | 243 hasFocus = 1; |
244 if (message[0] == sdlWindow) | 244 if (message[0] == sdlWindow) |
245 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); | 245 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
246 else | 246 else |
247 sysEvent = 1; | 247 sysEvent = 1; |
248 break; | 248 break; |
249 | 249 |
250 case 17: | 250 case 17: |
252 sysEvent = 1; /* All messages are passed on */ | 252 sysEvent = 1; /* All messages are passed on */ |
253 | 253 |
254 switch (message[4]) { | 254 switch (message[4]) { |
255 case 0: /* Quit Event */ | 255 case 0: /* Quit Event */ |
256 /* No choice - have to quit */ | 256 /* No choice - have to quit */ |
257 SDL_Quit (); | 257 SDL_Quit(); |
258 exit (0); | 258 exit(0); |
259 break; | 259 break; |
260 | 260 |
261 case 8: /* Pre Quit */ | 261 case 8: /* Pre Quit */ |
262 SDL_PrivateQuit (); | 262 SDL_PrivateQuit(); |
263 break; | 263 break; |
264 | 264 |
265 case 0x400c1: /* Mode change */ | 265 case 0x400c1: /* Mode change */ |
266 WIMP_ModeChanged (this); | 266 WIMP_ModeChanged(this); |
267 resizeOnOpen = 1; | 267 resizeOnOpen = 1; |
268 break; | 268 break; |
269 | 269 |
270 case 9: /* Palette changed */ | 270 case 9: /* Palette changed */ |
271 WIMP_PaletteChanged (this); | 271 WIMP_PaletteChanged(this); |
272 break; | 272 break; |
273 } | 273 } |
274 break; | 274 break; |
275 | 275 |
276 default: | 276 default: |
280 } | 280 } |
281 | 281 |
282 if (sysEvent) { | 282 if (sysEvent) { |
283 SDL_SysWMmsg wmmsg; | 283 SDL_SysWMmsg wmmsg; |
284 | 284 |
285 SDL_VERSION (&wmmsg.version); | 285 SDL_VERSION(&wmmsg.version); |
286 wmmsg.eventCode = code; | 286 wmmsg.eventCode = code; |
287 SDL_memcpy (wmmsg.pollBlock, message, 64 * sizeof (int)); | 287 SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); |
288 | 288 |
289 /* Fall out of polling loop if message is successfully posted */ | 289 /* Fall out of polling loop if message is successfully posted */ |
290 if (SDL_PrivateSysWMEvent (&wmmsg)) | 290 if (SDL_PrivateSysWMEvent(&wmmsg)) |
291 doPoll = 0; | 291 doPoll = 0; |
292 } | 292 } |
293 #if !SDL_THREADS_DISABLED | 293 #if !SDL_THREADS_DISABLED |
294 if (riscos_using_threads) { | 294 if (riscos_using_threads) { |
295 /* Restart ticker here so other thread can not interfere | 295 /* Restart ticker here so other thread can not interfere |
296 with the Redraw processing */ | 296 with the Redraw processing */ |
297 if (riscos_using_threads) | 297 if (riscos_using_threads) |
298 __pthread_start_ticker (); | 298 __pthread_start_ticker(); |
299 /* Give other threads a better chance of running */ | 299 /* Give other threads a better chance of running */ |
300 pthread_yield (); | 300 pthread_yield(); |
301 } | 301 } |
302 #endif | 302 #endif |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 /* Set focus to specified window */ | 306 /* Set focus to specified window */ |
307 void | 307 void |
308 WIMP_SetFocus (int win) | 308 WIMP_SetFocus(int win) |
309 { | 309 { |
310 _kernel_swi_regs regs; | 310 _kernel_swi_regs regs; |
311 | 311 |
312 regs.r[0] = win; | 312 regs.r[0] = win; |
313 regs.r[1] = -1; /* Icon handle */ | 313 regs.r[1] = -1; /* Icon handle */ |
314 regs.r[2] = 0; /* X-offset we just put it at position 0 */ | 314 regs.r[2] = 0; /* X-offset we just put it at position 0 */ |
315 regs.r[3] = 0; /* Y-offset as above */ | 315 regs.r[3] = 0; /* Y-offset as above */ |
316 regs.r[4] = 1 << 25; /* Caret is invisible */ | 316 regs.r[4] = 1 << 25; /* Caret is invisible */ |
317 regs.r[5] = 0; /* index into string */ | 317 regs.r[5] = 0; /* index into string */ |
318 | 318 |
319 _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); | 319 _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); |
320 } | 320 } |
321 | 321 |
322 /** Run background task while in a sleep command */ | 322 /** Run background task while in a sleep command */ |
323 void | 323 void |
324 RISCOS_BackgroundTasks (void) | 324 RISCOS_BackgroundTasks(void) |
325 { | 325 { |
326 if (current_video && current_video->hidden->window_handle) { | 326 if (current_video && current_video->hidden->window_handle) { |
327 WIMP_Poll (current_video, 0); | 327 WIMP_Poll(current_video, 0); |
328 } | 328 } |
329 #if SDL_THREADS_DISABLED | 329 #if SDL_THREADS_DISABLED |
330 if (SDL_timer_running) | 330 if (SDL_timer_running) |
331 RISCOS_CheckTimer (); | 331 RISCOS_CheckTimer(); |
332 #endif | 332 #endif |
333 } | 333 } |
334 | 334 |
335 /* vi: set ts=4 sw=4 expandtab: */ | 335 /* vi: set ts=4 sw=4 expandtab: */ |