Mercurial > sdl-ios-xcode
comparison src/video/os2fslib/SDL_os2fslib.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 |
---|---|
60 #pragma pack() | 60 #pragma pack() |
61 | 61 |
62 | 62 |
63 // Backdoors: | 63 // Backdoors: |
64 DECLSPEC void SDLCALL | 64 DECLSPEC void SDLCALL |
65 SDL_OS2FSLIB_SetFCFToUse (ULONG ulFCF) | 65 SDL_OS2FSLIB_SetFCFToUse(ULONG ulFCF) |
66 { | 66 { |
67 ulFCFToUse = ulFCF; | 67 ulFCFToUse = ulFCF; |
68 } | 68 } |
69 | 69 |
70 // Configuration defines: | 70 // Configuration defines: |
88 // even if the surface is resizable. | 88 // even if the surface is resizable. |
89 //#define RESIZE_EVEN_IF_RESIZABLE | 89 //#define RESIZE_EVEN_IF_RESIZABLE |
90 | 90 |
91 /* The translation table from a VK keysym to a SDL keysym */ | 91 /* The translation table from a VK keysym to a SDL keysym */ |
92 static SDLKey HWScanKeyMap[256]; | 92 static SDLKey HWScanKeyMap[256]; |
93 static SDL_keysym *TranslateKey (int vkey, int chcode, int scancode, | 93 static SDL_keysym *TranslateKey(int vkey, int chcode, int scancode, |
94 SDL_keysym * keysym, int iPressed); | 94 SDL_keysym * keysym, int iPressed); |
95 static int iShiftIsPressed; | 95 static int iShiftIsPressed; |
96 | 96 |
97 #ifdef BITBLT_IN_WINMESSAGEPROC | 97 #ifdef BITBLT_IN_WINMESSAGEPROC |
98 #define WM_UPDATERECTSREQUEST WM_USER+50 | 98 #define WM_UPDATERECTSREQUEST WM_USER+50 |
99 #endif | 99 #endif |
117 // Same as WinSetWindowPos(), but takes care for the window to be | 117 // Same as WinSetWindowPos(), but takes care for the window to be |
118 // always on the screen, the titlebar will be accessable everytime. | 118 // always on the screen, the titlebar will be accessable everytime. |
119 // | 119 // |
120 ///////////////////////////////////////////////////////////////////// | 120 ///////////////////////////////////////////////////////////////////// |
121 static BOOL | 121 static BOOL |
122 SetAccessableWindowPos (HWND hwnd, HWND hwndInsertBehind, | 122 SetAccessableWindowPos(HWND hwnd, HWND hwndInsertBehind, |
123 LONG x, LONG y, LONG cx, LONG cy, ULONG fl) | 123 LONG x, LONG y, LONG cx, LONG cy, ULONG fl) |
124 { | 124 { |
125 SWP swpDesktop, swp; | 125 SWP swpDesktop, swp; |
126 // Get desktop area | 126 // Get desktop area |
127 WinQueryWindowPos (HWND_DESKTOP, &swpDesktop); | 127 WinQueryWindowPos(HWND_DESKTOP, &swpDesktop); |
128 | 128 |
129 if ((fl & SWP_MOVE) && (fl & SWP_SIZE)) { | 129 if ((fl & SWP_MOVE) && (fl & SWP_SIZE)) { |
130 // If both moving and sizing, then change size and pos now!! | 130 // If both moving and sizing, then change size and pos now!! |
131 if (x + cx > swpDesktop.cx) | 131 if (x + cx > swpDesktop.cx) |
132 x = swpDesktop.cx - cx; | 132 x = swpDesktop.cx - cx; |
134 x = 0; | 134 x = 0; |
135 if (y < 0) | 135 if (y < 0) |
136 y = 0; | 136 y = 0; |
137 if (y + cy > swpDesktop.cy) | 137 if (y + cy > swpDesktop.cy) |
138 y = swpDesktop.cy - cy; | 138 y = swpDesktop.cy - cy; |
139 return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); | 139 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); |
140 } else if (fl & SWP_MOVE) { | 140 } else if (fl & SWP_MOVE) { |
141 // Just moving | 141 // Just moving |
142 WinQueryWindowPos (hwnd, &swp); | 142 WinQueryWindowPos(hwnd, &swp); |
143 if (x + swp.cx > swpDesktop.cx) | 143 if (x + swp.cx > swpDesktop.cx) |
144 x = swpDesktop.cx - swp.cx; | 144 x = swpDesktop.cx - swp.cx; |
145 if (x < 0) | 145 if (x < 0) |
146 x = 0; | 146 x = 0; |
147 if (y < 0) | 147 if (y < 0) |
148 y = 0; | 148 y = 0; |
149 if (y + swp.cy > swpDesktop.cy) | 149 if (y + swp.cy > swpDesktop.cy) |
150 y = swpDesktop.cy - swp.cy; | 150 y = swpDesktop.cy - swp.cy; |
151 return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); | 151 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); |
152 } else if (fl & SWP_SIZE) { | 152 } else if (fl & SWP_SIZE) { |
153 // Just sizing | 153 // Just sizing |
154 WinQueryWindowPos (hwnd, &swp); | 154 WinQueryWindowPos(hwnd, &swp); |
155 x = swp.x; | 155 x = swp.x; |
156 y = swp.y; | 156 y = swp.y; |
157 if (x + cx > swpDesktop.cx) | 157 if (x + cx > swpDesktop.cx) |
158 x = swpDesktop.cx - cx; | 158 x = swpDesktop.cx - cx; |
159 if (x < 0) | 159 if (x < 0) |
160 x = 0; | 160 x = 0; |
161 if (y < 0) | 161 if (y < 0) |
162 y = 0; | 162 y = 0; |
163 if (y + cy > swpDesktop.cy) | 163 if (y + cy > swpDesktop.cy) |
164 y = swpDesktop.cy - cy; | 164 y = swpDesktop.cy - cy; |
165 return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, | 165 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, |
166 fl | SWP_MOVE); | 166 fl | SWP_MOVE); |
167 } else | 167 } else |
168 return WinSetWindowPos (hwnd, hwndInsertBehind, x, y, cx, cy, fl); | 168 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); |
169 } | 169 } |
170 | 170 |
171 static UniChar | 171 static UniChar |
172 NativeCharToUniChar (int chcode) | 172 NativeCharToUniChar(int chcode) |
173 { | 173 { |
174 UniChar ucResult = (UniChar) chcode; | 174 UniChar ucResult = (UniChar) chcode; |
175 int rc; | 175 int rc; |
176 UconvObject ucoTemp; | 176 UconvObject ucoTemp; |
177 char achFrom[2]; | 177 char achFrom[2]; |
181 UniChar *pucTo; | 181 UniChar *pucTo; |
182 size_t iToCount; | 182 size_t iToCount; |
183 size_t iNonIdentical; | 183 size_t iNonIdentical; |
184 | 184 |
185 // Create unicode convert object | 185 // Create unicode convert object |
186 rc = UniCreateUconvObject (L"", &ucoTemp); | 186 rc = UniCreateUconvObject(L"", &ucoTemp); |
187 if (rc != ULS_SUCCESS) { | 187 if (rc != ULS_SUCCESS) { |
188 // Could not create convert object! | 188 // Could not create convert object! |
189 return ucResult; | 189 return ucResult; |
190 } | 190 } |
191 // Convert language code string to unicode string | 191 // Convert language code string to unicode string |
192 achFrom[0] = (char) chcode; | 192 achFrom[0] = (char) chcode; |
193 achFrom[1] = 0; | 193 achFrom[1] = 0; |
194 iFromCount = sizeof (char) * 2; | 194 iFromCount = sizeof(char) * 2; |
195 iToCount = sizeof (UniChar) * 2; | 195 iToCount = sizeof(UniChar) * 2; |
196 pucTo = &(aucTo[0]); | 196 pucTo = &(aucTo[0]); |
197 pchFrom = &(achFrom[0]); | 197 pchFrom = &(achFrom[0]); |
198 | 198 |
199 rc = UniUconvToUcs (ucoTemp, | 199 rc = UniUconvToUcs(ucoTemp, |
200 &pchFrom, | 200 &pchFrom, |
201 &iFromCount, &pucTo, &iToCount, &iNonIdentical); | 201 &iFromCount, &pucTo, &iToCount, &iNonIdentical); |
202 | 202 |
203 if (rc != ULS_SUCCESS) { | 203 if (rc != ULS_SUCCESS) { |
204 // Could not convert language code to UCS string! | 204 // Could not convert language code to UCS string! |
205 UniFreeUconvObject (ucoTemp); | 205 UniFreeUconvObject(ucoTemp); |
206 return ucResult; | 206 return ucResult; |
207 } | 207 } |
208 | 208 |
209 UniFreeUconvObject (ucoTemp); | 209 UniFreeUconvObject(ucoTemp); |
210 | 210 |
211 #ifdef DEBUG_BUILD | 211 #ifdef DEBUG_BUILD |
212 printf ("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0])); | 212 printf("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0])); |
213 #endif | 213 #endif |
214 | 214 |
215 return aucTo[0]; | 215 return aucTo[0]; |
216 } | 216 } |
217 | 217 |
221 // | 221 // |
222 // This creates SDL Keycodes from VK_ and hardware scan codes | 222 // This creates SDL Keycodes from VK_ and hardware scan codes |
223 // | 223 // |
224 ///////////////////////////////////////////////////////////////////// | 224 ///////////////////////////////////////////////////////////////////// |
225 static SDL_keysym * | 225 static SDL_keysym * |
226 TranslateKey (int vkey, int chcode, int scancode, SDL_keysym * keysym, | 226 TranslateKey(int vkey, int chcode, int scancode, SDL_keysym * keysym, |
227 int iPressed) | 227 int iPressed) |
228 { | 228 { |
229 keysym->scancode = (unsigned char) scancode; | 229 keysym->scancode = (unsigned char) scancode; |
230 keysym->mod = KMOD_NONE; | 230 keysym->mod = KMOD_NONE; |
231 keysym->unicode = 0; | 231 keysym->unicode = 0; |
232 | 232 |
233 if (iPressed && SDL_TranslateUNICODE) { | 233 if (iPressed && SDL_TranslateUNICODE) { |
234 if (chcode) | 234 if (chcode) |
235 keysym->unicode = NativeCharToUniChar (chcode); | 235 keysym->unicode = NativeCharToUniChar(chcode); |
236 else | 236 else |
237 keysym->unicode = vkey; | 237 keysym->unicode = vkey; |
238 } | 238 } |
239 | 239 |
240 keysym->sym = HWScanKeyMap[scancode]; | 240 keysym->sym = HWScanKeyMap[scancode]; |
365 // going out and back to and from fullscreen mode), sending keystrokes | 365 // going out and back to and from fullscreen mode), sending keystrokes |
366 // and mouse events to where it has to be sent, etc... | 366 // and mouse events to where it has to be sent, etc... |
367 // | 367 // |
368 ///////////////////////////////////////////////////////////////////// | 368 ///////////////////////////////////////////////////////////////////// |
369 static MRESULT EXPENTRY | 369 static MRESULT EXPENTRY |
370 WndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 370 WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
371 { | 371 { |
372 HPS ps; | 372 HPS ps; |
373 RECTL rcl; | 373 RECTL rcl; |
374 SDL_VideoDevice *pVideo = NULL; | 374 SDL_VideoDevice *pVideo = NULL; |
375 | 375 |
376 switch (msg) { | 376 switch (msg) { |
377 case WM_CHAR: // Keypress notification | 377 case WM_CHAR: // Keypress notification |
378 #ifdef DEBUG_BUILD | 378 #ifdef DEBUG_BUILD |
379 // printf("WM_CHAR\n"); fflush(stdout); | 379 // printf("WM_CHAR\n"); fflush(stdout); |
380 #endif | 380 #endif |
381 pVideo = WinQueryWindowPtr (hwnd, 0); | 381 pVideo = WinQueryWindowPtr(hwnd, 0); |
382 if (pVideo) { | 382 if (pVideo) { |
383 /* | 383 /* |
384 // We skip repeated keys: | 384 // We skip repeated keys: |
385 if (CHARMSG(&msg)->cRepeat>1) | 385 if (CHARMSG(&msg)->cRepeat>1) |
386 { | 386 { |
390 return (MRESULT) TRUE; | 390 return (MRESULT) TRUE; |
391 } | 391 } |
392 */ | 392 */ |
393 | 393 |
394 // If it's not repeated, then let's see if its pressed or released! | 394 // If it's not repeated, then let's see if its pressed or released! |
395 if (SHORT1FROMMP (mp1) & KC_KEYUP) { | 395 if (SHORT1FROMMP(mp1) & KC_KEYUP) { |
396 // A key has been released | 396 // A key has been released |
397 SDL_keysym keysym; | 397 SDL_keysym keysym; |
398 | 398 |
399 #ifdef DEBUG_BUILD | 399 #ifdef DEBUG_BUILD |
400 // printf("WM_CHAR, keyup, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code | 400 // printf("WM_CHAR, keyup, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code |
413 SHORT1FROMMP(mp2), // Character code | 413 SHORT1FROMMP(mp2), // Character code |
414 CHAR4FROMMP(mp1), // HW Scan code | 414 CHAR4FROMMP(mp1), // HW Scan code |
415 &keysym,0)); | 415 &keysym,0)); |
416 } */ | 416 } */ |
417 | 417 |
418 SDL_PrivateKeyboard (SDL_RELEASED, TranslateKey (SHORT2FROMMP (mp2), // VK_ code | 418 SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code |
419 SHORT1FROMMP (mp2), // Character code | 419 SHORT1FROMMP(mp2), // Character code |
420 CHAR4FROMMP (mp1), // HW Scan code | 420 CHAR4FROMMP(mp1), // HW Scan code |
421 &keysym, 0)); | 421 &keysym, 0)); |
422 | 422 |
423 } else { | 423 } else { |
424 // A key has been pressed | 424 // A key has been pressed |
425 SDL_keysym keysym; | 425 SDL_keysym keysym; |
426 | 426 |
427 #ifdef DEBUG_BUILD | 427 #ifdef DEBUG_BUILD |
428 // printf("WM_CHAR, keydown, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code | 428 // printf("WM_CHAR, keydown, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code |
429 #endif | 429 #endif |
430 // Check for fastkeys: ALT+HOME to toggle FS mode | 430 // Check for fastkeys: ALT+HOME to toggle FS mode |
431 // ALT+END to close app | 431 // ALT+END to close app |
432 if ((SHORT1FROMMP (mp1) & KC_ALT) && | 432 if ((SHORT1FROMMP(mp1) & KC_ALT) && |
433 (SHORT2FROMMP (mp2) == VK_HOME)) { | 433 (SHORT2FROMMP(mp2) == VK_HOME)) { |
434 #ifdef DEBUG_BUILD | 434 #ifdef DEBUG_BUILD |
435 printf (" Pressed ALT+HOME!\n"); | 435 printf(" Pressed ALT+HOME!\n"); |
436 fflush (stdout); | 436 fflush(stdout); |
437 #endif | 437 #endif |
438 // Only switch between fullscreen and back if it's not | 438 // Only switch between fullscreen and back if it's not |
439 // a resizable mode! | 439 // a resizable mode! |
440 if ((!pVideo->hidden->pSDLSurface) || | 440 if ((!pVideo->hidden->pSDLSurface) || |
441 ((pVideo->hidden->pSDLSurface) | 441 ((pVideo->hidden->pSDLSurface) |
442 && | 442 && |
443 ((pVideo->hidden->pSDLSurface-> | 443 ((pVideo->hidden->pSDLSurface-> |
444 flags & SDL_RESIZABLE) == 0))) | 444 flags & SDL_RESIZABLE) == 0))) |
445 FSLib_ToggleFSMode (hwnd, !FSLib_QueryFSMode (hwnd)); | 445 FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd)); |
446 #ifdef DEBUG_BUILD | 446 #ifdef DEBUG_BUILD |
447 else | 447 else |
448 printf (" Resizable mode, so discarding ALT+HOME!\n"); | 448 printf(" Resizable mode, so discarding ALT+HOME!\n"); |
449 fflush (stdout); | 449 fflush(stdout); |
450 #endif | 450 #endif |
451 } else if ((SHORT1FROMMP (mp1) & KC_ALT) && | 451 } else if ((SHORT1FROMMP(mp1) & KC_ALT) && |
452 (SHORT2FROMMP (mp2) == VK_END)) { | 452 (SHORT2FROMMP(mp2) == VK_END)) { |
453 #ifdef DEBUG_BUILD | 453 #ifdef DEBUG_BUILD |
454 printf (" Pressed ALT+END!\n"); | 454 printf(" Pressed ALT+END!\n"); |
455 fflush (stdout); | 455 fflush(stdout); |
456 #endif | 456 #endif |
457 // Close window, and get out of loop! | 457 // Close window, and get out of loop! |
458 // Also send event to SDL application, but we won't | 458 // Also send event to SDL application, but we won't |
459 // wait for it to be processed! | 459 // wait for it to be processed! |
460 SDL_PrivateQuit (); | 460 SDL_PrivateQuit(); |
461 WinPostMsg (hwnd, WM_QUIT, 0, 0); | 461 WinPostMsg(hwnd, WM_QUIT, 0, 0); |
462 } else { | 462 } else { |
463 | 463 |
464 SDL_PrivateKeyboard (SDL_PRESSED, TranslateKey (SHORT2FROMMP (mp2), // VK_ code | 464 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code |
465 SHORT1FROMMP (mp2), // Character code | 465 SHORT1FROMMP(mp2), // Character code |
466 CHAR4FROMMP (mp1), // HW Scan code | 466 CHAR4FROMMP(mp1), // HW Scan code |
467 &keysym, | 467 &keysym, |
468 1)); | 468 1)); |
469 | 469 |
470 } | 470 } |
471 } | 471 } |
472 } | 472 } |
473 return (MRESULT) TRUE; | 473 return (MRESULT) TRUE; |
486 break; // Default processing (pass to parent until frame control) | 486 break; // Default processing (pass to parent until frame control) |
487 } | 487 } |
488 | 488 |
489 case WM_PAINT: // Window redraw! | 489 case WM_PAINT: // Window redraw! |
490 #ifdef DEBUG_BUILD | 490 #ifdef DEBUG_BUILD |
491 printf ("WM_PAINT (0x%x)\n", hwnd); | 491 printf("WM_PAINT (0x%x)\n", hwnd); |
492 fflush (stdout); | 492 fflush(stdout); |
493 #endif | 493 #endif |
494 ps = WinBeginPaint (hwnd, 0, &rcl); | 494 ps = WinBeginPaint(hwnd, 0, &rcl); |
495 pVideo = FSLib_GetUserParm (hwnd); | 495 pVideo = FSLib_GetUserParm(hwnd); |
496 if (pVideo) { | 496 if (pVideo) { |
497 if (!pVideo->hidden->pSDLSurface) { | 497 if (!pVideo->hidden->pSDLSurface) { |
498 RECTL rclRect; | 498 RECTL rclRect; |
499 // So, don't blit now! | 499 // So, don't blit now! |
500 #ifdef DEBUG_BUILD | 500 #ifdef DEBUG_BUILD |
501 printf ("WM_PAINT : Skipping blit while resizing (Pre!)!\n"); | 501 printf("WM_PAINT : Skipping blit while resizing (Pre!)!\n"); |
502 fflush (stdout); | 502 fflush(stdout); |
503 #endif | 503 #endif |
504 WinQueryWindowRect (hwnd, &rclRect); | 504 WinQueryWindowRect(hwnd, &rclRect); |
505 // Fill with black | 505 // Fill with black |
506 WinFillRect (ps, &rclRect, CLR_BLACK); | 506 WinFillRect(ps, &rclRect, CLR_BLACK); |
507 } else { | 507 } else { |
508 if (DosRequestMutexSem | 508 if (DosRequestMutexSem |
509 (pVideo->hidden->hmtxUseSrcBuffer, 1000) == NO_ERROR) { | 509 (pVideo->hidden->hmtxUseSrcBuffer, 1000) == NO_ERROR) { |
510 int iTop, iLeft, iWidth, iHeight; | 510 int iTop, iLeft, iWidth, iHeight; |
511 int iXScaleError, iYScaleError; | 511 int iXScaleError, iYScaleError; |
512 int iXScaleError2, iYScaleError2; | 512 int iXScaleError2, iYScaleError2; |
513 SWP swp; | 513 SWP swp; |
514 | 514 |
515 // Re-blit the modified area! | 515 // Re-blit the modified area! |
516 // For this, we have to calculate the points, scaled! | 516 // For this, we have to calculate the points, scaled! |
517 WinQueryWindowPos (hwnd, &swp); | 517 WinQueryWindowPos(hwnd, &swp); |
518 #ifdef DEBUG_BUILD | 518 #ifdef DEBUG_BUILD |
519 printf | 519 printf |
520 ("WM_PAINT : WinSize: %d %d, BufSize: %d %d\n", | 520 ("WM_PAINT : WinSize: %d %d, BufSize: %d %d\n", |
521 swp.cx, swp.cy, | 521 swp.cx, swp.cy, |
522 pVideo->hidden->SrcBufferDesc.uiXResolution, | 522 pVideo->hidden->SrcBufferDesc.uiXResolution, |
523 pVideo->hidden->SrcBufferDesc.uiYResolution); | 523 pVideo->hidden->SrcBufferDesc.uiYResolution); |
524 fflush (stdout); | 524 fflush(stdout); |
525 #endif | 525 #endif |
526 | 526 |
527 #ifndef RESIZE_EVEN_IF_RESIZABLE | 527 #ifndef RESIZE_EVEN_IF_RESIZABLE |
528 // But only blit if the window is not resizable, or if | 528 // But only blit if the window is not resizable, or if |
529 // the window is resizable and the source buffer size is the | 529 // the window is resizable and the source buffer size is the |
534 && | 534 && |
535 ((swp.cx != | 535 ((swp.cx != |
536 pVideo->hidden->SrcBufferDesc.uiXResolution) | 536 pVideo->hidden->SrcBufferDesc.uiXResolution) |
537 || (swp.cy != | 537 || (swp.cy != |
538 pVideo->hidden->SrcBufferDesc.uiYResolution)) | 538 pVideo->hidden->SrcBufferDesc.uiYResolution)) |
539 && (!FSLib_QueryFSMode (hwnd)))) { | 539 && (!FSLib_QueryFSMode(hwnd)))) { |
540 RECTL rclRect; | 540 RECTL rclRect; |
541 // Resizable surface and in resizing! | 541 // Resizable surface and in resizing! |
542 // So, don't blit now! | 542 // So, don't blit now! |
543 #ifdef DEBUG_BUILD | 543 #ifdef DEBUG_BUILD |
544 printf ("WM_PAINT : Skipping blit while resizing!\n"); | 544 printf("WM_PAINT : Skipping blit while resizing!\n"); |
545 fflush (stdout); | 545 fflush(stdout); |
546 #endif | 546 #endif |
547 WinQueryWindowRect (hwnd, &rclRect); | 547 WinQueryWindowRect(hwnd, &rclRect); |
548 // Fill with black | 548 // Fill with black |
549 WinFillRect (ps, &rclRect, CLR_BLACK); | 549 WinFillRect(ps, &rclRect, CLR_BLACK); |
550 } else | 550 } else |
551 #endif | 551 #endif |
552 { | 552 { |
553 | 553 |
554 iXScaleError = | 554 iXScaleError = |
619 ("WM_PAINT : BitBlt: %d %d -> %d %d (Buf %d x %d)\n", | 619 ("WM_PAINT : BitBlt: %d %d -> %d %d (Buf %d x %d)\n", |
620 iTop, iLeft, iWidth, iHeight, | 620 iTop, iLeft, iWidth, iHeight, |
621 pVideo->hidden->SrcBufferDesc. | 621 pVideo->hidden->SrcBufferDesc. |
622 uiXResolution, | 622 uiXResolution, |
623 pVideo->hidden->SrcBufferDesc.uiYResolution); | 623 pVideo->hidden->SrcBufferDesc.uiYResolution); |
624 fflush (stdout); | 624 fflush(stdout); |
625 #endif | 625 #endif |
626 | 626 |
627 FSLIB_BITBLT (hwnd, | 627 FSLIB_BITBLT(hwnd, |
628 pVideo->hidden->pchSrcBuffer, | 628 pVideo->hidden->pchSrcBuffer, |
629 iTop, iLeft, iWidth, iHeight); | 629 iTop, iLeft, iWidth, iHeight); |
630 } | 630 } |
631 | 631 |
632 DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); | 632 DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); |
633 } | 633 } |
634 } | 634 } |
635 } | 635 } |
636 #ifdef DEBUG_BUILD | 636 #ifdef DEBUG_BUILD |
637 else { | 637 else { |
638 printf ("WM_PAINT : No pVideo!\n"); | 638 printf("WM_PAINT : No pVideo!\n"); |
639 fflush (stdout); | 639 fflush(stdout); |
640 } | 640 } |
641 #endif | 641 #endif |
642 WinEndPaint (ps); | 642 WinEndPaint(ps); |
643 #ifdef DEBUG_BUILD | 643 #ifdef DEBUG_BUILD |
644 printf ("WM_PAINT : Done.\n"); | 644 printf("WM_PAINT : Done.\n"); |
645 fflush (stdout); | 645 fflush(stdout); |
646 #endif | 646 #endif |
647 return 0; | 647 return 0; |
648 | 648 |
649 case WM_SIZE: | 649 case WM_SIZE: |
650 { | 650 { |
651 #ifdef DEBUG_BUILD | 651 #ifdef DEBUG_BUILD |
652 printf ("WM_SIZE : (%d %d)\n", | 652 printf("WM_SIZE : (%d %d)\n", |
653 SHORT1FROMMP (mp2), SHORT2FROMMP (mp2)); | 653 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); |
654 fflush (stdout); | 654 fflush(stdout); |
655 #endif | 655 #endif |
656 iWindowSizeX = SHORT1FROMMP (mp2); | 656 iWindowSizeX = SHORT1FROMMP(mp2); |
657 iWindowSizeY = SHORT2FROMMP (mp2); | 657 iWindowSizeY = SHORT2FROMMP(mp2); |
658 bWindowResized = 1; | 658 bWindowResized = 1; |
659 | 659 |
660 // Make sure the window will be redrawn | 660 // Make sure the window will be redrawn |
661 WinInvalidateRegion (hwnd, NULL, TRUE); | 661 WinInvalidateRegion(hwnd, NULL, TRUE); |
662 } | 662 } |
663 break; | 663 break; |
664 | 664 |
665 case WM_FSLIBNOTIFICATION: | 665 case WM_FSLIBNOTIFICATION: |
666 #ifdef DEBUG_BUILD | 666 #ifdef DEBUG_BUILD |
667 printf ("WM_FSLIBNOTIFICATION\n"); | 667 printf("WM_FSLIBNOTIFICATION\n"); |
668 fflush (stdout); | 668 fflush(stdout); |
669 #endif | 669 #endif |
670 if ((int) mp1 == FSLN_TOGGLEFSMODE) { | 670 if ((int) mp1 == FSLN_TOGGLEFSMODE) { |
671 // FS mode changed, reblit image! | 671 // FS mode changed, reblit image! |
672 pVideo = FSLib_GetUserParm (hwnd); | 672 pVideo = FSLib_GetUserParm(hwnd); |
673 if (pVideo) { | 673 if (pVideo) { |
674 if (!pVideo->hidden->pSDLSurface) { | 674 if (!pVideo->hidden->pSDLSurface) { |
675 // Resizable surface and in resizing! | 675 // Resizable surface and in resizing! |
676 // So, don't blit now! | 676 // So, don't blit now! |
677 #ifdef DEBUG_BUILD | 677 #ifdef DEBUG_BUILD |
678 printf | 678 printf |
679 ("WM_FSLIBNOTIFICATION : Can not blit if there is no surface, doing nothing.\n"); | 679 ("WM_FSLIBNOTIFICATION : Can not blit if there is no surface, doing nothing.\n"); |
680 fflush (stdout); | 680 fflush(stdout); |
681 #endif | 681 #endif |
682 } else { | 682 } else { |
683 if (DosRequestMutexSem | 683 if (DosRequestMutexSem |
684 (pVideo->hidden->hmtxUseSrcBuffer, | 684 (pVideo->hidden->hmtxUseSrcBuffer, |
685 1000) == NO_ERROR) { | 685 1000) == NO_ERROR) { |
688 SWP swp; | 688 SWP swp; |
689 | 689 |
690 // But only blit if the window is not resizable, or if | 690 // But only blit if the window is not resizable, or if |
691 // the window is resizable and the source buffer size is the | 691 // the window is resizable and the source buffer size is the |
692 // same as the destination buffer size! | 692 // same as the destination buffer size! |
693 WinQueryWindowPos (hwnd, &swp); | 693 WinQueryWindowPos(hwnd, &swp); |
694 if ((!pVideo->hidden->pSDLSurface) || | 694 if ((!pVideo->hidden->pSDLSurface) || |
695 ((pVideo->hidden->pSDLSurface) && | 695 ((pVideo->hidden->pSDLSurface) && |
696 (pVideo->hidden->pSDLSurface-> | 696 (pVideo->hidden->pSDLSurface-> |
697 flags & SDL_RESIZABLE) | 697 flags & SDL_RESIZABLE) |
698 && | 698 && |
700 pVideo->hidden->SrcBufferDesc. | 700 pVideo->hidden->SrcBufferDesc. |
701 uiXResolution) | 701 uiXResolution) |
702 || (swp.cy != | 702 || (swp.cy != |
703 pVideo->hidden-> | 703 pVideo->hidden-> |
704 SrcBufferDesc.uiYResolution)) | 704 SrcBufferDesc.uiYResolution)) |
705 && (!FSLib_QueryFSMode (hwnd)))) { | 705 && (!FSLib_QueryFSMode(hwnd)))) { |
706 // Resizable surface and in resizing! | 706 // Resizable surface and in resizing! |
707 // So, don't blit now! | 707 // So, don't blit now! |
708 #ifdef DEBUG_BUILD | 708 #ifdef DEBUG_BUILD |
709 printf | 709 printf |
710 ("WM_FSLIBNOTIFICATION : Cannot blit while resizing, doing nothing.\n"); | 710 ("WM_FSLIBNOTIFICATION : Cannot blit while resizing, doing nothing.\n"); |
711 fflush (stdout); | 711 fflush(stdout); |
712 #endif | 712 #endif |
713 } else | 713 } else |
714 #endif | 714 #endif |
715 { | 715 { |
716 #ifdef DEBUG_BUILD | 716 #ifdef DEBUG_BUILD |
717 printf ("WM_FSLIBNOTIFICATION : Blitting!\n"); | 717 printf("WM_FSLIBNOTIFICATION : Blitting!\n"); |
718 fflush (stdout); | 718 fflush(stdout); |
719 #endif | 719 #endif |
720 FSLIB_BITBLT (hwnd, | 720 FSLIB_BITBLT(hwnd, |
721 pVideo->hidden-> | 721 pVideo->hidden-> |
722 pchSrcBuffer, 0, | 722 pchSrcBuffer, 0, |
723 0, | 723 0, |
724 pVideo->hidden-> | 724 pVideo->hidden-> |
725 SrcBufferDesc. | 725 SrcBufferDesc. |
726 uiXResolution, | 726 uiXResolution, |
727 pVideo->hidden-> | 727 pVideo->hidden-> |
728 SrcBufferDesc.uiYResolution); | 728 SrcBufferDesc.uiYResolution); |
729 } | 729 } |
730 } | 730 } |
731 #ifdef DEBUG_BUILD | 731 #ifdef DEBUG_BUILD |
732 else | 732 else |
733 printf | 733 printf |
734 ("WM_FSLIBNOTIFICATION : No public surface!\n"); | 734 ("WM_FSLIBNOTIFICATION : No public surface!\n"); |
735 fflush (stdout); | 735 fflush(stdout); |
736 #endif | 736 #endif |
737 | 737 |
738 DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); | 738 DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); |
739 } | 739 } |
740 } | 740 } |
741 } | 741 } |
742 } | 742 } |
743 return (MPARAM) 1; | 743 return (MPARAM) 1; |
744 | 744 |
745 case WM_ACTIVATE: | 745 case WM_ACTIVATE: |
746 #ifdef DEBUG_BUILD | 746 #ifdef DEBUG_BUILD |
747 printf ("WM_ACTIVATE\n"); | 747 printf("WM_ACTIVATE\n"); |
748 fflush (stdout); | 748 fflush(stdout); |
749 #endif | 749 #endif |
750 | 750 |
751 pVideo = FSLib_GetUserParm (hwnd); | 751 pVideo = FSLib_GetUserParm(hwnd); |
752 if (pVideo) { | 752 if (pVideo) { |
753 pVideo->hidden->fInFocus = (int) mp1; | 753 pVideo->hidden->fInFocus = (int) mp1; |
754 if (pVideo->hidden->fInFocus) { | 754 if (pVideo->hidden->fInFocus) { |
755 // Went into focus | 755 // Went into focus |
756 if ((pVideo->hidden->iMouseVisible) | 756 if ((pVideo->hidden->iMouseVisible) |
757 && (!bMouseCaptured)) | 757 && (!bMouseCaptured)) |
758 WinSetPointer (HWND_DESKTOP, | 758 WinSetPointer(HWND_DESKTOP, |
759 WinQuerySysPointer (HWND_DESKTOP, | 759 WinQuerySysPointer(HWND_DESKTOP, |
760 SPTR_ARROW, FALSE)); | 760 SPTR_ARROW, FALSE)); |
761 else | 761 else |
762 WinSetPointer (HWND_DESKTOP, NULL); | 762 WinSetPointer(HWND_DESKTOP, NULL); |
763 | 763 |
764 if (bMouseCapturable) { | 764 if (bMouseCapturable) { |
765 // Re-capture the mouse, if we captured it before! | 765 // Re-capture the mouse, if we captured it before! |
766 WinSetCapture (HWND_DESKTOP, hwnd); | 766 WinSetCapture(HWND_DESKTOP, hwnd); |
767 bMouseCaptured = 1; | 767 bMouseCaptured = 1; |
768 { | 768 { |
769 SWP swpClient; | 769 SWP swpClient; |
770 POINTL ptl; | 770 POINTL ptl; |
771 // Center the mouse to the middle of the window! | 771 // Center the mouse to the middle of the window! |
772 WinQueryWindowPos (pVideo->hidden->hwndClient, | 772 WinQueryWindowPos(pVideo->hidden->hwndClient, |
773 &swpClient); | 773 &swpClient); |
774 ptl.x = 0; | 774 ptl.x = 0; |
775 ptl.y = 0; | 775 ptl.y = 0; |
776 WinMapWindowPoints (pVideo->hidden-> | 776 WinMapWindowPoints(pVideo->hidden-> |
777 hwndClient, HWND_DESKTOP, | 777 hwndClient, HWND_DESKTOP, &ptl, 1); |
778 &ptl, 1); | |
779 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 778 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
780 WinSetPointerPos (HWND_DESKTOP, | 779 WinSetPointerPos(HWND_DESKTOP, |
781 ptl.x + swpClient.cx / 2, | 780 ptl.x + swpClient.cx / 2, |
782 ptl.y + swpClient.cy / 2); | 781 ptl.y + swpClient.cy / 2); |
783 } | 782 } |
784 } | 783 } |
785 } else { | 784 } else { |
786 // Went out of focus | 785 // Went out of focus |
787 WinSetPointer (HWND_DESKTOP, | 786 WinSetPointer(HWND_DESKTOP, |
788 WinQuerySysPointer (HWND_DESKTOP, | 787 WinQuerySysPointer(HWND_DESKTOP, |
789 SPTR_ARROW, FALSE)); | 788 SPTR_ARROW, FALSE)); |
790 | 789 |
791 if (bMouseCaptured) { | 790 if (bMouseCaptured) { |
792 // Release the mouse | 791 // Release the mouse |
793 WinSetCapture (HWND_DESKTOP, hwnd); | 792 WinSetCapture(HWND_DESKTOP, hwnd); |
794 bMouseCaptured = 0; | 793 bMouseCaptured = 0; |
795 } | 794 } |
796 } | 795 } |
797 } | 796 } |
798 #ifdef DEBUG_BUILD | 797 #ifdef DEBUG_BUILD |
799 printf ("WM_ACTIVATE done\n"); | 798 printf("WM_ACTIVATE done\n"); |
800 fflush (stdout); | 799 fflush(stdout); |
801 #endif | 800 #endif |
802 | 801 |
803 break; | 802 break; |
804 | 803 |
805 case WM_BUTTON1DOWN: | 804 case WM_BUTTON1DOWN: |
806 #ifdef DEBUG_BUILD | 805 #ifdef DEBUG_BUILD |
807 printf ("WM_BUTTON1DOWN\n"); | 806 printf("WM_BUTTON1DOWN\n"); |
808 fflush (stdout); | 807 fflush(stdout); |
809 #endif | 808 #endif |
810 | 809 |
811 pVideo = FSLib_GetUserParm (hwnd); | 810 pVideo = FSLib_GetUserParm(hwnd); |
812 if (pVideo) { | 811 if (pVideo) { |
813 SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! | 812 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! |
814 | 813 |
815 if (bMouseCapturable) { | 814 if (bMouseCapturable) { |
816 // We should capture the mouse! | 815 // We should capture the mouse! |
817 if (!bMouseCaptured) { | 816 if (!bMouseCaptured) { |
818 WinSetCapture (HWND_DESKTOP, hwnd); | 817 WinSetCapture(HWND_DESKTOP, hwnd); |
819 WinSetPointer (HWND_DESKTOP, NULL); | 818 WinSetPointer(HWND_DESKTOP, NULL); |
820 bMouseCaptured = 1; | 819 bMouseCaptured = 1; |
821 { | 820 { |
822 SWP swpClient; | 821 SWP swpClient; |
823 POINTL ptl; | 822 POINTL ptl; |
824 // Center the mouse to the middle of the window! | 823 // Center the mouse to the middle of the window! |
825 WinQueryWindowPos (pVideo->hidden->hwndClient, | 824 WinQueryWindowPos(pVideo->hidden->hwndClient, |
826 &swpClient); | 825 &swpClient); |
827 ptl.x = 0; | 826 ptl.x = 0; |
828 ptl.y = 0; | 827 ptl.y = 0; |
829 WinMapWindowPoints (pVideo->hidden-> | 828 WinMapWindowPoints(pVideo->hidden-> |
830 hwndClient, HWND_DESKTOP, | 829 hwndClient, HWND_DESKTOP, &ptl, 1); |
831 &ptl, 1); | |
832 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 830 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
833 WinSetPointerPos (HWND_DESKTOP, | 831 WinSetPointerPos(HWND_DESKTOP, |
834 ptl.x + swpClient.cx / 2, | 832 ptl.x + swpClient.cx / 2, |
835 ptl.y + swpClient.cy / 2); | 833 ptl.y + swpClient.cy / 2); |
836 } | 834 } |
837 } | 835 } |
838 } | 836 } |
839 } | 837 } |
840 break; | 838 break; |
841 case WM_BUTTON1UP: | 839 case WM_BUTTON1UP: |
842 #ifdef DEBUG_BUILD | 840 #ifdef DEBUG_BUILD |
843 printf ("WM_BUTTON1UP\n"); | 841 printf("WM_BUTTON1UP\n"); |
844 fflush (stdout); | 842 fflush(stdout); |
845 #endif | 843 #endif |
846 SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! | 844 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); // Don't report mouse movement! |
847 break; | 845 break; |
848 case WM_BUTTON2DOWN: | 846 case WM_BUTTON2DOWN: |
849 #ifdef DEBUG_BUILD | 847 #ifdef DEBUG_BUILD |
850 printf ("WM_BUTTON2DOWN\n"); | 848 printf("WM_BUTTON2DOWN\n"); |
851 fflush (stdout); | 849 fflush(stdout); |
852 #endif | 850 #endif |
853 | 851 |
854 pVideo = FSLib_GetUserParm (hwnd); | 852 pVideo = FSLib_GetUserParm(hwnd); |
855 if (pVideo) { | 853 if (pVideo) { |
856 SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! | 854 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! |
857 | 855 |
858 if (bMouseCapturable) { | 856 if (bMouseCapturable) { |
859 // We should capture the mouse! | 857 // We should capture the mouse! |
860 if (!bMouseCaptured) { | 858 if (!bMouseCaptured) { |
861 WinSetCapture (HWND_DESKTOP, hwnd); | 859 WinSetCapture(HWND_DESKTOP, hwnd); |
862 WinSetPointer (HWND_DESKTOP, NULL); | 860 WinSetPointer(HWND_DESKTOP, NULL); |
863 bMouseCaptured = 1; | 861 bMouseCaptured = 1; |
864 { | 862 { |
865 SWP swpClient; | 863 SWP swpClient; |
866 POINTL ptl; | 864 POINTL ptl; |
867 // Center the mouse to the middle of the window! | 865 // Center the mouse to the middle of the window! |
868 WinQueryWindowPos (pVideo->hidden->hwndClient, | 866 WinQueryWindowPos(pVideo->hidden->hwndClient, |
869 &swpClient); | 867 &swpClient); |
870 ptl.x = 0; | 868 ptl.x = 0; |
871 ptl.y = 0; | 869 ptl.y = 0; |
872 WinMapWindowPoints (pVideo->hidden-> | 870 WinMapWindowPoints(pVideo->hidden-> |
873 hwndClient, HWND_DESKTOP, | 871 hwndClient, HWND_DESKTOP, &ptl, 1); |
874 &ptl, 1); | |
875 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 872 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
876 WinSetPointerPos (HWND_DESKTOP, | 873 WinSetPointerPos(HWND_DESKTOP, |
877 ptl.x + swpClient.cx / 2, | 874 ptl.x + swpClient.cx / 2, |
878 ptl.y + swpClient.cy / 2); | 875 ptl.y + swpClient.cy / 2); |
879 } | 876 } |
880 } | 877 } |
881 } | 878 } |
882 | 879 |
883 } | 880 } |
884 break; | 881 break; |
885 case WM_BUTTON2UP: | 882 case WM_BUTTON2UP: |
886 #ifdef DEBUG_BUILD | 883 #ifdef DEBUG_BUILD |
887 printf ("WM_BUTTON2UP\n"); | 884 printf("WM_BUTTON2UP\n"); |
888 fflush (stdout); | 885 fflush(stdout); |
889 #endif | 886 #endif |
890 SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! | 887 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); // Don't report mouse movement! |
891 break; | 888 break; |
892 case WM_BUTTON3DOWN: | 889 case WM_BUTTON3DOWN: |
893 #ifdef DEBUG_BUILD | 890 #ifdef DEBUG_BUILD |
894 printf ("WM_BUTTON3DOWN\n"); | 891 printf("WM_BUTTON3DOWN\n"); |
895 fflush (stdout); | 892 fflush(stdout); |
896 #endif | 893 #endif |
897 | 894 |
898 pVideo = FSLib_GetUserParm (hwnd); | 895 pVideo = FSLib_GetUserParm(hwnd); |
899 if (pVideo) { | 896 if (pVideo) { |
900 SDL_PrivateMouseButton (SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! | 897 SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! |
901 | 898 |
902 if (bMouseCapturable) { | 899 if (bMouseCapturable) { |
903 // We should capture the mouse! | 900 // We should capture the mouse! |
904 if (!bMouseCaptured) { | 901 if (!bMouseCaptured) { |
905 WinSetCapture (HWND_DESKTOP, hwnd); | 902 WinSetCapture(HWND_DESKTOP, hwnd); |
906 WinSetPointer (HWND_DESKTOP, NULL); | 903 WinSetPointer(HWND_DESKTOP, NULL); |
907 bMouseCaptured = 1; | 904 bMouseCaptured = 1; |
908 { | 905 { |
909 SWP swpClient; | 906 SWP swpClient; |
910 POINTL ptl; | 907 POINTL ptl; |
911 // Center the mouse to the middle of the window! | 908 // Center the mouse to the middle of the window! |
912 WinQueryWindowPos (pVideo->hidden->hwndClient, | 909 WinQueryWindowPos(pVideo->hidden->hwndClient, |
913 &swpClient); | 910 &swpClient); |
914 ptl.x = 0; | 911 ptl.x = 0; |
915 ptl.y = 0; | 912 ptl.y = 0; |
916 WinMapWindowPoints (pVideo->hidden-> | 913 WinMapWindowPoints(pVideo->hidden-> |
917 hwndClient, HWND_DESKTOP, | 914 hwndClient, HWND_DESKTOP, &ptl, 1); |
918 &ptl, 1); | |
919 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 915 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
920 WinSetPointerPos (HWND_DESKTOP, | 916 WinSetPointerPos(HWND_DESKTOP, |
921 ptl.x + swpClient.cx / 2, | 917 ptl.x + swpClient.cx / 2, |
922 ptl.y + swpClient.cy / 2); | 918 ptl.y + swpClient.cy / 2); |
923 } | 919 } |
924 } | 920 } |
925 } | 921 } |
926 } | 922 } |
927 break; | 923 break; |
928 case WM_BUTTON3UP: | 924 case WM_BUTTON3UP: |
929 #ifdef DEBUG_BUILD | 925 #ifdef DEBUG_BUILD |
930 printf ("WM_BUTTON3UP\n"); | 926 printf("WM_BUTTON3UP\n"); |
931 fflush (stdout); | 927 fflush(stdout); |
932 #endif | 928 #endif |
933 SDL_PrivateMouseButton (SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! | 929 SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); // Don't report mouse movement! |
934 break; | 930 break; |
935 case WM_MOUSEMOVE: | 931 case WM_MOUSEMOVE: |
936 #ifdef DEBUG_BUILD | 932 #ifdef DEBUG_BUILD |
937 // printf("WM_MOUSEMOVE\n"); fflush(stdout); | 933 // printf("WM_MOUSEMOVE\n"); fflush(stdout); |
938 #endif | 934 #endif |
939 | 935 |
940 pVideo = FSLib_GetUserParm (hwnd); | 936 pVideo = FSLib_GetUserParm(hwnd); |
941 if (pVideo) { | 937 if (pVideo) { |
942 if (pVideo->hidden->iSkipWMMOUSEMOVE) { | 938 if (pVideo->hidden->iSkipWMMOUSEMOVE) { |
943 pVideo->hidden->iSkipWMMOUSEMOVE--; | 939 pVideo->hidden->iSkipWMMOUSEMOVE--; |
944 } else { | 940 } else { |
945 POINTS *ppts = (POINTS *) (&mp1); | 941 POINTS *ppts = (POINTS *) (&mp1); |
946 POINTL ptl; | 942 POINTL ptl; |
947 | 943 |
948 if (bMouseCaptured) { | 944 if (bMouseCaptured) { |
949 SWP swpClient; | 945 SWP swpClient; |
950 | 946 |
951 WinQueryWindowPos (pVideo->hidden->hwndClient, | 947 WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient); |
952 &swpClient); | |
953 | 948 |
954 // Send relative mouse position, and re-center the mouse | 949 // Send relative mouse position, and re-center the mouse |
955 // Reposition the mouse to the center of the screen/window | 950 // Reposition the mouse to the center of the screen/window |
956 SDL_PrivateMouseMotion (0, // Buttons not changed | 951 SDL_PrivateMouseMotion(0, // Buttons not changed |
957 1, // Relative position | 952 1, // Relative position |
958 ppts->x - | 953 ppts->x - |
959 (swpClient.cx / 2), | 954 (swpClient.cx / 2), |
960 (swpClient.cy / 2) - ppts->y); | 955 (swpClient.cy / 2) - ppts->y); |
961 | 956 |
962 ptl.x = 0; | 957 ptl.x = 0; |
963 ptl.y = 0; | 958 ptl.y = 0; |
964 WinMapWindowPoints (pVideo->hidden->hwndClient, | 959 WinMapWindowPoints(pVideo->hidden->hwndClient, |
965 HWND_DESKTOP, &ptl, 1); | 960 HWND_DESKTOP, &ptl, 1); |
966 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 961 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
967 // Center the mouse to the middle of the window! | 962 // Center the mouse to the middle of the window! |
968 WinSetPointerPos (HWND_DESKTOP, | 963 WinSetPointerPos(HWND_DESKTOP, |
969 ptl.x + swpClient.cx / 2, | 964 ptl.x + swpClient.cx / 2, |
970 ptl.y + swpClient.cy / 2); | 965 ptl.y + swpClient.cy / 2); |
971 } else { | 966 } else { |
972 CONVERTMOUSEPOSITION (); | 967 CONVERTMOUSEPOSITION(); |
973 | 968 |
974 // Send absolute mouse position | 969 // Send absolute mouse position |
975 SDL_PrivateMouseMotion (0, // Buttons not changed | 970 SDL_PrivateMouseMotion(0, // Buttons not changed |
976 0, // Absolute position | 971 0, // Absolute position |
977 ppts->x, ppts->y); | 972 ppts->x, ppts->y); |
978 } | 973 } |
979 } | 974 } |
980 if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) { | 975 if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) { |
981 #ifdef DEBUG_BUILD | 976 #ifdef DEBUG_BUILD |
982 // printf("WM_MOUSEMOVE : ptr = %p\n", hptrGlobalPointer); fflush(stdout); | 977 // printf("WM_MOUSEMOVE : ptr = %p\n", hptrGlobalPointer); fflush(stdout); |
983 #endif | 978 #endif |
984 | 979 |
985 if (hptrGlobalPointer) | 980 if (hptrGlobalPointer) |
986 WinSetPointer (HWND_DESKTOP, hptrGlobalPointer); | 981 WinSetPointer(HWND_DESKTOP, hptrGlobalPointer); |
987 else | 982 else |
988 WinSetPointer (HWND_DESKTOP, | 983 WinSetPointer(HWND_DESKTOP, |
989 WinQuerySysPointer (HWND_DESKTOP, | 984 WinQuerySysPointer(HWND_DESKTOP, |
990 SPTR_ARROW, FALSE)); | 985 SPTR_ARROW, FALSE)); |
991 } else { | 986 } else { |
992 WinSetPointer (HWND_DESKTOP, NULL); | 987 WinSetPointer(HWND_DESKTOP, NULL); |
993 } | 988 } |
994 } | 989 } |
995 #ifdef DEBUG_BUILD | 990 #ifdef DEBUG_BUILD |
996 // printf("WM_MOUSEMOVE done\n"); fflush(stdout); | 991 // printf("WM_MOUSEMOVE done\n"); fflush(stdout); |
997 #endif | 992 #endif |
998 | 993 |
999 return (MRESULT) FALSE; | 994 return (MRESULT) FALSE; |
1000 case WM_CLOSE: // Window close | 995 case WM_CLOSE: // Window close |
1001 #ifdef DEBUG_BUILD | 996 #ifdef DEBUG_BUILD |
1002 printf ("WM_CLOSE\n"); | 997 printf("WM_CLOSE\n"); |
1003 fflush (stdout); | 998 fflush(stdout); |
1004 #endif | 999 #endif |
1005 | 1000 |
1006 pVideo = FSLib_GetUserParm (hwnd); | 1001 pVideo = FSLib_GetUserParm(hwnd); |
1007 if (pVideo) { | 1002 if (pVideo) { |
1008 // Send Quit message to the SDL application! | 1003 // Send Quit message to the SDL application! |
1009 SDL_PrivateQuit (); | 1004 SDL_PrivateQuit(); |
1010 return 0; | 1005 return 0; |
1011 } | 1006 } |
1012 break; | 1007 break; |
1013 | 1008 |
1014 #ifdef BITBLT_IN_WINMESSAGEPROC | 1009 #ifdef BITBLT_IN_WINMESSAGEPROC |
1015 case WM_UPDATERECTSREQUEST: | 1010 case WM_UPDATERECTSREQUEST: |
1016 pVideo = FSLib_GetUserParm (hwnd); | 1011 pVideo = FSLib_GetUserParm(hwnd); |
1017 if ((pVideo) && (pVideo->hidden->pSDLSurface)) { | 1012 if ((pVideo) && (pVideo->hidden->pSDLSurface)) { |
1018 if (DosRequestMutexSem | 1013 if (DosRequestMutexSem |
1019 (pVideo->hidden->hmtxUseSrcBuffer, | 1014 (pVideo->hidden->hmtxUseSrcBuffer, |
1020 SEM_INDEFINITE_WAIT) == NO_ERROR) { | 1015 SEM_INDEFINITE_WAIT) == NO_ERROR) { |
1021 int numrects; | 1016 int numrects; |
1024 SWP swp; | 1019 SWP swp; |
1025 | 1020 |
1026 numrects = (int) mp1; | 1021 numrects = (int) mp1; |
1027 rects = (SDL_Rect *) mp2; | 1022 rects = (SDL_Rect *) mp2; |
1028 | 1023 |
1029 WinQueryWindowPos (hwnd, &swp); | 1024 WinQueryWindowPos(hwnd, &swp); |
1030 #ifndef RESIZE_EVEN_IF_RESIZABLE | 1025 #ifndef RESIZE_EVEN_IF_RESIZABLE |
1031 if ((!pVideo->hidden->pSDLSurface) || | 1026 if ((!pVideo->hidden->pSDLSurface) || |
1032 ((pVideo->hidden->pSDLSurface) && | 1027 ((pVideo->hidden->pSDLSurface) && |
1033 (pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE) | 1028 (pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE) |
1034 && | 1029 && |
1035 ((swp.cx != pVideo->hidden->SrcBufferDesc.uiXResolution) | 1030 ((swp.cx != pVideo->hidden->SrcBufferDesc.uiXResolution) |
1036 || (swp.cy != | 1031 || (swp.cy != |
1037 pVideo->hidden->SrcBufferDesc.uiYResolution)) | 1032 pVideo->hidden->SrcBufferDesc.uiYResolution)) |
1038 && (!FSLib_QueryFSMode (hwnd)))) { | 1033 && (!FSLib_QueryFSMode(hwnd)))) { |
1039 // Resizable surface and in resizing! | 1034 // Resizable surface and in resizing! |
1040 // So, don't blit now! | 1035 // So, don't blit now! |
1041 #ifdef DEBUG_BUILD | 1036 #ifdef DEBUG_BUILD |
1042 printf | 1037 printf |
1043 ("[WM_UPDATERECTSREQUEST] : Skipping blit while resizing!\n"); | 1038 ("[WM_UPDATERECTSREQUEST] : Skipping blit while resizing!\n"); |
1044 fflush (stdout); | 1039 fflush(stdout); |
1045 #endif | 1040 #endif |
1046 } else | 1041 } else |
1047 #endif | 1042 #endif |
1048 { | 1043 { |
1049 #ifdef DEBUG_BUILD | 1044 #ifdef DEBUG_BUILD |
1050 printf ("[WM_UPDATERECTSREQUEST] : Blitting!\n"); | 1045 printf("[WM_UPDATERECTSREQUEST] : Blitting!\n"); |
1051 fflush (stdout); | 1046 fflush(stdout); |
1052 #endif | 1047 #endif |
1053 | 1048 |
1054 // Blit the changed areas | 1049 // Blit the changed areas |
1055 for (i = 0; i < numrects; i++) | 1050 for (i = 0; i < numrects; i++) |
1056 FSLIB_BITBLT (hwnd, | 1051 FSLIB_BITBLT(hwnd, |
1057 pVideo->hidden->pchSrcBuffer, | 1052 pVideo->hidden->pchSrcBuffer, |
1058 rects[i].y, rects[i].x, | 1053 rects[i].y, rects[i].x, |
1059 rects[i].w, rects[i].h); | 1054 rects[i].w, rects[i].h); |
1060 } | 1055 } |
1061 DosReleaseMutexSem (pVideo->hidden->hmtxUseSrcBuffer); | 1056 DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); |
1062 } | 1057 } |
1063 } | 1058 } |
1064 return 0; | 1059 return 0; |
1065 #endif | 1060 #endif |
1066 | 1061 |
1067 default: | 1062 default: |
1068 #ifdef DEBUG_BUILD | 1063 #ifdef DEBUG_BUILD |
1069 printf ("Unhandled: %x\n", msg); | 1064 printf("Unhandled: %x\n", msg); |
1070 fflush (stdout); | 1065 fflush(stdout); |
1071 #endif | 1066 #endif |
1072 | 1067 |
1073 break; | 1068 break; |
1074 } | 1069 } |
1075 // Run the default window procedure for unhandled stuffs | 1070 // Run the default window procedure for unhandled stuffs |
1076 return WinDefWindowProc (hwnd, msg, mp1, mp2); | 1071 return WinDefWindowProc(hwnd, msg, mp1, mp2); |
1077 } | 1072 } |
1078 | 1073 |
1079 ///////////////////////////////////////////////////////////////////// | 1074 ///////////////////////////////////////////////////////////////////// |
1080 // | 1075 // |
1081 // FrameWndProc | 1076 // FrameWndProc |
1083 // This is the message processing window procedure for the | 1078 // This is the message processing window procedure for the |
1084 // frame window of SDLWindowClass. | 1079 // frame window of SDLWindowClass. |
1085 // | 1080 // |
1086 ///////////////////////////////////////////////////////////////////// | 1081 ///////////////////////////////////////////////////////////////////// |
1087 static MRESULT EXPENTRY | 1082 static MRESULT EXPENTRY |
1088 FrameWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 1083 FrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) |
1089 { | 1084 { |
1090 PFNWP pOldFrameProc; | 1085 PFNWP pOldFrameProc; |
1091 MRESULT result; | 1086 MRESULT result; |
1092 PTRACKINFO ti; | 1087 PTRACKINFO ti; |
1093 int cx, cy, ncx, ncy; | 1088 int cx, cy, ncx, ncy; |
1094 RECTL rclTemp; | 1089 RECTL rclTemp; |
1095 PSWP pswpTemp; | 1090 PSWP pswpTemp; |
1096 | 1091 |
1097 SDL_VideoDevice *pVideo = NULL; | 1092 SDL_VideoDevice *pVideo = NULL; |
1098 | 1093 |
1099 pVideo = (SDL_VideoDevice *) WinQueryWindowULong (hwnd, QWL_USER); | 1094 pVideo = (SDL_VideoDevice *) WinQueryWindowULong(hwnd, QWL_USER); |
1100 | 1095 |
1101 pOldFrameProc = pVideo->hidden->pfnOldFrameProc; | 1096 pOldFrameProc = pVideo->hidden->pfnOldFrameProc; |
1102 | 1097 |
1103 if ((pVideo->hidden->bProportionalResize) && | 1098 if ((pVideo->hidden->bProportionalResize) && |
1104 (msg == WM_ADJUSTWINDOWPOS) && | 1099 (msg == WM_ADJUSTWINDOWPOS) && |
1105 (!FSLib_QueryFSMode (pVideo->hidden->hwndClient))) { | 1100 (!FSLib_QueryFSMode(pVideo->hidden->hwndClient))) { |
1106 pswpTemp = (PSWP) mp1; | 1101 pswpTemp = (PSWP) mp1; |
1107 | 1102 |
1108 /* Resizing? */ | 1103 /* Resizing? */ |
1109 if (pswpTemp->fl & SWP_SIZE) { | 1104 if (pswpTemp->fl & SWP_SIZE) { |
1110 /* Calculate client size */ | 1105 /* Calculate client size */ |
1111 rclTemp.xLeft = pswpTemp->x; | 1106 rclTemp.xLeft = pswpTemp->x; |
1112 rclTemp.xRight = pswpTemp->x + pswpTemp->cx; | 1107 rclTemp.xRight = pswpTemp->x + pswpTemp->cx; |
1113 rclTemp.yBottom = pswpTemp->y; | 1108 rclTemp.yBottom = pswpTemp->y; |
1114 rclTemp.yTop = pswpTemp->y + pswpTemp->cy; | 1109 rclTemp.yTop = pswpTemp->y + pswpTemp->cy; |
1115 WinCalcFrameRect (hwnd, &rclTemp, TRUE); | 1110 WinCalcFrameRect(hwnd, &rclTemp, TRUE); |
1116 | 1111 |
1117 ncx = cx = rclTemp.xRight - rclTemp.xLeft; | 1112 ncx = cx = rclTemp.xRight - rclTemp.xLeft; |
1118 ncy = cy = rclTemp.yTop - rclTemp.yBottom; | 1113 ncy = cy = rclTemp.yTop - rclTemp.yBottom; |
1119 | 1114 |
1120 /* Calculate new size to keep it proportional */ | 1115 /* Calculate new size to keep it proportional */ |
1136 /* Calculate back frame coordinates */ | 1131 /* Calculate back frame coordinates */ |
1137 rclTemp.xLeft = pswpTemp->x; | 1132 rclTemp.xLeft = pswpTemp->x; |
1138 rclTemp.xRight = pswpTemp->x + ncx; | 1133 rclTemp.xRight = pswpTemp->x + ncx; |
1139 rclTemp.yBottom = pswpTemp->y; | 1134 rclTemp.yBottom = pswpTemp->y; |
1140 rclTemp.yTop = pswpTemp->y + ncy; | 1135 rclTemp.yTop = pswpTemp->y + ncy; |
1141 WinCalcFrameRect (hwnd, &rclTemp, FALSE); | 1136 WinCalcFrameRect(hwnd, &rclTemp, FALSE); |
1142 | 1137 |
1143 /* Store new size/position info */ | 1138 /* Store new size/position info */ |
1144 pswpTemp->cx = rclTemp.xRight - rclTemp.xLeft; | 1139 pswpTemp->cx = rclTemp.xRight - rclTemp.xLeft; |
1145 | 1140 |
1146 if (!(pVideo->hidden->ulResizingFlag & TF_TOP)) { | 1141 if (!(pVideo->hidden->ulResizingFlag & TF_TOP)) { |
1176 // application window itself, the DIVE, and start message processing. | 1171 // application window itself, the DIVE, and start message processing. |
1177 // | 1172 // |
1178 ///////////////////////////////////////////////////////////////////// | 1173 ///////////////////////////////////////////////////////////////////// |
1179 int iNumOfPMThreadInstances = 0; // Global! | 1174 int iNumOfPMThreadInstances = 0; // Global! |
1180 static void | 1175 static void |
1181 PMThreadFunc (void *pParm) | 1176 PMThreadFunc(void *pParm) |
1182 { | 1177 { |
1183 SDL_VideoDevice *pVideo = pParm; | 1178 SDL_VideoDevice *pVideo = pParm; |
1184 HAB hab; | 1179 HAB hab; |
1185 HMQ hmq; | 1180 HMQ hmq; |
1186 QMSG msg; | 1181 QMSG msg; |
1187 ULONG fcf; | 1182 ULONG fcf; |
1188 | 1183 |
1189 #ifdef DEBUG_BUILD | 1184 #ifdef DEBUG_BUILD |
1190 printf ("[PMThreadFunc] : Starting\n"); | 1185 printf("[PMThreadFunc] : Starting\n"); |
1191 fflush (stdout); | 1186 fflush(stdout); |
1192 #endif | 1187 #endif |
1193 | 1188 |
1194 iNumOfPMThreadInstances++; | 1189 iNumOfPMThreadInstances++; |
1195 | 1190 |
1196 // Initialize PM, create a message queue. | 1191 // Initialize PM, create a message queue. |
1197 | 1192 |
1198 hab = WinInitialize (0); | 1193 hab = WinInitialize(0); |
1199 hmq = WinCreateMsgQueue (hab, 0); | 1194 hmq = WinCreateMsgQueue(hab, 0); |
1200 if (hmq == 0) { | 1195 if (hmq == 0) { |
1201 #ifdef DEBUG_BUILD | 1196 #ifdef DEBUG_BUILD |
1202 printf ("[PMThreadFunc] : Could not create message queue!\n"); | 1197 printf("[PMThreadFunc] : Could not create message queue!\n"); |
1203 printf | 1198 printf |
1204 (" It might be that the application using SDL is not a PM app!\n"); | 1199 (" It might be that the application using SDL is not a PM app!\n"); |
1205 fflush (stdout); | 1200 fflush(stdout); |
1206 #endif | 1201 #endif |
1207 pVideo->hidden->iPMThreadStatus = 2; | 1202 pVideo->hidden->iPMThreadStatus = 2; |
1208 } else { | 1203 } else { |
1209 int rc; | 1204 int rc; |
1210 RECTL rectl; | 1205 RECTL rectl; |
1211 | 1206 |
1212 fcf = ulFCFToUse; // Get from global setting | 1207 fcf = ulFCFToUse; // Get from global setting |
1213 | 1208 |
1214 #ifdef DEBUG_BUILD | 1209 #ifdef DEBUG_BUILD |
1215 printf ("[PMThreadFunc] : FSLib_CreateWindow()!\n"); | 1210 printf("[PMThreadFunc] : FSLib_CreateWindow()!\n"); |
1216 fflush (stdout); | 1211 fflush(stdout); |
1217 #endif | 1212 #endif |
1218 | 1213 |
1219 rc = FSLib_CreateWindow (HWND_DESKTOP, 0, &fcf, | 1214 rc = FSLib_CreateWindow(HWND_DESKTOP, 0, &fcf, |
1220 "SDL Application", | 1215 "SDL Application", |
1221 NULLHANDLE, 0, | 1216 NULLHANDLE, 0, |
1222 &(pVideo->hidden->SrcBufferDesc), | 1217 &(pVideo->hidden->SrcBufferDesc), |
1223 WndProc, | 1218 WndProc, |
1224 &(pVideo->hidden->hwndClient), | 1219 &(pVideo->hidden->hwndClient), |
1225 &(pVideo->hidden->hwndFrame)); | 1220 &(pVideo->hidden->hwndFrame)); |
1226 | 1221 |
1227 #ifdef DEBUG_BUILD | 1222 #ifdef DEBUG_BUILD |
1228 printf ("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc); | 1223 printf("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc); |
1229 fflush (stdout); | 1224 fflush(stdout); |
1230 #endif | 1225 #endif |
1231 | 1226 |
1232 if (!rc) { | 1227 if (!rc) { |
1233 #ifdef DEBUG_BUILD | 1228 #ifdef DEBUG_BUILD |
1234 printf ("[PMThreadFunc] : Could not create FSLib window!\n"); | 1229 printf("[PMThreadFunc] : Could not create FSLib window!\n"); |
1235 fflush (stdout); | 1230 fflush(stdout); |
1236 #endif | 1231 #endif |
1237 pVideo->hidden->iPMThreadStatus = 3; | 1232 pVideo->hidden->iPMThreadStatus = 3; |
1238 } else { | 1233 } else { |
1239 #ifdef DEBUG_BUILD | 1234 #ifdef DEBUG_BUILD |
1240 printf ("[PMThreadFunc] : FSLib_AddUserParm()!\n"); | 1235 printf("[PMThreadFunc] : FSLib_AddUserParm()!\n"); |
1241 fflush (stdout); | 1236 fflush(stdout); |
1242 #endif | 1237 #endif |
1243 | 1238 |
1244 // Store pVideo pointer in window data for client window, so | 1239 // Store pVideo pointer in window data for client window, so |
1245 // it will know the instance to which it belongs to. | 1240 // it will know the instance to which it belongs to. |
1246 FSLib_AddUserParm (pVideo->hidden->hwndClient, pVideo); | 1241 FSLib_AddUserParm(pVideo->hidden->hwndClient, pVideo); |
1247 | 1242 |
1248 // Now set default image width height and fourcc! | 1243 // Now set default image width height and fourcc! |
1249 #ifdef DEBUG_BUILD | 1244 #ifdef DEBUG_BUILD |
1250 printf ("[PMThreadFunc] : SetWindowPos()!\n"); | 1245 printf("[PMThreadFunc] : SetWindowPos()!\n"); |
1251 fflush (stdout); | 1246 fflush(stdout); |
1252 #endif | 1247 #endif |
1253 | 1248 |
1254 // Set the position and size of the main window, | 1249 // Set the position and size of the main window, |
1255 // and make it visible! | 1250 // and make it visible! |
1256 // Calculate frame window size from client window size | 1251 // Calculate frame window size from client window size |
1257 rectl.xLeft = 0; | 1252 rectl.xLeft = 0; |
1258 rectl.yBottom = 0; | 1253 rectl.yBottom = 0; |
1259 rectl.xRight = pVideo->hidden->SrcBufferDesc.uiXResolution; // Noninclusive | 1254 rectl.xRight = pVideo->hidden->SrcBufferDesc.uiXResolution; // Noninclusive |
1260 rectl.yTop = pVideo->hidden->SrcBufferDesc.uiYResolution; // Noninclusive | 1255 rectl.yTop = pVideo->hidden->SrcBufferDesc.uiYResolution; // Noninclusive |
1261 WinCalcFrameRect (pVideo->hidden->hwndFrame, &rectl, FALSE); | 1256 WinCalcFrameRect(pVideo->hidden->hwndFrame, &rectl, FALSE); |
1262 | 1257 |
1263 SetAccessableWindowPos (pVideo->hidden->hwndFrame, | 1258 SetAccessableWindowPos(pVideo->hidden->hwndFrame, |
1264 HWND_TOP, | 1259 HWND_TOP, |
1265 (WinQuerySysValue | 1260 (WinQuerySysValue |
1266 (HWND_DESKTOP, | 1261 (HWND_DESKTOP, |
1267 SV_CXSCREEN) - (rectl.xRight - | 1262 SV_CXSCREEN) - (rectl.xRight - |
1268 rectl.xLeft)) / 2, | 1263 rectl.xLeft)) / 2, |
1269 (WinQuerySysValue | 1264 (WinQuerySysValue |
1270 (HWND_DESKTOP, | 1265 (HWND_DESKTOP, |
1271 SV_CYSCREEN) - (rectl.yTop - | 1266 SV_CYSCREEN) - (rectl.yTop - |
1272 rectl.yBottom)) / 2, | 1267 rectl.yBottom)) / 2, |
1273 (rectl.xRight - rectl.xLeft), | 1268 (rectl.xRight - rectl.xLeft), |
1274 (rectl.yTop - rectl.yBottom), | 1269 (rectl.yTop - rectl.yBottom), |
1275 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | | 1270 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | |
1276 SWP_MOVE); | 1271 SWP_MOVE); |
1277 | 1272 |
1278 // Subclass frame procedure and store old window proc address | 1273 // Subclass frame procedure and store old window proc address |
1279 pVideo->hidden->pfnOldFrameProc = | 1274 pVideo->hidden->pfnOldFrameProc = |
1280 WinSubclassWindow (pVideo->hidden->hwndFrame, FrameWndProc); | 1275 WinSubclassWindow(pVideo->hidden->hwndFrame, FrameWndProc); |
1281 WinSetWindowULong (pVideo->hidden->hwndFrame, QWL_USER, | 1276 WinSetWindowULong(pVideo->hidden->hwndFrame, QWL_USER, |
1282 (ULONG) pVideo); | 1277 (ULONG) pVideo); |
1283 | 1278 |
1284 #ifdef DEBUG_BUILD | 1279 #ifdef DEBUG_BUILD |
1285 printf ("[PMThreadFunc] : Entering message loop\n"); | 1280 printf("[PMThreadFunc] : Entering message loop\n"); |
1286 fflush (stdout); | 1281 fflush(stdout); |
1287 #endif | 1282 #endif |
1288 pVideo->hidden->iPMThreadStatus = 1; | 1283 pVideo->hidden->iPMThreadStatus = 1; |
1289 | 1284 |
1290 while (WinGetMsg (hab, (PQMSG) & msg, 0, 0, 0)) | 1285 while (WinGetMsg(hab, (PQMSG) & msg, 0, 0, 0)) |
1291 WinDispatchMsg (hab, (PQMSG) & msg); | 1286 WinDispatchMsg(hab, (PQMSG) & msg); |
1292 | 1287 |
1293 #ifdef DEBUG_BUILD | 1288 #ifdef DEBUG_BUILD |
1294 printf ("[PMThreadFunc] : Leaving message loop\n"); | 1289 printf("[PMThreadFunc] : Leaving message loop\n"); |
1295 fflush (stdout); | 1290 fflush(stdout); |
1296 #endif | 1291 #endif |
1297 // We should release the captured the mouse! | 1292 // We should release the captured the mouse! |
1298 if (bMouseCaptured) { | 1293 if (bMouseCaptured) { |
1299 WinSetCapture (HWND_DESKTOP, NULLHANDLE); | 1294 WinSetCapture(HWND_DESKTOP, NULLHANDLE); |
1300 bMouseCaptured = 0; | 1295 bMouseCaptured = 0; |
1301 } | 1296 } |
1302 // Destroy our window | 1297 // Destroy our window |
1303 WinDestroyWindow (pVideo->hidden->hwndFrame); | 1298 WinDestroyWindow(pVideo->hidden->hwndFrame); |
1304 pVideo->hidden->hwndFrame = NULL; | 1299 pVideo->hidden->hwndFrame = NULL; |
1305 // Show pointer to make sure it will not be left hidden. | 1300 // Show pointer to make sure it will not be left hidden. |
1306 WinSetPointer (HWND_DESKTOP, | 1301 WinSetPointer(HWND_DESKTOP, |
1307 WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, | 1302 WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, |
1308 FALSE)); | 1303 FALSE)); |
1309 WinShowPointer (HWND_DESKTOP, TRUE); | 1304 WinShowPointer(HWND_DESKTOP, TRUE); |
1310 } | 1305 } |
1311 // Uninitialize PM | 1306 // Uninitialize PM |
1312 WinDestroyMsgQueue (hmq); | 1307 WinDestroyMsgQueue(hmq); |
1313 // All done! | 1308 // All done! |
1314 pVideo->hidden->iPMThreadStatus = 0; | 1309 pVideo->hidden->iPMThreadStatus = 0; |
1315 } | 1310 } |
1316 WinTerminate (hab); | 1311 WinTerminate(hab); |
1317 /* Commented out, should not be needed anymore, because we send it | 1312 /* Commented out, should not be needed anymore, because we send it |
1318 from WM_CLOSE. | 1313 from WM_CLOSE. |
1319 // Notify SDL that it should really die now... | 1314 // Notify SDL that it should really die now... |
1320 SDL_PrivateQuit(); SDL_PrivateQuit(); SDL_PrivateQuit(); //... :)) | 1315 SDL_PrivateQuit(); SDL_PrivateQuit(); SDL_PrivateQuit(); //... :)) |
1321 */ | 1316 */ |
1322 #ifdef DEBUG_BUILD | 1317 #ifdef DEBUG_BUILD |
1323 printf ("[PMThreadFunc] : End, status is %d!\n", | 1318 printf("[PMThreadFunc] : End, status is %d!\n", |
1324 pVideo->hidden->iPMThreadStatus); | 1319 pVideo->hidden->iPMThreadStatus); |
1325 fflush (stdout); | 1320 fflush(stdout); |
1326 #endif | 1321 #endif |
1327 | 1322 |
1328 iNumOfPMThreadInstances--; | 1323 iNumOfPMThreadInstances--; |
1329 | 1324 |
1330 // HACK to prevent zombie and hanging SDL applications, which does not take | 1325 // HACK to prevent zombie and hanging SDL applications, which does not take |
1334 // I've thought about the following: | 1329 // I've thought about the following: |
1335 // If the window is closed (the execution came here), I wait a bit to | 1330 // If the window is closed (the execution came here), I wait a bit to |
1336 // give time to the app to finish its execution. If it does not, I kill it | 1331 // give time to the app to finish its execution. If it does not, I kill it |
1337 // using DosExit(). Brute force, but should work. | 1332 // using DosExit(). Brute force, but should work. |
1338 if (pVideo->hidden->iPMThreadStatus == 0) { | 1333 if (pVideo->hidden->iPMThreadStatus == 0) { |
1339 DosSleep (5000); // Wait 5 secs | 1334 DosSleep(5000); // Wait 5 secs |
1340 // If a new PM thread has been spawned (reinitializing video mode), then all right. | 1335 // If a new PM thread has been spawned (reinitializing video mode), then all right. |
1341 // Otherwise, we have a problem, the app doesn't want to stop. Kill! | 1336 // Otherwise, we have a problem, the app doesn't want to stop. Kill! |
1342 if (iNumOfPMThreadInstances == 0) { | 1337 if (iNumOfPMThreadInstances == 0) { |
1343 #ifdef DEBUG_BUILD | 1338 #ifdef DEBUG_BUILD |
1344 printf | 1339 printf |
1345 ("[PMThreadFunc] : It seems that the application haven't terminated itself\n"); | 1340 ("[PMThreadFunc] : It seems that the application haven't terminated itself\n"); |
1346 fflush (stdout); | 1341 fflush(stdout); |
1347 printf | 1342 printf |
1348 ("[PMThreadFunc] : in the last 5 seconds, so we go berserk.\n"); | 1343 ("[PMThreadFunc] : in the last 5 seconds, so we go berserk.\n"); |
1349 fflush (stdout); | 1344 fflush(stdout); |
1350 printf | 1345 printf |
1351 ("[PMThreadFunc] : Brute force mode. :) Killing process! Dieeeee...\n"); | 1346 ("[PMThreadFunc] : Brute force mode. :) Killing process! Dieeeee...\n"); |
1352 fflush (stdout); | 1347 fflush(stdout); |
1353 #endif | 1348 #endif |
1354 DosExit (EXIT_PROCESS, -1); | 1349 DosExit(EXIT_PROCESS, -1); |
1355 } | 1350 } |
1356 } | 1351 } |
1357 _endthread (); | 1352 _endthread(); |
1358 } | 1353 } |
1359 | 1354 |
1360 struct WMcursor | 1355 struct WMcursor |
1361 { | 1356 { |
1362 HBITMAP hbm; | 1357 HBITMAP hbm; |
1364 char *pchData; | 1359 char *pchData; |
1365 }; | 1360 }; |
1366 | 1361 |
1367 /* Free a window manager cursor */ | 1362 /* Free a window manager cursor */ |
1368 void | 1363 void |
1369 os2fslib_FreeWMCursor (_THIS, WMcursor * cursor) | 1364 os2fslib_FreeWMCursor(_THIS, WMcursor * cursor) |
1370 { | 1365 { |
1371 if (cursor) { | 1366 if (cursor) { |
1372 GpiDeleteBitmap (cursor->hbm); | 1367 GpiDeleteBitmap(cursor->hbm); |
1373 WinDestroyPointer (cursor->hptr); | 1368 WinDestroyPointer(cursor->hptr); |
1374 SDL_free (cursor->pchData); | 1369 SDL_free(cursor->pchData); |
1375 SDL_free (cursor); | 1370 SDL_free(cursor); |
1376 } | 1371 } |
1377 } | 1372 } |
1378 | 1373 |
1379 /* Local functions to convert the SDL cursor mask into OS/2 format */ | 1374 /* Local functions to convert the SDL cursor mask into OS/2 format */ |
1380 static void | 1375 static void |
1381 memnot (Uint8 * dst, Uint8 * src, int len) | 1376 memnot(Uint8 * dst, Uint8 * src, int len) |
1382 { | 1377 { |
1383 while (len-- > 0) | 1378 while (len-- > 0) |
1384 *dst++ = ~*src++; | 1379 *dst++ = ~*src++; |
1385 } | 1380 } |
1386 static void | 1381 static void |
1387 memxor (Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) | 1382 memxor(Uint8 * dst, Uint8 * src1, Uint8 * src2, int len) |
1388 { | 1383 { |
1389 while (len-- > 0) | 1384 while (len-- > 0) |
1390 *dst++ = (*src1++) ^ (*src2++); | 1385 *dst++ = (*src1++) ^ (*src2++); |
1391 } | 1386 } |
1392 | 1387 |
1393 /* Create a black/white window manager cursor */ | 1388 /* Create a black/white window manager cursor */ |
1394 WMcursor * | 1389 WMcursor * |
1395 os2fslib_CreateWMCursor_Win (_THIS, Uint8 * data, Uint8 * mask, | 1390 os2fslib_CreateWMCursor_Win(_THIS, Uint8 * data, Uint8 * mask, |
1396 int w, int h, int hot_x, int hot_y) | 1391 int w, int h, int hot_x, int hot_y) |
1397 { | 1392 { |
1398 HPOINTER hptr; | 1393 HPOINTER hptr; |
1399 HBITMAP hbm; | 1394 HBITMAP hbm; |
1400 BITMAPINFOHEADER bmih; | 1395 BITMAPINFOHEADER bmih; |
1401 BMPINFO bmi; | 1396 BMPINFO bmi; |
1404 char *xptr, *aptr; | 1399 char *xptr, *aptr; |
1405 int maxx, maxy; | 1400 int maxx, maxy; |
1406 int i, run, pad; | 1401 int i, run, pad; |
1407 WMcursor *pResult; | 1402 WMcursor *pResult; |
1408 | 1403 |
1409 maxx = WinQuerySysValue (HWND_DESKTOP, SV_CXPOINTER); | 1404 maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXPOINTER); |
1410 maxy = WinQuerySysValue (HWND_DESKTOP, SV_CYPOINTER); | 1405 maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYPOINTER); |
1411 | 1406 |
1412 // Check for max size! | 1407 // Check for max size! |
1413 if ((w > maxx) || (h > maxy)) | 1408 if ((w > maxx) || (h > maxy)) |
1414 return (WMcursor *) NULL; | 1409 return (WMcursor *) NULL; |
1415 | 1410 |
1416 pResult = (WMcursor *) SDL_malloc (sizeof (WMcursor)); | 1411 pResult = (WMcursor *) SDL_malloc(sizeof(WMcursor)); |
1417 if (!pResult) | 1412 if (!pResult) |
1418 return (WMcursor *) NULL; | 1413 return (WMcursor *) NULL; |
1419 | 1414 |
1420 pchTemp = (char *) SDL_malloc ((maxx + 7) / 8 * maxy * 2); | 1415 pchTemp = (char *) SDL_malloc((maxx + 7) / 8 * maxy * 2); |
1421 if (!pchTemp) { | 1416 if (!pchTemp) { |
1422 SDL_free (pResult); | 1417 SDL_free(pResult); |
1423 return (WMcursor *) NULL; | 1418 return (WMcursor *) NULL; |
1424 } | 1419 } |
1425 | 1420 |
1426 SDL_memset (pchTemp, 0, (maxx + 7) / 8 * maxy * 2); | 1421 SDL_memset(pchTemp, 0, (maxx + 7) / 8 * maxy * 2); |
1427 | 1422 |
1428 hps = WinGetPS (_this->hidden->hwndClient); | 1423 hps = WinGetPS(_this->hidden->hwndClient); |
1429 | 1424 |
1430 bmi.cbFix = sizeof (BITMAPINFOHEADER); | 1425 bmi.cbFix = sizeof(BITMAPINFOHEADER); |
1431 bmi.cx = maxx; | 1426 bmi.cx = maxx; |
1432 bmi.cy = 2 * maxy; | 1427 bmi.cy = 2 * maxy; |
1433 bmi.cPlanes = 1; | 1428 bmi.cPlanes = 1; |
1434 bmi.cBitCount = 1; | 1429 bmi.cBitCount = 1; |
1435 bmi.argbColor[0].bBlue = 0x00; | 1430 bmi.argbColor[0].bBlue = 0x00; |
1437 bmi.argbColor[0].bRed = 0x00; | 1432 bmi.argbColor[0].bRed = 0x00; |
1438 bmi.argbColor[1].bBlue = 0x00; | 1433 bmi.argbColor[1].bBlue = 0x00; |
1439 bmi.argbColor[1].bGreen = 0x00; | 1434 bmi.argbColor[1].bGreen = 0x00; |
1440 bmi.argbColor[1].bRed = 0xff; | 1435 bmi.argbColor[1].bRed = 0xff; |
1441 | 1436 |
1442 SDL_memset (&bmih, 0, sizeof (BITMAPINFOHEADER)); | 1437 SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); |
1443 bmih.cbFix = sizeof (BITMAPINFOHEADER); | 1438 bmih.cbFix = sizeof(BITMAPINFOHEADER); |
1444 bmih.cx = maxx; | 1439 bmih.cx = maxx; |
1445 bmih.cy = 2 * maxy; | 1440 bmih.cy = 2 * maxy; |
1446 bmih.cPlanes = 1; | 1441 bmih.cPlanes = 1; |
1447 bmih.cBitCount = 1; | 1442 bmih.cBitCount = 1; |
1448 | 1443 |
1450 pad = (maxx + 7) / 8 - run; | 1445 pad = (maxx + 7) / 8 - run; |
1451 | 1446 |
1452 for (i = 0; i < h; i++) { | 1447 for (i = 0; i < h; i++) { |
1453 xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); | 1448 xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); |
1454 aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); | 1449 aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); |
1455 memxor (xptr, data, mask, run); | 1450 memxor(xptr, data, mask, run); |
1456 xptr += run; | 1451 xptr += run; |
1457 data += run; | 1452 data += run; |
1458 memnot (aptr, mask, run); | 1453 memnot(aptr, mask, run); |
1459 mask += run; | 1454 mask += run; |
1460 aptr += run; | 1455 aptr += run; |
1461 SDL_memset (xptr, 0, pad); | 1456 SDL_memset(xptr, 0, pad); |
1462 xptr += pad; | 1457 xptr += pad; |
1463 SDL_memset (aptr, ~0, pad); | 1458 SDL_memset(aptr, ~0, pad); |
1464 aptr += pad; | 1459 aptr += pad; |
1465 } | 1460 } |
1466 pad += run; | 1461 pad += run; |
1467 for (i = h; i < maxy; i++) { | 1462 for (i = h; i < maxy; i++) { |
1468 xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); | 1463 xptr = pchTemp + (maxx + 7) / 8 * (maxy - 1 - i); |
1469 aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); | 1464 aptr = pchTemp + (maxx + 7) / 8 * (maxy + maxy - 1 - i); |
1470 | 1465 |
1471 SDL_memset (xptr, 0, (maxx + 7) / 8); | 1466 SDL_memset(xptr, 0, (maxx + 7) / 8); |
1472 xptr += (maxx + 7) / 8; | 1467 xptr += (maxx + 7) / 8; |
1473 SDL_memset (aptr, ~0, (maxx + 7) / 8); | 1468 SDL_memset(aptr, ~0, (maxx + 7) / 8); |
1474 aptr += (maxx + 7) / 8; | 1469 aptr += (maxx + 7) / 8; |
1475 } | 1470 } |
1476 | 1471 |
1477 hbm = | 1472 hbm = |
1478 GpiCreateBitmap (hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, | 1473 GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, |
1479 (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); | 1474 (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); |
1480 hptr = | 1475 hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, hot_x, maxy - hot_y - 1); |
1481 WinCreatePointer (HWND_DESKTOP, hbm, TRUE, hot_x, maxy - hot_y - 1); | 1476 |
1482 | 1477 #ifdef DEBUG_BUILD |
1483 #ifdef DEBUG_BUILD | 1478 printf("HotSpot : %d ; %d\n", hot_x, hot_y); |
1484 printf ("HotSpot : %d ; %d\n", hot_x, hot_y); | 1479 printf("HPS returned : %x\n", (ULONG) hps); |
1485 printf ("HPS returned : %x\n", (ULONG) hps); | 1480 printf("HBITMAP returned : %x\n", (ULONG) hbm); |
1486 printf ("HBITMAP returned : %x\n", (ULONG) hbm); | 1481 printf("HPOINTER returned: %x\n", (ULONG) hptr); |
1487 printf ("HPOINTER returned: %x\n", (ULONG) hptr); | 1482 #endif |
1488 #endif | 1483 |
1489 | 1484 WinReleasePS(hps); |
1490 WinReleasePS (hps); | 1485 |
1491 | 1486 #ifdef DEBUG_BUILD |
1492 #ifdef DEBUG_BUILD | 1487 printf("[CreateWMCursor] : ptr = %p\n", hptr); |
1493 printf ("[CreateWMCursor] : ptr = %p\n", hptr); | 1488 fflush(stdout); |
1494 fflush (stdout); | |
1495 #endif | 1489 #endif |
1496 | 1490 |
1497 pResult->hptr = hptr; | 1491 pResult->hptr = hptr; |
1498 pResult->hbm = hbm; | 1492 pResult->hbm = hbm; |
1499 pResult->pchData = pchTemp; | 1493 pResult->pchData = pchTemp; |
1500 | 1494 |
1501 #ifdef DEBUG_BUILD | 1495 #ifdef DEBUG_BUILD |
1502 printf ("[CreateWMCursor] : ptr = %p return.\n", hptr); | 1496 printf("[CreateWMCursor] : ptr = %p return.\n", hptr); |
1503 fflush (stdout); | 1497 fflush(stdout); |
1504 #endif | 1498 #endif |
1505 | 1499 |
1506 return (WMcursor *) pResult; | 1500 return (WMcursor *) pResult; |
1507 } | 1501 } |
1508 | 1502 |
1509 WMcursor * | 1503 WMcursor * |
1510 os2fslib_CreateWMCursor_FS (_THIS, Uint8 * data, Uint8 * mask, | 1504 os2fslib_CreateWMCursor_FS(_THIS, Uint8 * data, Uint8 * mask, |
1511 int w, int h, int hot_x, int hot_y) | 1505 int w, int h, int hot_x, int hot_y) |
1512 { | 1506 { |
1513 #ifdef DEBUG_BUILD | 1507 #ifdef DEBUG_BUILD |
1514 printf ("[CreateWMCursor_FS] : returning pointer NULL\n"); | 1508 printf("[CreateWMCursor_FS] : returning pointer NULL\n"); |
1515 fflush (stdout); | 1509 fflush(stdout); |
1516 #endif | 1510 #endif |
1517 | 1511 |
1518 // In FS mode we'll use software cursor | 1512 // In FS mode we'll use software cursor |
1519 return (WMcursor *) NULL; | 1513 return (WMcursor *) NULL; |
1520 } | 1514 } |
1521 | 1515 |
1522 /* Show the specified cursor, or hide if cursor is NULL */ | 1516 /* Show the specified cursor, or hide if cursor is NULL */ |
1523 int | 1517 int |
1524 os2fslib_ShowWMCursor (_THIS, WMcursor * cursor) | 1518 os2fslib_ShowWMCursor(_THIS, WMcursor * cursor) |
1525 { | 1519 { |
1526 #ifdef DEBUG_BUILD | 1520 #ifdef DEBUG_BUILD |
1527 printf ("[ShowWMCursor] : ptr = %p\n", cursor); | 1521 printf("[ShowWMCursor] : ptr = %p\n", cursor); |
1528 fflush (stdout); | 1522 fflush(stdout); |
1529 #endif | 1523 #endif |
1530 | 1524 |
1531 if (cursor) { | 1525 if (cursor) { |
1532 WinSetPointer (HWND_DESKTOP, cursor->hptr); | 1526 WinSetPointer(HWND_DESKTOP, cursor->hptr); |
1533 hptrGlobalPointer = cursor->hptr; | 1527 hptrGlobalPointer = cursor->hptr; |
1534 _this->hidden->iMouseVisible = 1; | 1528 _this->hidden->iMouseVisible = 1; |
1535 } else { | 1529 } else { |
1536 WinSetPointer (HWND_DESKTOP, FALSE); | 1530 WinSetPointer(HWND_DESKTOP, FALSE); |
1537 hptrGlobalPointer = NULL; | 1531 hptrGlobalPointer = NULL; |
1538 _this->hidden->iMouseVisible = 0; | 1532 _this->hidden->iMouseVisible = 0; |
1539 } | 1533 } |
1540 | 1534 |
1541 #ifdef DEBUG_BUILD | 1535 #ifdef DEBUG_BUILD |
1542 printf ("[ShowWMCursor] : ptr = %p, DONE\n", cursor); | 1536 printf("[ShowWMCursor] : ptr = %p, DONE\n", cursor); |
1543 fflush (stdout); | 1537 fflush(stdout); |
1544 #endif | 1538 #endif |
1545 | 1539 |
1546 return 1; | 1540 return 1; |
1547 } | 1541 } |
1548 | 1542 |
1549 /* Warp the window manager cursor to (x,y) | 1543 /* Warp the window manager cursor to (x,y) |
1550 If NULL, a mouse motion event is posted internally. | 1544 If NULL, a mouse motion event is posted internally. |
1551 */ | 1545 */ |
1552 void | 1546 void |
1553 os2fslib_WarpWMCursor (_THIS, Uint16 x, Uint16 y) | 1547 os2fslib_WarpWMCursor(_THIS, Uint16 x, Uint16 y) |
1554 { | 1548 { |
1555 LONG lx, ly; | 1549 LONG lx, ly; |
1556 SWP swpClient; | 1550 SWP swpClient; |
1557 POINTL ptlPoints; | 1551 POINTL ptlPoints; |
1558 WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); | 1552 WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); |
1559 ptlPoints.x = swpClient.x; | 1553 ptlPoints.x = swpClient.x; |
1560 ptlPoints.y = swpClient.y; | 1554 ptlPoints.y = swpClient.y; |
1561 WinMapWindowPoints (_this->hidden->hwndFrame, HWND_DESKTOP, &ptlPoints, | 1555 WinMapWindowPoints(_this->hidden->hwndFrame, HWND_DESKTOP, &ptlPoints, 1); |
1562 1); | |
1563 lx = ptlPoints.x + | 1556 lx = ptlPoints.x + |
1564 (x * swpClient.cx) / _this->hidden->SrcBufferDesc.uiXResolution; | 1557 (x * swpClient.cx) / _this->hidden->SrcBufferDesc.uiXResolution; |
1565 ly = ptlPoints.y + swpClient.cy - | 1558 ly = ptlPoints.y + swpClient.cy - |
1566 ((y * swpClient.cy) / _this->hidden->SrcBufferDesc.uiYResolution) - 1; | 1559 ((y * swpClient.cy) / _this->hidden->SrcBufferDesc.uiYResolution) - 1; |
1567 | 1560 |
1568 SDL_PrivateMouseMotion (0, // Buttons not changed | 1561 SDL_PrivateMouseMotion(0, // Buttons not changed |
1569 0, // Absolute position | 1562 0, // Absolute position |
1570 x, y); | 1563 x, y); |
1571 | 1564 |
1572 WinSetPointerPos (HWND_DESKTOP, lx, ly); | 1565 WinSetPointerPos(HWND_DESKTOP, lx, ly); |
1573 | 1566 |
1574 } | 1567 } |
1575 | 1568 |
1576 /* If not NULL, this is called when a mouse motion event occurs */ | 1569 /* If not NULL, this is called when a mouse motion event occurs */ |
1577 void | 1570 void |
1578 os2fslib_MoveWMCursor (_THIS, int x, int y) | 1571 os2fslib_MoveWMCursor(_THIS, int x, int y) |
1579 { | 1572 { |
1580 /* | 1573 /* |
1581 SDL_Rect rect; | 1574 SDL_Rect rect; |
1582 | 1575 |
1583 #ifdef DEBUG_BUILD | 1576 #ifdef DEBUG_BUILD |
1599 If the cursor is not visible, and the input is grabbed, the | 1592 If the cursor is not visible, and the input is grabbed, the |
1600 driver can place the mouse in relative mode, which may result | 1593 driver can place the mouse in relative mode, which may result |
1601 in higher accuracy sampling of the pointer motion. | 1594 in higher accuracy sampling of the pointer motion. |
1602 */ | 1595 */ |
1603 void | 1596 void |
1604 os2fslib_CheckMouseMode (_THIS) | 1597 os2fslib_CheckMouseMode(_THIS) |
1605 { | 1598 { |
1606 } | 1599 } |
1607 | 1600 |
1608 static void | 1601 static void |
1609 os2fslib_PumpEvents (_THIS) | 1602 os2fslib_PumpEvents(_THIS) |
1610 { | 1603 { |
1611 // Notify SDL that if window has been resized! | 1604 // Notify SDL that if window has been resized! |
1612 if ((_this->hidden->pSDLSurface) && | 1605 if ((_this->hidden->pSDLSurface) && |
1613 (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) && | 1606 (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) && |
1614 ((_this->hidden->SrcBufferDesc.uiXResolution != iWindowSizeX) || | 1607 ((_this->hidden->SrcBufferDesc.uiXResolution != iWindowSizeX) || |
1615 (_this->hidden->SrcBufferDesc.uiYResolution != iWindowSizeY)) && | 1608 (_this->hidden->SrcBufferDesc.uiYResolution != iWindowSizeY)) && |
1616 (iWindowSizeX > 0) && (iWindowSizeY > 0)) { | 1609 (iWindowSizeX > 0) && (iWindowSizeY > 0)) { |
1617 static time_t prev_time; | 1610 static time_t prev_time; |
1618 time_t curr_time; | 1611 time_t curr_time; |
1619 | 1612 |
1620 curr_time = time (NULL); | 1613 curr_time = time(NULL); |
1621 if ((difftime (curr_time, prev_time) >= 0.25) || (bWindowResized)) { | 1614 if ((difftime(curr_time, prev_time) >= 0.25) || (bWindowResized)) { |
1622 // Make sure we won't flood the event queue with resize events, | 1615 // Make sure we won't flood the event queue with resize events, |
1623 // only send them at 250 msecs! | 1616 // only send them at 250 msecs! |
1624 // (or when the window is resized) | 1617 // (or when the window is resized) |
1625 #ifdef DEBUG_BUILD | 1618 #ifdef DEBUG_BUILD |
1626 printf | 1619 printf |
1627 ("[os2fslib_PumpEvents] : Calling PrivateResize (%d %d).\n", | 1620 ("[os2fslib_PumpEvents] : Calling PrivateResize (%d %d).\n", |
1628 iWindowSizeX, iWindowSizeY); | 1621 iWindowSizeX, iWindowSizeY); |
1629 fflush (stdout); | 1622 fflush(stdout); |
1630 #endif | 1623 #endif |
1631 // Tell SDL the new size | 1624 // Tell SDL the new size |
1632 SDL_PrivateResize (iWindowSizeX, iWindowSizeY); | 1625 SDL_PrivateResize(iWindowSizeX, iWindowSizeY); |
1633 prev_time = curr_time; | 1626 prev_time = curr_time; |
1634 bWindowResized = 0; | 1627 bWindowResized = 0; |
1635 } | 1628 } |
1636 } | 1629 } |
1637 } | 1630 } |
1638 | 1631 |
1639 /* We don't actually allow hardware surfaces other than the main one */ | 1632 /* We don't actually allow hardware surfaces other than the main one */ |
1640 static int | 1633 static int |
1641 os2fslib_AllocHWSurface (_THIS, SDL_Surface * surface) | 1634 os2fslib_AllocHWSurface(_THIS, SDL_Surface * surface) |
1642 { | 1635 { |
1643 return (-1); | 1636 return (-1); |
1644 } | 1637 } |
1645 static void | 1638 static void |
1646 os2fslib_FreeHWSurface (_THIS, SDL_Surface * surface) | 1639 os2fslib_FreeHWSurface(_THIS, SDL_Surface * surface) |
1647 { | 1640 { |
1648 return; | 1641 return; |
1649 } | 1642 } |
1650 | 1643 |
1651 /* We need to wait for vertical retrace on page flipped displays */ | 1644 /* We need to wait for vertical retrace on page flipped displays */ |
1652 static int | 1645 static int |
1653 os2fslib_LockHWSurface (_THIS, SDL_Surface * surface) | 1646 os2fslib_LockHWSurface(_THIS, SDL_Surface * surface) |
1654 { | 1647 { |
1655 return (0); | 1648 return (0); |
1656 } | 1649 } |
1657 | 1650 |
1658 static void | 1651 static void |
1659 os2fslib_UnlockHWSurface (_THIS, SDL_Surface * surface) | 1652 os2fslib_UnlockHWSurface(_THIS, SDL_Surface * surface) |
1660 { | 1653 { |
1661 return; | 1654 return; |
1662 } | 1655 } |
1663 | 1656 |
1664 static int | 1657 static int |
1665 os2fslib_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) | 1658 os2fslib_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
1666 { | 1659 { |
1667 printf ("[os2fslib_SetColors] : TODO!\n"); | 1660 printf("[os2fslib_SetColors] : TODO!\n"); |
1668 fflush (stdout); | 1661 fflush(stdout); |
1669 // TODO: Implement paletted modes | 1662 // TODO: Implement paletted modes |
1670 return (1); | 1663 return (1); |
1671 } | 1664 } |
1672 | 1665 |
1673 static void | 1666 static void |
1674 os2fslib_DestroyIcon (HWND hwndFrame) | 1667 os2fslib_DestroyIcon(HWND hwndFrame) |
1675 { | 1668 { |
1676 if (hptrCurrentIcon) { | 1669 if (hptrCurrentIcon) { |
1677 WinDestroyPointer (hptrCurrentIcon); | 1670 WinDestroyPointer(hptrCurrentIcon); |
1678 hptrCurrentIcon = NULL; | 1671 hptrCurrentIcon = NULL; |
1679 | 1672 |
1680 WinSendMsg (hwndFrame, WM_SETICON, NULL, NULL); | 1673 WinSendMsg(hwndFrame, WM_SETICON, NULL, NULL); |
1681 } | 1674 } |
1682 | 1675 |
1683 } | 1676 } |
1684 | 1677 |
1685 /* Set the window icon image */ | 1678 /* Set the window icon image */ |
1686 void | 1679 void |
1687 os2fslib_SetIcon (_THIS, SDL_Surface * icon, Uint8 * mask) | 1680 os2fslib_SetIcon(_THIS, SDL_Surface * icon, Uint8 * mask) |
1688 { | 1681 { |
1689 HWND hwndFrame; | 1682 HWND hwndFrame; |
1690 SDL_Surface *icon_rgb; | 1683 SDL_Surface *icon_rgb; |
1691 HPOINTER hptrIcon; | 1684 HPOINTER hptrIcon; |
1692 HBITMAP hbm; | 1685 HBITMAP hbm; |
1697 char *pptr, *mptr, *dptr, *dmptr; | 1690 char *pptr, *mptr, *dptr, *dmptr; |
1698 int maxx, maxy, w, h, x, y; | 1691 int maxx, maxy, w, h, x, y; |
1699 SDL_Rect bounds; | 1692 SDL_Rect bounds; |
1700 | 1693 |
1701 #ifdef DEBUG_BUILD | 1694 #ifdef DEBUG_BUILD |
1702 printf ("[os2fslib_SetIcon] : Creating and setting new icon\n"); | 1695 printf("[os2fslib_SetIcon] : Creating and setting new icon\n"); |
1703 fflush (stdout); | 1696 fflush(stdout); |
1704 #endif | 1697 #endif |
1705 | 1698 |
1706 hwndFrame = WinQueryWindow (_this->hidden->hwndClient, QW_PARENT); | 1699 hwndFrame = WinQueryWindow(_this->hidden->hwndClient, QW_PARENT); |
1707 | 1700 |
1708 // Make sure the old icon resource will be free'd! | 1701 // Make sure the old icon resource will be free'd! |
1709 os2fslib_DestroyIcon (hwndFrame); | 1702 os2fslib_DestroyIcon(hwndFrame); |
1710 | 1703 |
1711 if ((!icon) || (!mask)) | 1704 if ((!icon) || (!mask)) |
1712 return; | 1705 return; |
1713 | 1706 |
1714 w = icon->w; | 1707 w = icon->w; |
1715 h = icon->h; | 1708 h = icon->h; |
1716 | 1709 |
1717 maxx = WinQuerySysValue (HWND_DESKTOP, SV_CXICON); | 1710 maxx = WinQuerySysValue(HWND_DESKTOP, SV_CXICON); |
1718 maxy = WinQuerySysValue (HWND_DESKTOP, SV_CYICON); | 1711 maxy = WinQuerySysValue(HWND_DESKTOP, SV_CYICON); |
1719 | 1712 |
1720 // Check for max size! | 1713 // Check for max size! |
1721 if ((w > maxx) || (h > maxy)) | 1714 if ((w > maxx) || (h > maxy)) |
1722 return; | 1715 return; |
1723 | 1716 |
1724 pchTemp = (char *) SDL_malloc (w * h * 2 * 4); | 1717 pchTemp = (char *) SDL_malloc(w * h * 2 * 4); |
1725 if (!pchTemp) | 1718 if (!pchTemp) |
1726 return; | 1719 return; |
1727 | 1720 |
1728 SDL_memset (pchTemp, 0, w * h * 2 * 4); | 1721 SDL_memset(pchTemp, 0, w * h * 2 * 4); |
1729 | 1722 |
1730 // Convert surface to RGB, if it's not RGB yet! | 1723 // Convert surface to RGB, if it's not RGB yet! |
1731 icon_rgb = SDL_CreateRGBSurface (SDL_SWSURFACE, icon->w, icon->h, | 1724 icon_rgb = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, |
1732 32, 0, 0, 0, 0); | 1725 32, 0, 0, 0, 0); |
1733 if (icon_rgb == NULL) { | 1726 if (icon_rgb == NULL) { |
1734 SDL_free (pchTemp); | 1727 SDL_free(pchTemp); |
1735 return; | 1728 return; |
1736 } | 1729 } |
1737 bounds.x = 0; | 1730 bounds.x = 0; |
1738 bounds.y = 0; | 1731 bounds.y = 0; |
1739 bounds.w = icon->w; | 1732 bounds.w = icon->w; |
1740 bounds.h = icon->h; | 1733 bounds.h = icon->h; |
1741 if (SDL_LowerBlit (icon, &bounds, icon_rgb, &bounds) < 0) { | 1734 if (SDL_LowerBlit(icon, &bounds, icon_rgb, &bounds) < 0) { |
1742 SDL_FreeSurface (icon_rgb); | 1735 SDL_FreeSurface(icon_rgb); |
1743 SDL_free (pchTemp); | 1736 SDL_free(pchTemp); |
1744 return; | 1737 return; |
1745 } | 1738 } |
1746 | 1739 |
1747 /* Copy pixels upside-down from RGB surface into BMP, masked with the icon mask */ | 1740 /* Copy pixels upside-down from RGB surface into BMP, masked with the icon mask */ |
1748 | 1741 |
1795 } | 1788 } |
1796 } | 1789 } |
1797 } | 1790 } |
1798 | 1791 |
1799 // There is no more need for the RGB surface | 1792 // There is no more need for the RGB surface |
1800 SDL_FreeSurface (icon_rgb); | 1793 SDL_FreeSurface(icon_rgb); |
1801 | 1794 |
1802 hps = WinGetPS (_this->hidden->hwndClient); | 1795 hps = WinGetPS(_this->hidden->hwndClient); |
1803 | 1796 |
1804 bmi.cbFix = sizeof (BITMAPINFOHEADER); | 1797 bmi.cbFix = sizeof(BITMAPINFOHEADER); |
1805 bmi.cx = w; | 1798 bmi.cx = w; |
1806 bmi.cy = 2 * h; | 1799 bmi.cy = 2 * h; |
1807 bmi.cPlanes = 1; | 1800 bmi.cPlanes = 1; |
1808 bmi.cBitCount = 32; | 1801 bmi.cBitCount = 32; |
1809 | 1802 |
1810 SDL_memset (&bmih, 0, sizeof (BITMAPINFOHEADER)); | 1803 SDL_memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); |
1811 bmih.cbFix = sizeof (BITMAPINFOHEADER); | 1804 bmih.cbFix = sizeof(BITMAPINFOHEADER); |
1812 bmih.cx = w; | 1805 bmih.cx = w; |
1813 bmih.cy = 2 * h; | 1806 bmih.cy = 2 * h; |
1814 bmih.cPlanes = 1; | 1807 bmih.cPlanes = 1; |
1815 bmih.cBitCount = 32; | 1808 bmih.cBitCount = 32; |
1816 | 1809 |
1817 hbm = | 1810 hbm = |
1818 GpiCreateBitmap (hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, | 1811 GpiCreateBitmap(hps, (PBITMAPINFOHEADER2) & bmih, CBM_INIT, |
1819 (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); | 1812 (PBYTE) pchTemp, (PBITMAPINFO2) & bmi); |
1820 hptrIcon = WinCreatePointer (HWND_DESKTOP, hbm, FALSE, 0, 0); | 1813 hptrIcon = WinCreatePointer(HWND_DESKTOP, hbm, FALSE, 0, 0); |
1821 | 1814 |
1822 WinReleasePS (hps); | 1815 WinReleasePS(hps); |
1823 | 1816 |
1824 // Free pixel array | 1817 // Free pixel array |
1825 SDL_free (pchTemp); | 1818 SDL_free(pchTemp); |
1826 | 1819 |
1827 // Change icon in frame window | 1820 // Change icon in frame window |
1828 WinSendMsg (hwndFrame, WM_SETICON, (MPARAM) hptrIcon, NULL); | 1821 WinSendMsg(hwndFrame, WM_SETICON, (MPARAM) hptrIcon, NULL); |
1829 | 1822 |
1830 /* | 1823 /* |
1831 // Change icon in switchlist | 1824 // Change icon in switchlist |
1832 // Seems like it's not needed, the WM_SETICON already does it. | 1825 // Seems like it's not needed, the WM_SETICON already does it. |
1833 { | 1826 { |
1851 | 1844 |
1852 // ------------------------ REAL FUNCTIONS ----------------- | 1845 // ------------------------ REAL FUNCTIONS ----------------- |
1853 | 1846 |
1854 | 1847 |
1855 static void | 1848 static void |
1856 os2fslib_SetCursorManagementFunctions (_THIS, int iForWindowedMode) | 1849 os2fslib_SetCursorManagementFunctions(_THIS, int iForWindowedMode) |
1857 { | 1850 { |
1858 if (iForWindowedMode) { | 1851 if (iForWindowedMode) { |
1859 _this->FreeWMCursor = os2fslib_FreeWMCursor; | 1852 _this->FreeWMCursor = os2fslib_FreeWMCursor; |
1860 _this->CreateWMCursor = os2fslib_CreateWMCursor_Win; | 1853 _this->CreateWMCursor = os2fslib_CreateWMCursor_Win; |
1861 _this->ShowWMCursor = os2fslib_ShowWMCursor; | 1854 _this->ShowWMCursor = os2fslib_ShowWMCursor; |
1872 _this->CheckMouseMode = NULL; //os2fslib_CheckMouseMode; | 1865 _this->CheckMouseMode = NULL; //os2fslib_CheckMouseMode; |
1873 } | 1866 } |
1874 } | 1867 } |
1875 | 1868 |
1876 static void | 1869 static void |
1877 os2fslib_InitOSKeymap (_THIS) | 1870 os2fslib_InitOSKeymap(_THIS) |
1878 { | 1871 { |
1879 int i; | 1872 int i; |
1880 | 1873 |
1881 iShiftIsPressed = 0; | 1874 iShiftIsPressed = 0; |
1882 | 1875 |
2006 /* Iconify the window. | 1999 /* Iconify the window. |
2007 This function returns 1 if there is a window manager and the | 2000 This function returns 1 if there is a window manager and the |
2008 window was actually iconified, it returns 0 otherwise. | 2001 window was actually iconified, it returns 0 otherwise. |
2009 */ | 2002 */ |
2010 int | 2003 int |
2011 os2fslib_IconifyWindow (_THIS) | 2004 os2fslib_IconifyWindow(_THIS) |
2012 { | 2005 { |
2013 HAB hab; | 2006 HAB hab; |
2014 HMQ hmq; | 2007 HMQ hmq; |
2015 ERRORID hmqerror; | 2008 ERRORID hmqerror; |
2016 | 2009 |
2017 // If there is no more window, nothing we can do! | 2010 // If there is no more window, nothing we can do! |
2018 if (_this->hidden->iPMThreadStatus != 1) | 2011 if (_this->hidden->iPMThreadStatus != 1) |
2019 return 0; | 2012 return 0; |
2020 | 2013 |
2021 // Cannot do anything in fullscreen mode! | 2014 // Cannot do anything in fullscreen mode! |
2022 if (FSLib_QueryFSMode (_this->hidden->hwndClient)) | 2015 if (FSLib_QueryFSMode(_this->hidden->hwndClient)) |
2023 return 0; | 2016 return 0; |
2024 | 2017 |
2025 // Make sure this thread is prepared for using the Presentation Manager! | 2018 // Make sure this thread is prepared for using the Presentation Manager! |
2026 hab = WinInitialize (0); | 2019 hab = WinInitialize(0); |
2027 hmq = WinCreateMsgQueue (hab, 0); | 2020 hmq = WinCreateMsgQueue(hab, 0); |
2028 // Remember if there was an error at WinCreateMsgQueue(), because we don't | 2021 // Remember if there was an error at WinCreateMsgQueue(), because we don't |
2029 // want to destroy somebody else's queue later. :) | 2022 // want to destroy somebody else's queue later. :) |
2030 hmqerror = WinGetLastError (hab); | 2023 hmqerror = WinGetLastError(hab); |
2031 | 2024 |
2032 WinSetWindowPos (_this->hidden->hwndFrame, HWND_TOP, | 2025 WinSetWindowPos(_this->hidden->hwndFrame, HWND_TOP, |
2033 0, 0, 0, 0, SWP_MINIMIZE); | 2026 0, 0, 0, 0, SWP_MINIMIZE); |
2034 | 2027 |
2035 // Now destroy the message queue, if we've created it! | 2028 // Now destroy the message queue, if we've created it! |
2036 if (ERRORIDERROR (hmqerror) == 0) | 2029 if (ERRORIDERROR(hmqerror) == 0) |
2037 WinDestroyMsgQueue (hmq); | 2030 WinDestroyMsgQueue(hmq); |
2038 | 2031 |
2039 return 1; | 2032 return 1; |
2040 } | 2033 } |
2041 | 2034 |
2042 static SDL_GrabMode | 2035 static SDL_GrabMode |
2043 os2fslib_GrabInput (_THIS, SDL_GrabMode mode) | 2036 os2fslib_GrabInput(_THIS, SDL_GrabMode mode) |
2044 { | 2037 { |
2045 HAB hab; | 2038 HAB hab; |
2046 HMQ hmq; | 2039 HMQ hmq; |
2047 ERRORID hmqerror; | 2040 ERRORID hmqerror; |
2048 | 2041 |
2050 // If there is no more window, nothing we can do! | 2043 // If there is no more window, nothing we can do! |
2051 if (_this->hidden->iPMThreadStatus != 1) | 2044 if (_this->hidden->iPMThreadStatus != 1) |
2052 return SDL_GRAB_OFF; | 2045 return SDL_GRAB_OFF; |
2053 | 2046 |
2054 // Make sure this thread is prepared for using the Presentation Manager! | 2047 // Make sure this thread is prepared for using the Presentation Manager! |
2055 hab = WinInitialize (0); | 2048 hab = WinInitialize(0); |
2056 hmq = WinCreateMsgQueue (hab, 0); | 2049 hmq = WinCreateMsgQueue(hab, 0); |
2057 // Remember if there was an error at WinCreateMsgQueue(), because we don't | 2050 // Remember if there was an error at WinCreateMsgQueue(), because we don't |
2058 // want to destroy somebody else's queue later. :) | 2051 // want to destroy somebody else's queue later. :) |
2059 hmqerror = WinGetLastError (hab); | 2052 hmqerror = WinGetLastError(hab); |
2060 | 2053 |
2061 | 2054 |
2062 if (mode == SDL_GRAB_OFF) { | 2055 if (mode == SDL_GRAB_OFF) { |
2063 #ifdef DEBUG_BUILD | 2056 #ifdef DEBUG_BUILD |
2064 printf ("[os2fslib_GrabInput] : Releasing mouse\n"); | 2057 printf("[os2fslib_GrabInput] : Releasing mouse\n"); |
2065 fflush (stdout); | 2058 fflush(stdout); |
2066 #endif | 2059 #endif |
2067 | 2060 |
2068 // Release the mouse | 2061 // Release the mouse |
2069 bMouseCapturable = 0; | 2062 bMouseCapturable = 0; |
2070 if (bMouseCaptured) { | 2063 if (bMouseCaptured) { |
2071 WinSetCapture (HWND_DESKTOP, NULLHANDLE); | 2064 WinSetCapture(HWND_DESKTOP, NULLHANDLE); |
2072 bMouseCaptured = 0; | 2065 bMouseCaptured = 0; |
2073 } | 2066 } |
2074 } else { | 2067 } else { |
2075 #ifdef DEBUG_BUILD | 2068 #ifdef DEBUG_BUILD |
2076 printf ("[os2fslib_GrabInput] : Capturing mouse\n"); | 2069 printf("[os2fslib_GrabInput] : Capturing mouse\n"); |
2077 fflush (stdout); | 2070 fflush(stdout); |
2078 #endif | 2071 #endif |
2079 | 2072 |
2080 // Capture the mouse | 2073 // Capture the mouse |
2081 bMouseCapturable = 1; | 2074 bMouseCapturable = 1; |
2082 if (WinQueryFocus (HWND_DESKTOP) == _this->hidden->hwndClient) { | 2075 if (WinQueryFocus(HWND_DESKTOP) == _this->hidden->hwndClient) { |
2083 WinSetCapture (HWND_DESKTOP, _this->hidden->hwndClient); | 2076 WinSetCapture(HWND_DESKTOP, _this->hidden->hwndClient); |
2084 bMouseCaptured = 1; | 2077 bMouseCaptured = 1; |
2085 { | 2078 { |
2086 SWP swpClient; | 2079 SWP swpClient; |
2087 POINTL ptl; | 2080 POINTL ptl; |
2088 // Center the mouse to the middle of the window! | 2081 // Center the mouse to the middle of the window! |
2089 WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); | 2082 WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); |
2090 ptl.x = 0; | 2083 ptl.x = 0; |
2091 ptl.y = 0; | 2084 ptl.y = 0; |
2092 WinMapWindowPoints (_this->hidden->hwndClient, | 2085 WinMapWindowPoints(_this->hidden->hwndClient, |
2093 HWND_DESKTOP, &ptl, 1); | 2086 HWND_DESKTOP, &ptl, 1); |
2094 _this->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ | 2087 _this->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ |
2095 WinSetPointerPos (HWND_DESKTOP, | 2088 WinSetPointerPos(HWND_DESKTOP, |
2096 ptl.x + swpClient.cx / 2, | 2089 ptl.x + swpClient.cx / 2, |
2097 ptl.y + swpClient.cy / 2); | 2090 ptl.y + swpClient.cy / 2); |
2098 } | 2091 } |
2099 } | 2092 } |
2100 } | 2093 } |
2101 | 2094 |
2102 // Now destroy the message queue, if we've created it! | 2095 // Now destroy the message queue, if we've created it! |
2103 if (ERRORIDERROR (hmqerror) == 0) | 2096 if (ERRORIDERROR(hmqerror) == 0) |
2104 WinDestroyMsgQueue (hmq); | 2097 WinDestroyMsgQueue(hmq); |
2105 | 2098 |
2106 return mode; | 2099 return mode; |
2107 } | 2100 } |
2108 | 2101 |
2109 /* Set the title and icon text */ | 2102 /* Set the title and icon text */ |
2110 static void | 2103 static void |
2111 os2fslib_SetCaption (_THIS, const char *title, const char *icon) | 2104 os2fslib_SetCaption(_THIS, const char *title, const char *icon) |
2112 { | 2105 { |
2113 HAB hab; | 2106 HAB hab; |
2114 HMQ hmq; | 2107 HMQ hmq; |
2115 ERRORID hmqerror; | 2108 ERRORID hmqerror; |
2116 | 2109 |
2117 // If there is no more window, nothing we can do! | 2110 // If there is no more window, nothing we can do! |
2118 if (_this->hidden->iPMThreadStatus != 1) | 2111 if (_this->hidden->iPMThreadStatus != 1) |
2119 return; | 2112 return; |
2120 | 2113 |
2121 // Make sure this thread is prepared for using the Presentation Manager! | 2114 // Make sure this thread is prepared for using the Presentation Manager! |
2122 hab = WinInitialize (0); | 2115 hab = WinInitialize(0); |
2123 hmq = WinCreateMsgQueue (hab, 0); | 2116 hmq = WinCreateMsgQueue(hab, 0); |
2124 // Remember if there was an error at WinCreateMsgQueue(), because we don't | 2117 // Remember if there was an error at WinCreateMsgQueue(), because we don't |
2125 // want to destroy somebody else's queue later. :) | 2118 // want to destroy somebody else's queue later. :) |
2126 hmqerror = WinGetLastError (hab); | 2119 hmqerror = WinGetLastError(hab); |
2127 | 2120 |
2128 WinSetWindowText (_this->hidden->hwndFrame, (char *) title); | 2121 WinSetWindowText(_this->hidden->hwndFrame, (char *) title); |
2129 | 2122 |
2130 // Now destroy the message queue, if we've created it! | 2123 // Now destroy the message queue, if we've created it! |
2131 if (ERRORIDERROR (hmqerror) == 0) | 2124 if (ERRORIDERROR(hmqerror) == 0) |
2132 WinDestroyMsgQueue (hmq); | 2125 WinDestroyMsgQueue(hmq); |
2133 } | 2126 } |
2134 | 2127 |
2135 static int | 2128 static int |
2136 os2fslib_ToggleFullScreen (_THIS, int on) | 2129 os2fslib_ToggleFullScreen(_THIS, int on) |
2137 { | 2130 { |
2138 #ifdef DEBUG_BUILD | 2131 #ifdef DEBUG_BUILD |
2139 printf ("[os2fslib_ToggleFullScreen] : %d\n", on); | 2132 printf("[os2fslib_ToggleFullScreen] : %d\n", on); |
2140 fflush (stdout); | 2133 fflush(stdout); |
2141 #endif | 2134 #endif |
2142 // If there is no more window, nothing we can do! | 2135 // If there is no more window, nothing we can do! |
2143 if (_this->hidden->iPMThreadStatus != 1) | 2136 if (_this->hidden->iPMThreadStatus != 1) |
2144 return 0; | 2137 return 0; |
2145 | 2138 |
2146 FSLib_ToggleFSMode (_this->hidden->hwndClient, on); | 2139 FSLib_ToggleFSMode(_this->hidden->hwndClient, on); |
2147 /* Cursor manager functions to Windowed/FS mode */ | 2140 /* Cursor manager functions to Windowed/FS mode */ |
2148 os2fslib_SetCursorManagementFunctions (_this, !on); | 2141 os2fslib_SetCursorManagementFunctions(_this, !on); |
2149 return 1; | 2142 return 1; |
2150 } | 2143 } |
2151 | 2144 |
2152 /* This is called after the video mode has been set, to get the | 2145 /* This is called after the video mode has been set, to get the |
2153 initial mouse state. It should queue events as necessary to | 2146 initial mouse state. It should queue events as necessary to |
2154 properly represent the current mouse focus and position. | 2147 properly represent the current mouse focus and position. |
2155 */ | 2148 */ |
2156 static void | 2149 static void |
2157 os2fslib_UpdateMouse (_THIS) | 2150 os2fslib_UpdateMouse(_THIS) |
2158 { | 2151 { |
2159 POINTL ptl; | 2152 POINTL ptl; |
2160 HAB hab; | 2153 HAB hab; |
2161 HMQ hmq; | 2154 HMQ hmq; |
2162 ERRORID hmqerror; | 2155 ERRORID hmqerror; |
2166 if (_this->hidden->iPMThreadStatus != 1) | 2159 if (_this->hidden->iPMThreadStatus != 1) |
2167 return; | 2160 return; |
2168 | 2161 |
2169 | 2162 |
2170 // Make sure this thread is prepared for using the Presentation Manager! | 2163 // Make sure this thread is prepared for using the Presentation Manager! |
2171 hab = WinInitialize (0); | 2164 hab = WinInitialize(0); |
2172 hmq = WinCreateMsgQueue (hab, 0); | 2165 hmq = WinCreateMsgQueue(hab, 0); |
2173 // Remember if there was an error at WinCreateMsgQueue(), because we don't | 2166 // Remember if there was an error at WinCreateMsgQueue(), because we don't |
2174 // want to destroy somebody else's queue later. :) | 2167 // want to destroy somebody else's queue later. :) |
2175 hmqerror = WinGetLastError (hab); | 2168 hmqerror = WinGetLastError(hab); |
2176 | 2169 |
2177 | 2170 |
2178 | 2171 |
2179 if (_this->hidden->fInFocus) { | 2172 if (_this->hidden->fInFocus) { |
2180 // If our app is in focus | 2173 // If our app is in focus |
2181 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS); | 2174 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
2182 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); | 2175 SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); |
2183 SDL_PrivateAppActive (1, SDL_APPACTIVE); | 2176 SDL_PrivateAppActive(1, SDL_APPACTIVE); |
2184 WinQueryPointerPos (HWND_DESKTOP, &ptl); | 2177 WinQueryPointerPos(HWND_DESKTOP, &ptl); |
2185 WinMapWindowPoints (HWND_DESKTOP, _this->hidden->hwndClient, &ptl, 1); | 2178 WinMapWindowPoints(HWND_DESKTOP, _this->hidden->hwndClient, &ptl, 1); |
2186 WinQueryWindowPos (_this->hidden->hwndClient, &swpClient); | 2179 WinQueryWindowPos(_this->hidden->hwndClient, &swpClient); |
2187 // Convert OS/2 mouse position to SDL position, and also scale it! | 2180 // Convert OS/2 mouse position to SDL position, and also scale it! |
2188 ptl.x = | 2181 ptl.x = |
2189 ptl.x * _this->hidden->SrcBufferDesc.uiXResolution / swpClient.cx; | 2182 ptl.x * _this->hidden->SrcBufferDesc.uiXResolution / swpClient.cx; |
2190 ptl.y = | 2183 ptl.y = |
2191 ptl.y * _this->hidden->SrcBufferDesc.uiYResolution / swpClient.cy; | 2184 ptl.y * _this->hidden->SrcBufferDesc.uiYResolution / swpClient.cy; |
2192 ptl.y = _this->hidden->SrcBufferDesc.uiYResolution - ptl.y - 1; | 2185 ptl.y = _this->hidden->SrcBufferDesc.uiYResolution - ptl.y - 1; |
2193 SDL_PrivateMouseMotion (0, 0, (Sint16) (ptl.x), (Sint16) (ptl.y)); | 2186 SDL_PrivateMouseMotion(0, 0, (Sint16) (ptl.x), (Sint16) (ptl.y)); |
2194 } else { | 2187 } else { |
2195 // If we're not in focus | 2188 // If we're not in focus |
2196 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS); | 2189 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
2197 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); | 2190 SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); |
2198 SDL_PrivateAppActive (0, SDL_APPACTIVE); | 2191 SDL_PrivateAppActive(0, SDL_APPACTIVE); |
2199 SDL_PrivateMouseMotion (0, 0, (Sint16) - 1, (Sint16) - 1); | 2192 SDL_PrivateMouseMotion(0, 0, (Sint16) - 1, (Sint16) - 1); |
2200 } | 2193 } |
2201 | 2194 |
2202 // Now destroy the message queue, if we've created it! | 2195 // Now destroy the message queue, if we've created it! |
2203 if (ERRORIDERROR (hmqerror) == 0) | 2196 if (ERRORIDERROR(hmqerror) == 0) |
2204 WinDestroyMsgQueue (hmq); | 2197 WinDestroyMsgQueue(hmq); |
2205 | 2198 |
2206 } | 2199 } |
2207 | 2200 |
2208 /* This pointer should exist in the native video subsystem and should | 2201 /* This pointer should exist in the native video subsystem and should |
2209 point to an appropriate update function for the current video mode | 2202 point to an appropriate update function for the current video mode |
2210 */ | 2203 */ |
2211 static void | 2204 static void |
2212 os2fslib_UpdateRects (_THIS, int numrects, SDL_Rect * rects) | 2205 os2fslib_UpdateRects(_THIS, int numrects, SDL_Rect * rects) |
2213 { | 2206 { |
2214 // If there is no more window, nothing we can do! | 2207 // If there is no more window, nothing we can do! |
2215 if (_this->hidden->iPMThreadStatus != 1) | 2208 if (_this->hidden->iPMThreadStatus != 1) |
2216 return; | 2209 return; |
2217 | 2210 |
2218 #ifdef BITBLT_IN_WINMESSAGEPROC | 2211 #ifdef BITBLT_IN_WINMESSAGEPROC |
2219 WinSendMsg (_this->hidden->hwndClient, | 2212 WinSendMsg(_this->hidden->hwndClient, |
2220 WM_UPDATERECTSREQUEST, (MPARAM) numrects, (MPARAM) rects); | 2213 WM_UPDATERECTSREQUEST, (MPARAM) numrects, (MPARAM) rects); |
2221 #else | 2214 #else |
2222 if (DosRequestMutexSem | 2215 if (DosRequestMutexSem |
2223 (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { | 2216 (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { |
2224 int i; | 2217 int i; |
2225 | 2218 |
2227 #ifndef RESIZE_EVEN_IF_RESIZABLE | 2220 #ifndef RESIZE_EVEN_IF_RESIZABLE |
2228 SWP swp; | 2221 SWP swp; |
2229 // But only blit if the window is not resizable, or if | 2222 // But only blit if the window is not resizable, or if |
2230 // the window is resizable and the source buffer size is the | 2223 // the window is resizable and the source buffer size is the |
2231 // same as the destination buffer size! | 2224 // same as the destination buffer size! |
2232 WinQueryWindowPos (_this->hidden->hwndClient, &swp); | 2225 WinQueryWindowPos(_this->hidden->hwndClient, &swp); |
2233 if ((_this->hidden->pSDLSurface) && | 2226 if ((_this->hidden->pSDLSurface) && |
2234 (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) && | 2227 (_this->hidden->pSDLSurface->flags & SDL_RESIZABLE) && |
2235 ((swp.cx != _this->hidden->SrcBufferDesc.uiXResolution) || | 2228 ((swp.cx != _this->hidden->SrcBufferDesc.uiXResolution) || |
2236 (swp.cy != _this->hidden->SrcBufferDesc.uiYResolution)) | 2229 (swp.cy != _this->hidden->SrcBufferDesc.uiYResolution)) |
2237 && (!FSLib_QueryFSMode (_this->hidden->hwndClient))) { | 2230 && (!FSLib_QueryFSMode(_this->hidden->hwndClient))) { |
2238 // Resizable surface and in resizing! | 2231 // Resizable surface and in resizing! |
2239 // So, don't blit now! | 2232 // So, don't blit now! |
2240 #ifdef DEBUG_BUILD | 2233 #ifdef DEBUG_BUILD |
2241 printf ("[UpdateRects] : Skipping blit while resizing!\n"); | 2234 printf("[UpdateRects] : Skipping blit while resizing!\n"); |
2242 fflush (stdout); | 2235 fflush(stdout); |
2243 #endif | 2236 #endif |
2244 } else | 2237 } else |
2245 #endif | 2238 #endif |
2246 { | 2239 { |
2247 /* | 2240 /* |
2250 0, 0, | 2243 0, 0, |
2251 _this->hidden->SrcBufferDesc.uiXResolution, | 2244 _this->hidden->SrcBufferDesc.uiXResolution, |
2252 _this->hidden->SrcBufferDesc.uiYResolution); | 2245 _this->hidden->SrcBufferDesc.uiYResolution); |
2253 */ | 2246 */ |
2254 #ifdef DEBUG_BUILD | 2247 #ifdef DEBUG_BUILD |
2255 printf ("[os2fslib_UpdateRects] : Blitting!\n"); | 2248 printf("[os2fslib_UpdateRects] : Blitting!\n"); |
2256 fflush (stdout); | 2249 fflush(stdout); |
2257 #endif | 2250 #endif |
2258 | 2251 |
2259 // Blit the changed areas | 2252 // Blit the changed areas |
2260 for (i = 0; i < numrects; i++) | 2253 for (i = 0; i < numrects; i++) |
2261 FSLIB_BITBLT (_this->hidden->hwndClient, | 2254 FSLIB_BITBLT(_this->hidden->hwndClient, |
2262 _this->hidden->pchSrcBuffer, | 2255 _this->hidden->pchSrcBuffer, |
2263 rects[i].y, rects[i].x, rects[i].w, | 2256 rects[i].y, rects[i].x, rects[i].w, |
2264 rects[i].h); | 2257 rects[i].h); |
2265 } | 2258 } |
2266 } | 2259 } |
2267 #ifdef DEBUG_BUILD | 2260 #ifdef DEBUG_BUILD |
2268 else | 2261 else |
2269 printf ("[os2fslib_UpdateRects] : No public surface!\n"); | 2262 printf("[os2fslib_UpdateRects] : No public surface!\n"); |
2270 fflush (stdout); | 2263 fflush(stdout); |
2271 #endif | 2264 #endif |
2272 DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); | 2265 DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); |
2273 } | 2266 } |
2274 #ifdef DEBUG_BUILD | 2267 #ifdef DEBUG_BUILD |
2275 else | 2268 else |
2276 printf ("[os2fslib_UpdateRects] : Error in mutex!\n"); | 2269 printf("[os2fslib_UpdateRects] : Error in mutex!\n"); |
2277 fflush (stdout); | 2270 fflush(stdout); |
2278 #endif | 2271 #endif |
2279 #endif | 2272 #endif |
2280 } | 2273 } |
2281 | 2274 |
2282 | 2275 |
2283 /* Reverse the effects VideoInit() -- called if VideoInit() fails | 2276 /* Reverse the effects VideoInit() -- called if VideoInit() fails |
2284 or if the application is shutting down the video subsystem. | 2277 or if the application is shutting down the video subsystem. |
2285 */ | 2278 */ |
2286 static void | 2279 static void |
2287 os2fslib_VideoQuit (_THIS) | 2280 os2fslib_VideoQuit(_THIS) |
2288 { | 2281 { |
2289 #ifdef DEBUG_BUILD | 2282 #ifdef DEBUG_BUILD |
2290 printf ("[os2fslib_VideoQuit]\n"); | 2283 printf("[os2fslib_VideoQuit]\n"); |
2291 fflush (stdout); | 2284 fflush(stdout); |
2292 #endif | 2285 #endif |
2293 // Close PM stuff if running! | 2286 // Close PM stuff if running! |
2294 if (_this->hidden->iPMThreadStatus == 1) { | 2287 if (_this->hidden->iPMThreadStatus == 1) { |
2295 int iTimeout; | 2288 int iTimeout; |
2296 WinPostMsg (_this->hidden->hwndFrame, WM_QUIT, (MPARAM) 0, | 2289 WinPostMsg(_this->hidden->hwndFrame, WM_QUIT, (MPARAM) 0, (MPARAM) 0); |
2297 (MPARAM) 0); | |
2298 // HACK: We had this line before: | 2290 // HACK: We had this line before: |
2299 //DosWaitThread((TID *) &(_this->hidden->tidPMThread), DCWW_WAIT); | 2291 //DosWaitThread((TID *) &(_this->hidden->tidPMThread), DCWW_WAIT); |
2300 // We don't use it, because the PMThread will never stop, or if it stops, | 2292 // We don't use it, because the PMThread will never stop, or if it stops, |
2301 // it will kill the whole process as a emergency fallback. | 2293 // it will kill the whole process as a emergency fallback. |
2302 // So, we only check for the iPMThreadStatus stuff! | 2294 // So, we only check for the iPMThreadStatus stuff! |
2303 #ifdef DEBUG_BUILD | 2295 #ifdef DEBUG_BUILD |
2304 printf ("[os2fslib_VideoQuit] : Waiting for PM thread to die\n"); | 2296 printf("[os2fslib_VideoQuit] : Waiting for PM thread to die\n"); |
2305 fflush (stdout); | 2297 fflush(stdout); |
2306 #endif | 2298 #endif |
2307 | 2299 |
2308 iTimeout = 0; | 2300 iTimeout = 0; |
2309 while ((_this->hidden->iPMThreadStatus == 1) && (iTimeout < 100)) { | 2301 while ((_this->hidden->iPMThreadStatus == 1) && (iTimeout < 100)) { |
2310 iTimeout++; | 2302 iTimeout++; |
2311 DosSleep (64); | 2303 DosSleep(64); |
2312 } | 2304 } |
2313 | 2305 |
2314 #ifdef DEBUG_BUILD | 2306 #ifdef DEBUG_BUILD |
2315 printf ("[os2fslib_VideoQuit] : End of wait.\n"); | 2307 printf("[os2fslib_VideoQuit] : End of wait.\n"); |
2316 fflush (stdout); | 2308 fflush(stdout); |
2317 #endif | 2309 #endif |
2318 | 2310 |
2319 if (_this->hidden->iPMThreadStatus == 1) { | 2311 if (_this->hidden->iPMThreadStatus == 1) { |
2320 #ifdef DEBUG_BUILD | 2312 #ifdef DEBUG_BUILD |
2321 printf ("[os2fslib_VideoQuit] : Killing PM thread!\n"); | 2313 printf("[os2fslib_VideoQuit] : Killing PM thread!\n"); |
2322 fflush (stdout); | 2314 fflush(stdout); |
2323 #endif | 2315 #endif |
2324 | 2316 |
2325 _this->hidden->iPMThreadStatus = 0; | 2317 _this->hidden->iPMThreadStatus = 0; |
2326 DosKillThread (_this->hidden->tidPMThread); | 2318 DosKillThread(_this->hidden->tidPMThread); |
2327 | 2319 |
2328 if (_this->hidden->hwndFrame) { | 2320 if (_this->hidden->hwndFrame) { |
2329 #ifdef DEBUG_BUILD | 2321 #ifdef DEBUG_BUILD |
2330 printf ("[os2fslib_VideoQuit] : Destroying PM window!\n"); | 2322 printf("[os2fslib_VideoQuit] : Destroying PM window!\n"); |
2331 fflush (stdout); | 2323 fflush(stdout); |
2332 #endif | 2324 #endif |
2333 | 2325 |
2334 WinDestroyWindow (_this->hidden->hwndFrame); | 2326 WinDestroyWindow(_this->hidden->hwndFrame); |
2335 _this->hidden->hwndFrame = NULL; | 2327 _this->hidden->hwndFrame = NULL; |
2336 } | 2328 } |
2337 } | 2329 } |
2338 | 2330 |
2339 } | 2331 } |
2340 // Free result of an old ListModes() call, because there is | 2332 // Free result of an old ListModes() call, because there is |
2341 // no FreeListModes() call in SDL! | 2333 // no FreeListModes() call in SDL! |
2342 if (_this->hidden->pListModesResult) { | 2334 if (_this->hidden->pListModesResult) { |
2343 SDL_free (_this->hidden->pListModesResult); | 2335 SDL_free(_this->hidden->pListModesResult); |
2344 _this->hidden->pListModesResult = NULL; | 2336 _this->hidden->pListModesResult = NULL; |
2345 } | 2337 } |
2346 // Free list of available fullscreen modes | 2338 // Free list of available fullscreen modes |
2347 if (_this->hidden->pAvailableFSLibVideoModes) { | 2339 if (_this->hidden->pAvailableFSLibVideoModes) { |
2348 FSLib_FreeVideoModeList (_this->hidden->pAvailableFSLibVideoModes); | 2340 FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes); |
2349 _this->hidden->pAvailableFSLibVideoModes = NULL; | 2341 _this->hidden->pAvailableFSLibVideoModes = NULL; |
2350 } | 2342 } |
2351 // Free application icon if we had one | 2343 // Free application icon if we had one |
2352 if (hptrCurrentIcon) { | 2344 if (hptrCurrentIcon) { |
2353 WinDestroyPointer (hptrCurrentIcon); | 2345 WinDestroyPointer(hptrCurrentIcon); |
2354 hptrCurrentIcon = NULL; | 2346 hptrCurrentIcon = NULL; |
2355 } | 2347 } |
2356 } | 2348 } |
2357 | 2349 |
2358 /* Set the requested video mode, returning a surface which will be | 2350 /* Set the requested video mode, returning a surface which will be |
2362 specified -- the desired bpp will be emulated with a shadow | 2354 specified -- the desired bpp will be emulated with a shadow |
2363 surface if necessary. If a new mode is returned, this function | 2355 surface if necessary. If a new mode is returned, this function |
2364 should take care of cleaning up the current mode. | 2356 should take care of cleaning up the current mode. |
2365 */ | 2357 */ |
2366 static SDL_Surface * | 2358 static SDL_Surface * |
2367 os2fslib_SetVideoMode (_THIS, SDL_Surface * current, | 2359 os2fslib_SetVideoMode(_THIS, SDL_Surface * current, |
2368 int width, int height, int bpp, Uint32 flags) | 2360 int width, int height, int bpp, Uint32 flags) |
2369 { | 2361 { |
2370 static int bFirstCall = 1; | 2362 static int bFirstCall = 1; |
2371 FSLib_VideoMode_p pModeInfo, pModeInfoFound; | 2363 FSLib_VideoMode_p pModeInfo, pModeInfoFound; |
2372 FSLib_VideoMode TempModeInfo; | 2364 FSLib_VideoMode TempModeInfo; |
2373 HAB hab; | 2365 HAB hab; |
2382 | 2374 |
2383 #ifdef DEBUG_BUILD | 2375 #ifdef DEBUG_BUILD |
2384 printf | 2376 printf |
2385 ("[os2fslib_SetVideoMode] : Request for %dx%d @ %dBPP, flags=0x%x\n", | 2377 ("[os2fslib_SetVideoMode] : Request for %dx%d @ %dBPP, flags=0x%x\n", |
2386 width, height, bpp, flags); | 2378 width, height, bpp, flags); |
2387 fflush (stdout); | 2379 fflush(stdout); |
2388 #endif | 2380 #endif |
2389 | 2381 |
2390 // We don't support palette modes! | 2382 // We don't support palette modes! |
2391 if (bpp == 8) | 2383 if (bpp == 8) |
2392 bpp = 32; | 2384 bpp = 32; |
2406 } | 2398 } |
2407 #ifdef DEBUG_BUILD | 2399 #ifdef DEBUG_BUILD |
2408 printf | 2400 printf |
2409 ("[os2fslib_SetVideoMode] : Changed request to %dx%d @ %dBPP, flags=0x%x\n", | 2401 ("[os2fslib_SetVideoMode] : Changed request to %dx%d @ %dBPP, flags=0x%x\n", |
2410 width, height, bpp, flags); | 2402 width, height, bpp, flags); |
2411 fflush (stdout); | 2403 fflush(stdout); |
2412 #endif | 2404 #endif |
2413 | 2405 |
2414 // First check if there is such a video mode they want! | 2406 // First check if there is such a video mode they want! |
2415 pModeInfoFound = NULL; | 2407 pModeInfoFound = NULL; |
2416 | 2408 |
2437 // If we did not find a good fullscreen mode, then try a similar | 2429 // If we did not find a good fullscreen mode, then try a similar |
2438 if (!pModeInfoFound) { | 2430 if (!pModeInfoFound) { |
2439 #ifdef DEBUG_BUILD | 2431 #ifdef DEBUG_BUILD |
2440 printf | 2432 printf |
2441 ("[os2fslib_SetVideoMode] : Requested video mode not found, looking for a similar one!\n"); | 2433 ("[os2fslib_SetVideoMode] : Requested video mode not found, looking for a similar one!\n"); |
2442 fflush (stdout); | 2434 fflush(stdout); |
2443 #endif | 2435 #endif |
2444 // Go through the video modes again, and find a similar resolution! | 2436 // Go through the video modes again, and find a similar resolution! |
2445 pModeInfo = _this->hidden->pAvailableFSLibVideoModes; | 2437 pModeInfo = _this->hidden->pAvailableFSLibVideoModes; |
2446 while (pModeInfo) { | 2438 while (pModeInfo) { |
2447 // Check all available fullscreen modes for this resolution | 2439 // Check all available fullscreen modes for this resolution |
2463 } | 2455 } |
2464 } | 2456 } |
2465 // If we did not find a good fullscreen mode, then return NULL | 2457 // If we did not find a good fullscreen mode, then return NULL |
2466 if (!pModeInfoFound) { | 2458 if (!pModeInfoFound) { |
2467 #ifdef DEBUG_BUILD | 2459 #ifdef DEBUG_BUILD |
2468 printf | 2460 printf("[os2fslib_SetVideoMode] : Requested video mode not found!\n"); |
2469 ("[os2fslib_SetVideoMode] : Requested video mode not found!\n"); | 2461 fflush(stdout); |
2470 fflush (stdout); | |
2471 #endif | 2462 #endif |
2472 return NULL; | 2463 return NULL; |
2473 } | 2464 } |
2474 #ifdef DEBUG_BUILD | 2465 #ifdef DEBUG_BUILD |
2475 printf ("[os2fslib_SetVideoMode] : Found mode!\n"); | 2466 printf("[os2fslib_SetVideoMode] : Found mode!\n"); |
2476 fflush (stdout); | 2467 fflush(stdout); |
2477 #endif | 2468 #endif |
2478 | 2469 |
2479 // We'll possibly adjust the structure, so copy out the values | 2470 // We'll possibly adjust the structure, so copy out the values |
2480 // into TempModeInfo! | 2471 // into TempModeInfo! |
2481 SDL_memcpy (&TempModeInfo, pModeInfoFound, sizeof (TempModeInfo)); | 2472 SDL_memcpy(&TempModeInfo, pModeInfoFound, sizeof(TempModeInfo)); |
2482 pModeInfoFound = &TempModeInfo; | 2473 pModeInfoFound = &TempModeInfo; |
2483 | 2474 |
2484 if (flags & SDL_RESIZABLE) { | 2475 if (flags & SDL_RESIZABLE) { |
2485 #ifdef DEBUG_BUILD | 2476 #ifdef DEBUG_BUILD |
2486 printf | 2477 printf |
2487 ("[os2fslib_SetVideoMode] : Requested mode is resizable, changing width/height\n"); | 2478 ("[os2fslib_SetVideoMode] : Requested mode is resizable, changing width/height\n"); |
2488 fflush (stdout); | 2479 fflush(stdout); |
2489 #endif | 2480 #endif |
2490 // Change width and height to requested one! | 2481 // Change width and height to requested one! |
2491 TempModeInfo.uiXResolution = width; | 2482 TempModeInfo.uiXResolution = width; |
2492 TempModeInfo.uiYResolution = height; | 2483 TempModeInfo.uiYResolution = height; |
2493 TempModeInfo.uiScanLineSize = width * ((TempModeInfo.uiBPP + 7) / 8); | 2484 TempModeInfo.uiScanLineSize = width * ((TempModeInfo.uiBPP + 7) / 8); |
2494 } | 2485 } |
2495 // We can try create new surface! | 2486 // We can try create new surface! |
2496 | 2487 |
2497 // Make sure this thread is prepared for using the Presentation Manager! | 2488 // Make sure this thread is prepared for using the Presentation Manager! |
2498 hab = WinInitialize (0); | 2489 hab = WinInitialize(0); |
2499 hmq = WinCreateMsgQueue (hab, 0); | 2490 hmq = WinCreateMsgQueue(hab, 0); |
2500 // Remember if there was an error at WinCreateMsgQueue(), because we don't | 2491 // Remember if there was an error at WinCreateMsgQueue(), because we don't |
2501 // want to destroy somebody else's queue later. :) | 2492 // want to destroy somebody else's queue later. :) |
2502 hmqerror = WinGetLastError (hab); | 2493 hmqerror = WinGetLastError(hab); |
2503 | 2494 |
2504 | 2495 |
2505 | 2496 |
2506 if (DosRequestMutexSem | 2497 if (DosRequestMutexSem |
2507 (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { | 2498 (_this->hidden->hmtxUseSrcBuffer, SEM_INDEFINITE_WAIT) == NO_ERROR) { |
2508 #ifdef DEBUG_BUILD | 2499 #ifdef DEBUG_BUILD |
2509 printf ("[os2fslib_SetVideoMode] : Creating new SW surface\n"); | 2500 printf("[os2fslib_SetVideoMode] : Creating new SW surface\n"); |
2510 fflush (stdout); | 2501 fflush(stdout); |
2511 #endif | 2502 #endif |
2512 | 2503 |
2513 // Create new software surface! | 2504 // Create new software surface! |
2514 pResult = SDL_CreateRGBSurface (SDL_SWSURFACE, | 2505 pResult = SDL_CreateRGBSurface(SDL_SWSURFACE, |
2515 pModeInfoFound->uiXResolution, | 2506 pModeInfoFound->uiXResolution, |
2516 pModeInfoFound->uiYResolution, | 2507 pModeInfoFound->uiYResolution, |
2517 pModeInfoFound->uiBPP, | 2508 pModeInfoFound->uiBPP, |
2518 ((unsigned int) pModeInfoFound-> | 2509 ((unsigned int) pModeInfoFound-> |
2519 PixelFormat. | 2510 PixelFormat. |
2520 ucRedMask) << pModeInfoFound-> | 2511 ucRedMask) << pModeInfoFound-> |
2521 PixelFormat.ucRedPosition, | 2512 PixelFormat.ucRedPosition, |
2522 ((unsigned int) pModeInfoFound-> | 2513 ((unsigned int) pModeInfoFound-> |
2523 PixelFormat. | 2514 PixelFormat. |
2524 ucGreenMask) << pModeInfoFound-> | 2515 ucGreenMask) << pModeInfoFound-> |
2525 PixelFormat.ucGreenPosition, | 2516 PixelFormat.ucGreenPosition, |
2526 ((unsigned int) pModeInfoFound-> | 2517 ((unsigned int) pModeInfoFound-> |
2527 PixelFormat. | 2518 PixelFormat. |
2528 ucBlueMask) << pModeInfoFound-> | 2519 ucBlueMask) << pModeInfoFound-> |
2529 PixelFormat.ucBluePosition, | 2520 PixelFormat.ucBluePosition, |
2530 ((unsigned int) pModeInfoFound-> | 2521 ((unsigned int) pModeInfoFound-> |
2531 PixelFormat. | 2522 PixelFormat. |
2532 ucAlphaMask) << pModeInfoFound-> | 2523 ucAlphaMask) << pModeInfoFound-> |
2533 PixelFormat.ucAlphaPosition); | 2524 PixelFormat.ucAlphaPosition); |
2534 | 2525 |
2535 if (pResult == NULL) { | 2526 if (pResult == NULL) { |
2536 DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); | 2527 DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); |
2537 SDL_OutOfMemory (); | 2528 SDL_OutOfMemory(); |
2538 return NULL; | 2529 return NULL; |
2539 } | 2530 } |
2540 #ifdef DEBUG_BUILD | 2531 #ifdef DEBUG_BUILD |
2541 printf ("[os2fslib_SetVideoMode] : Adjusting pixel format\n"); | 2532 printf("[os2fslib_SetVideoMode] : Adjusting pixel format\n"); |
2542 fflush (stdout); | 2533 fflush(stdout); |
2543 #endif | 2534 #endif |
2544 | 2535 |
2545 // Adjust pixel format mask! | 2536 // Adjust pixel format mask! |
2546 pResult->format->Rmask = | 2537 pResult->format->Rmask = |
2547 ((unsigned int) pModeInfoFound->PixelFormat. | 2538 ((unsigned int) pModeInfoFound->PixelFormat. |
2576 // It might be that the software surface pitch is not the same as | 2567 // It might be that the software surface pitch is not the same as |
2577 // the pitch we have, so adjust that! | 2568 // the pitch we have, so adjust that! |
2578 pModeInfoFound->uiScanLineSize = pResult->pitch; | 2569 pModeInfoFound->uiScanLineSize = pResult->pitch; |
2579 | 2570 |
2580 // Store new source buffer parameters! | 2571 // Store new source buffer parameters! |
2581 SDL_memcpy (&(_this->hidden->SrcBufferDesc), pModeInfoFound, | 2572 SDL_memcpy(&(_this->hidden->SrcBufferDesc), pModeInfoFound, |
2582 sizeof (*pModeInfoFound)); | 2573 sizeof(*pModeInfoFound)); |
2583 _this->hidden->pchSrcBuffer = pResult->pixels; | 2574 _this->hidden->pchSrcBuffer = pResult->pixels; |
2584 | 2575 |
2585 #ifdef DEBUG_BUILD | 2576 #ifdef DEBUG_BUILD |
2586 printf ("[os2fslib_SetVideoMode] : Telling FSLib the stuffs\n"); | 2577 printf("[os2fslib_SetVideoMode] : Telling FSLib the stuffs\n"); |
2587 fflush (stdout); | 2578 fflush(stdout); |
2588 #endif | 2579 #endif |
2589 | 2580 |
2590 // Tell the FSLib window the new source image format | 2581 // Tell the FSLib window the new source image format |
2591 FSLib_SetSrcBufferDesc (_this->hidden->hwndClient, | 2582 FSLib_SetSrcBufferDesc(_this->hidden->hwndClient, |
2592 &(_this->hidden->SrcBufferDesc)); | 2583 &(_this->hidden->SrcBufferDesc)); |
2593 | 2584 |
2594 if (((flags & SDL_RESIZABLE) == 0) || (bFirstCall)) { | 2585 if (((flags & SDL_RESIZABLE) == 0) || (bFirstCall)) { |
2595 bFirstCall = 0; | 2586 bFirstCall = 0; |
2596 #ifdef DEBUG_BUILD | 2587 #ifdef DEBUG_BUILD |
2597 printf ("[os2fslib_SetVideoMode] : Modifying window size\n"); | 2588 printf("[os2fslib_SetVideoMode] : Modifying window size\n"); |
2598 fflush (stdout); | 2589 fflush(stdout); |
2599 #endif | 2590 #endif |
2600 | 2591 |
2601 // Calculate frame window size from client window size | 2592 // Calculate frame window size from client window size |
2602 rectl.xLeft = 0; | 2593 rectl.xLeft = 0; |
2603 rectl.yBottom = 0; | 2594 rectl.yBottom = 0; |
2604 rectl.xRight = pModeInfoFound->uiXResolution; // Noninclusive | 2595 rectl.xRight = pModeInfoFound->uiXResolution; // Noninclusive |
2605 rectl.yTop = pModeInfoFound->uiYResolution; // Noninclusive | 2596 rectl.yTop = pModeInfoFound->uiYResolution; // Noninclusive |
2606 WinCalcFrameRect (_this->hidden->hwndFrame, &rectl, FALSE); | 2597 WinCalcFrameRect(_this->hidden->hwndFrame, &rectl, FALSE); |
2607 | 2598 |
2608 // Set the new size of the main window | 2599 // Set the new size of the main window |
2609 SetAccessableWindowPos (_this->hidden->hwndFrame, | 2600 SetAccessableWindowPos(_this->hidden->hwndFrame, |
2610 HWND_TOP, | 2601 HWND_TOP, |
2611 0, 0, | 2602 0, 0, |
2612 (rectl.xRight - rectl.xLeft), | 2603 (rectl.xRight - rectl.xLeft), |
2613 (rectl.yTop - rectl.yBottom), | 2604 (rectl.yTop - rectl.yBottom), |
2614 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW); | 2605 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW); |
2615 } | 2606 } |
2616 // Set fullscreen mode flag, and switch to fullscreen if needed! | 2607 // Set fullscreen mode flag, and switch to fullscreen if needed! |
2617 if (flags & SDL_FULLSCREEN) { | 2608 if (flags & SDL_FULLSCREEN) { |
2618 #ifdef DEBUG_BUILD | 2609 #ifdef DEBUG_BUILD |
2619 printf | 2610 printf |
2620 ("[os2fslib_SetVideoMode] : Also trying to switch to fullscreen\n"); | 2611 ("[os2fslib_SetVideoMode] : Also trying to switch to fullscreen\n"); |
2621 fflush (stdout); | 2612 fflush(stdout); |
2622 #endif | 2613 #endif |
2623 FSLib_ToggleFSMode (_this->hidden->hwndClient, 1); | 2614 FSLib_ToggleFSMode(_this->hidden->hwndClient, 1); |
2624 /* Cursor manager functions to FS mode */ | 2615 /* Cursor manager functions to FS mode */ |
2625 os2fslib_SetCursorManagementFunctions (_this, 0); | 2616 os2fslib_SetCursorManagementFunctions(_this, 0); |
2626 } else { | 2617 } else { |
2627 #ifdef DEBUG_BUILD | 2618 #ifdef DEBUG_BUILD |
2628 printf | 2619 printf |
2629 ("[os2fslib_SetVideoMode] : Also trying to switch to desktop mode\n"); | 2620 ("[os2fslib_SetVideoMode] : Also trying to switch to desktop mode\n"); |
2630 fflush (stdout); | 2621 fflush(stdout); |
2631 #endif | 2622 #endif |
2632 FSLib_ToggleFSMode (_this->hidden->hwndClient, 0); | 2623 FSLib_ToggleFSMode(_this->hidden->hwndClient, 0); |
2633 /* Cursor manager functions to Windowed mode */ | 2624 /* Cursor manager functions to Windowed mode */ |
2634 os2fslib_SetCursorManagementFunctions (_this, 1); | 2625 os2fslib_SetCursorManagementFunctions(_this, 1); |
2635 } | 2626 } |
2636 | 2627 |
2637 _this->hidden->pSDLSurface = pResult; | 2628 _this->hidden->pSDLSurface = pResult; |
2638 | 2629 |
2639 DosReleaseMutexSem (_this->hidden->hmtxUseSrcBuffer); | 2630 DosReleaseMutexSem(_this->hidden->hmtxUseSrcBuffer); |
2640 } else { | 2631 } else { |
2641 #ifdef DEBUG_BUILD | 2632 #ifdef DEBUG_BUILD |
2642 printf | 2633 printf("[os2fslib_SetVideoMode] : Could not get hmtxUseSrcBuffer!\n"); |
2643 ("[os2fslib_SetVideoMode] : Could not get hmtxUseSrcBuffer!\n"); | 2634 fflush(stdout); |
2644 fflush (stdout); | |
2645 #endif | 2635 #endif |
2646 | 2636 |
2647 pResult = NULL; | 2637 pResult = NULL; |
2648 } | 2638 } |
2649 | 2639 |
2650 // As we have the new surface, we don't need the current one anymore! | 2640 // As we have the new surface, we don't need the current one anymore! |
2651 if ((pResult) && (current)) { | 2641 if ((pResult) && (current)) { |
2652 #ifdef DEBUG_BUILD | 2642 #ifdef DEBUG_BUILD |
2653 printf ("[os2fslib_SetVideoMode] : Freeing old surface\n"); | 2643 printf("[os2fslib_SetVideoMode] : Freeing old surface\n"); |
2654 fflush (stdout); | 2644 fflush(stdout); |
2655 #endif | 2645 #endif |
2656 SDL_FreeSurface (current); | 2646 SDL_FreeSurface(current); |
2657 } | 2647 } |
2658 // Redraw window | 2648 // Redraw window |
2659 WinInvalidateRegion (_this->hidden->hwndClient, NULL, TRUE); | 2649 WinInvalidateRegion(_this->hidden->hwndClient, NULL, TRUE); |
2660 | 2650 |
2661 // Now destroy the message queue, if we've created it! | 2651 // Now destroy the message queue, if we've created it! |
2662 if (ERRORIDERROR (hmqerror) == 0) { | 2652 if (ERRORIDERROR(hmqerror) == 0) { |
2663 #ifdef DEBUG_BUILD | 2653 #ifdef DEBUG_BUILD |
2664 printf ("[os2fslib_SetVideoMode] : Destroying message queue\n"); | 2654 printf("[os2fslib_SetVideoMode] : Destroying message queue\n"); |
2665 fflush (stdout); | 2655 fflush(stdout); |
2666 #endif | 2656 #endif |
2667 WinDestroyMsgQueue (hmq); | 2657 WinDestroyMsgQueue(hmq); |
2668 } | 2658 } |
2669 #ifdef DEBUG_BUILD | 2659 #ifdef DEBUG_BUILD |
2670 printf ("[os2fslib_SetVideoMode] : Done\n"); | 2660 printf("[os2fslib_SetVideoMode] : Done\n"); |
2671 fflush (stdout); | 2661 fflush(stdout); |
2672 #endif | 2662 #endif |
2673 | 2663 |
2674 /* We're done */ | 2664 /* We're done */ |
2675 | 2665 |
2676 // Return with the new surface! | 2666 // Return with the new surface! |
2679 | 2669 |
2680 /* List the available video modes for the given pixel format, sorted | 2670 /* List the available video modes for the given pixel format, sorted |
2681 from largest to smallest. | 2671 from largest to smallest. |
2682 */ | 2672 */ |
2683 static SDL_Rect ** | 2673 static SDL_Rect ** |
2684 os2fslib_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) | 2674 os2fslib_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
2685 { | 2675 { |
2686 #ifdef DEBUG_BUILD | 2676 #ifdef DEBUG_BUILD |
2687 printf ("[os2fslib_ListModes] : ListModes of %d Bpp\n", | 2677 printf("[os2fslib_ListModes] : ListModes of %d Bpp\n", |
2688 format->BitsPerPixel); | 2678 format->BitsPerPixel); |
2689 #endif | 2679 #endif |
2690 // Destroy result of previous call, if there is any | 2680 // Destroy result of previous call, if there is any |
2691 if (_this->hidden->pListModesResult) { | 2681 if (_this->hidden->pListModesResult) { |
2692 SDL_free (_this->hidden->pListModesResult); | 2682 SDL_free(_this->hidden->pListModesResult); |
2693 _this->hidden->pListModesResult = NULL; | 2683 _this->hidden->pListModesResult = NULL; |
2694 } | 2684 } |
2695 // For resizable and windowed mode we support every resolution! | 2685 // For resizable and windowed mode we support every resolution! |
2696 if ((flags & SDL_RESIZABLE) && ((flags & SDL_FULLSCREEN) == 0)) | 2686 if ((flags & SDL_RESIZABLE) && ((flags & SDL_FULLSCREEN) == 0)) |
2697 return (SDL_Rect **) - 1; | 2687 return (SDL_Rect **) - 1; |
2705 // For fullscreen mode we don't support every resolution! | 2695 // For fullscreen mode we don't support every resolution! |
2706 // Now create a new list | 2696 // Now create a new list |
2707 pFSMode = _this->hidden->pAvailableFSLibVideoModes; | 2697 pFSMode = _this->hidden->pAvailableFSLibVideoModes; |
2708 while (pFSMode) { | 2698 while (pFSMode) { |
2709 if (pFSMode->uiBPP == format->BitsPerPixel) { | 2699 if (pFSMode->uiBPP == format->BitsPerPixel) { |
2710 SDL_Rect *pRect = (SDL_Rect *) SDL_malloc (sizeof (SDL_Rect)); | 2700 SDL_Rect *pRect = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); |
2711 if (pRect) { | 2701 if (pRect) { |
2712 // Fill description | 2702 // Fill description |
2713 pRect->x = 0; | 2703 pRect->x = 0; |
2714 pRect->y = 0; | 2704 pRect->y = 0; |
2715 pRect->w = pFSMode->uiXResolution; | 2705 pRect->w = pFSMode->uiXResolution; |
2724 // printf("!!! Inserting to beginning\n"); | 2714 // printf("!!! Inserting to beginning\n"); |
2725 #endif | 2715 #endif |
2726 | 2716 |
2727 // We're the first one to be inserted! | 2717 // We're the first one to be inserted! |
2728 _this->hidden->pListModesResult = | 2718 _this->hidden->pListModesResult = |
2729 (SDL_Rect **) SDL_malloc (2 * | 2719 (SDL_Rect **) SDL_malloc(2 * sizeof(SDL_Rect *)); |
2730 sizeof (SDL_Rect *)); | |
2731 if (_this->hidden->pListModesResult) { | 2720 if (_this->hidden->pListModesResult) { |
2732 _this->hidden->pListModesResult[0] = pRect; | 2721 _this->hidden->pListModesResult[0] = pRect; |
2733 _this->hidden->pListModesResult[1] = NULL; | 2722 _this->hidden->pListModesResult[1] = NULL; |
2734 } else { | 2723 } else { |
2735 SDL_free (pRect); | 2724 SDL_free(pRect); |
2736 } | 2725 } |
2737 } else { | 2726 } else { |
2738 // We're not the first ones, so find the place where we | 2727 // We're not the first ones, so find the place where we |
2739 // have to insert ourselves | 2728 // have to insert ourselves |
2740 SDL_Rect **pNewList; | 2729 SDL_Rect **pNewList; |
2764 #ifdef DEBUG_BUILD | 2753 #ifdef DEBUG_BUILD |
2765 // printf("!!! From %d slots, it will be at %d\n", iNumOfSlots, iPlace); | 2754 // printf("!!! From %d slots, it will be at %d\n", iNumOfSlots, iPlace); |
2766 #endif | 2755 #endif |
2767 | 2756 |
2768 pNewList = | 2757 pNewList = |
2769 (SDL_Rect **) SDL_realloc (_this-> | 2758 (SDL_Rect **) SDL_realloc(_this-> |
2770 hidden-> | 2759 hidden-> |
2771 pListModesResult, | 2760 pListModesResult, |
2772 (iNumOfSlots | 2761 (iNumOfSlots |
2773 + | 2762 + |
2774 1) * | 2763 1) * |
2775 sizeof (SDL_Rect *)); | 2764 sizeof(SDL_Rect *)); |
2776 if (pNewList) { | 2765 if (pNewList) { |
2777 for (i = iNumOfSlots; i > iPlace; i--) | 2766 for (i = iNumOfSlots; i > iPlace; i--) |
2778 pNewList[i] = pNewList[i - 1]; | 2767 pNewList[i] = pNewList[i - 1]; |
2779 pNewList[iPlace] = pRect; | 2768 pNewList[iPlace] = pRect; |
2780 _this->hidden->pListModesResult = pNewList; | 2769 _this->hidden->pListModesResult = pNewList; |
2781 } else { | 2770 } else { |
2782 SDL_free (pRect); | 2771 SDL_free(pRect); |
2783 } | 2772 } |
2784 } | 2773 } |
2785 } | 2774 } |
2786 } | 2775 } |
2787 pFSMode = pFSMode->pNext; | 2776 pFSMode = pFSMode->pNext; |
2795 | 2784 |
2796 /* Initialize the native video subsystem, filling 'vformat' with the | 2785 /* Initialize the native video subsystem, filling 'vformat' with the |
2797 "best" display pixel format, returning 0 or -1 if there's an error. | 2786 "best" display pixel format, returning 0 or -1 if there's an error. |
2798 */ | 2787 */ |
2799 static int | 2788 static int |
2800 os2fslib_VideoInit (_THIS, SDL_PixelFormat * vformat) | 2789 os2fslib_VideoInit(_THIS, SDL_PixelFormat * vformat) |
2801 { | 2790 { |
2802 FSLib_VideoMode_p pDesktopMode; | 2791 FSLib_VideoMode_p pDesktopMode; |
2803 | 2792 |
2804 #ifdef DEBUG_BUILD | 2793 #ifdef DEBUG_BUILD |
2805 printf ("[os2fslib_VideoInit] : Enter\n"); | 2794 printf("[os2fslib_VideoInit] : Enter\n"); |
2806 fflush (stdout); | 2795 fflush(stdout); |
2807 #endif | 2796 #endif |
2808 | 2797 |
2809 // Report the best pixel format. For this, | 2798 // Report the best pixel format. For this, |
2810 // we'll use the current desktop format. | 2799 // we'll use the current desktop format. |
2811 pDesktopMode = FSLib_GetDesktopVideoMode (); | 2800 pDesktopMode = FSLib_GetDesktopVideoMode(); |
2812 if (!pDesktopMode) { | 2801 if (!pDesktopMode) { |
2813 SDL_SetError ("Could not query desktop video mode!"); | 2802 SDL_SetError("Could not query desktop video mode!"); |
2814 #ifdef DEBUG_BUILD | 2803 #ifdef DEBUG_BUILD |
2815 printf | 2804 printf |
2816 ("[os2fslib_VideoInit] : Could not query desktop video mode!\n"); | 2805 ("[os2fslib_VideoInit] : Could not query desktop video mode!\n"); |
2817 #endif | 2806 #endif |
2818 return -1; | 2807 return -1; |
2858 _this->hidden->pListModesResult = NULL; | 2847 _this->hidden->pListModesResult = NULL; |
2859 _this->hidden->fInFocus = 0; | 2848 _this->hidden->fInFocus = 0; |
2860 _this->hidden->iSkipWMMOUSEMOVE = 0; | 2849 _this->hidden->iSkipWMMOUSEMOVE = 0; |
2861 _this->hidden->iMouseVisible = 1; | 2850 _this->hidden->iMouseVisible = 1; |
2862 | 2851 |
2863 if (getenv ("SDL_USE_PROPORTIONAL_WINDOW")) | 2852 if (getenv("SDL_USE_PROPORTIONAL_WINDOW")) |
2864 _this->hidden->bProportionalResize = 1; | 2853 _this->hidden->bProportionalResize = 1; |
2865 else { | 2854 else { |
2866 PPIB pib; | 2855 PPIB pib; |
2867 PTIB tib; | 2856 PTIB tib; |
2868 char *pchFileName, *pchTemp; | 2857 char *pchFileName, *pchTemp; |
2872 /* No environment variable to have proportional window. | 2861 /* No environment variable to have proportional window. |
2873 * Ok, let's check if this executable is in config file! | 2862 * Ok, let's check if this executable is in config file! |
2874 */ | 2863 */ |
2875 _this->hidden->bProportionalResize = 0; | 2864 _this->hidden->bProportionalResize = 0; |
2876 | 2865 |
2877 DosGetInfoBlocks (&tib, &pib); | 2866 DosGetInfoBlocks(&tib, &pib); |
2878 pchTemp = pchFileName = pib->pib_pchcmd; | 2867 pchTemp = pchFileName = pib->pib_pchcmd; |
2879 while (*pchTemp) { | 2868 while (*pchTemp) { |
2880 if (*pchTemp == '\\') | 2869 if (*pchTemp == '\\') |
2881 pchFileName = pchTemp + 1; | 2870 pchFileName = pchTemp + 1; |
2882 pchTemp++; | 2871 pchTemp++; |
2883 } | 2872 } |
2884 if (getenv ("HOME")) { | 2873 if (getenv("HOME")) { |
2885 sprintf (achConfigFile, "%s\\.sdl.proportionals", | 2874 sprintf(achConfigFile, "%s\\.sdl.proportionals", getenv("HOME")); |
2886 getenv ("HOME")); | 2875 hFile = fopen(achConfigFile, "rt"); |
2887 hFile = fopen (achConfigFile, "rt"); | |
2888 if (!hFile) { | 2876 if (!hFile) { |
2889 /* Seems like the file cannot be opened or does not exist. | 2877 /* Seems like the file cannot be opened or does not exist. |
2890 * Let's try to create it with defaults! | 2878 * Let's try to create it with defaults! |
2891 */ | 2879 */ |
2892 hFile = fopen (achConfigFile, "wt"); | 2880 hFile = fopen(achConfigFile, "wt"); |
2893 if (hFile) { | 2881 if (hFile) { |
2894 fprintf (hFile, | 2882 fprintf(hFile, |
2895 "; This file is a config file of SDL/2, containing\n"); | 2883 "; This file is a config file of SDL/2, containing\n"); |
2896 fprintf (hFile, | 2884 fprintf(hFile, |
2897 "; the list of executables that must have proportional\n"); | 2885 "; the list of executables that must have proportional\n"); |
2898 fprintf (hFile, "; windows.\n"); | 2886 fprintf(hFile, "; windows.\n"); |
2899 fprintf (hFile, ";\n"); | 2887 fprintf(hFile, ";\n"); |
2900 fprintf (hFile, | 2888 fprintf(hFile, |
2901 "; You can add executable filenames into this file,\n"); | 2889 "; You can add executable filenames into this file,\n"); |
2902 fprintf (hFile, | 2890 fprintf(hFile, |
2903 "; one under the other. If SDL finds that a given\n"); | 2891 "; one under the other. If SDL finds that a given\n"); |
2904 fprintf (hFile, | 2892 fprintf(hFile, |
2905 "; program is in this list, then that application\n"); | 2893 "; program is in this list, then that application\n"); |
2906 fprintf (hFile, | 2894 fprintf(hFile, |
2907 "; will have proportional windows, just like if\n"); | 2895 "; will have proportional windows, just like if\n"); |
2908 fprintf (hFile, | 2896 fprintf(hFile, |
2909 "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n"); | 2897 "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n"); |
2910 fprintf (hFile, | 2898 fprintf(hFile, |
2911 "; would have been set for that process.\n"); | 2899 "; would have been set for that process.\n"); |
2912 fprintf (hFile, ";\n"); | 2900 fprintf(hFile, ";\n"); |
2913 fprintf (hFile, "\n"); | 2901 fprintf(hFile, "\n"); |
2914 fprintf (hFile, "dosbox.exe\n"); | 2902 fprintf(hFile, "dosbox.exe\n"); |
2915 fclose (hFile); | 2903 fclose(hFile); |
2916 } | 2904 } |
2917 | 2905 |
2918 hFile = fopen (achConfigFile, "rt"); | 2906 hFile = fopen(achConfigFile, "rt"); |
2919 } | 2907 } |
2920 | 2908 |
2921 if (hFile) { | 2909 if (hFile) { |
2922 while (fgets (achConfigFile, sizeof (achConfigFile), hFile)) { | 2910 while (fgets(achConfigFile, sizeof(achConfigFile), hFile)) { |
2923 /* Cut \n from end of string */ | 2911 /* Cut \n from end of string */ |
2924 | 2912 |
2925 while (achConfigFile[strlen (achConfigFile) - 1] | 2913 while (achConfigFile[strlen(achConfigFile) - 1] |
2926 == '\n') | 2914 == '\n') |
2927 achConfigFile[strlen (achConfigFile) - 1] = 0; | 2915 achConfigFile[strlen(achConfigFile) - 1] = 0; |
2928 | 2916 |
2929 /* Compare... */ | 2917 /* Compare... */ |
2930 if (stricmp (achConfigFile, pchFileName) == 0) { | 2918 if (stricmp(achConfigFile, pchFileName) == 0) { |
2931 /* Found it in config file! */ | 2919 /* Found it in config file! */ |
2932 _this->hidden->bProportionalResize = 1; | 2920 _this->hidden->bProportionalResize = 1; |
2933 break; | 2921 break; |
2934 } | 2922 } |
2935 } | 2923 } |
2936 fclose (hFile); | 2924 fclose(hFile); |
2937 } | 2925 } |
2938 } | 2926 } |
2939 } | 2927 } |
2940 | 2928 |
2941 DosCreateMutexSem (NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE); | 2929 DosCreateMutexSem(NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE); |
2942 | 2930 |
2943 // Now create our window with a default size | 2931 // Now create our window with a default size |
2944 | 2932 |
2945 // For this, we select the first available fullscreen mode as | 2933 // For this, we select the first available fullscreen mode as |
2946 // current window size! | 2934 // current window size! |
2947 SDL_memcpy (&(_this->hidden->SrcBufferDesc), | 2935 SDL_memcpy(&(_this->hidden->SrcBufferDesc), |
2948 _this->hidden->pAvailableFSLibVideoModes, | 2936 _this->hidden->pAvailableFSLibVideoModes, |
2949 sizeof (_this->hidden->SrcBufferDesc)); | 2937 sizeof(_this->hidden->SrcBufferDesc)); |
2950 // Allocate new video buffer! | 2938 // Allocate new video buffer! |
2951 _this->hidden->pchSrcBuffer = | 2939 _this->hidden->pchSrcBuffer = |
2952 (char *) SDL_malloc (_this->hidden->pAvailableFSLibVideoModes-> | 2940 (char *) SDL_malloc(_this->hidden->pAvailableFSLibVideoModes-> |
2953 uiScanLineSize * | 2941 uiScanLineSize * |
2954 _this->hidden->pAvailableFSLibVideoModes-> | 2942 _this->hidden->pAvailableFSLibVideoModes-> |
2955 uiYResolution); | 2943 uiYResolution); |
2956 if (!_this->hidden->pchSrcBuffer) { | 2944 if (!_this->hidden->pchSrcBuffer) { |
2957 #ifdef DEBUG_BUILD | 2945 #ifdef DEBUG_BUILD |
2958 printf | 2946 printf |
2959 ("[os2fslib_VideoInit] : Yikes, not enough memory for new video buffer!\n"); | 2947 ("[os2fslib_VideoInit] : Yikes, not enough memory for new video buffer!\n"); |
2960 fflush (stdout); | 2948 fflush(stdout); |
2961 #endif | 2949 #endif |
2962 SDL_SetError ("Not enough memory for new video buffer!\n"); | 2950 SDL_SetError("Not enough memory for new video buffer!\n"); |
2963 return -1; | 2951 return -1; |
2964 } | 2952 } |
2965 // For this, we need a message processing thread. | 2953 // For this, we need a message processing thread. |
2966 // We'll create a new thread for this, which will do everything | 2954 // We'll create a new thread for this, which will do everything |
2967 // what is related to PM | 2955 // what is related to PM |
2968 _this->hidden->iPMThreadStatus = 0; | 2956 _this->hidden->iPMThreadStatus = 0; |
2969 _this->hidden->tidPMThread = | 2957 _this->hidden->tidPMThread = |
2970 _beginthread (PMThreadFunc, NULL, 65536, (void *) _this); | 2958 _beginthread(PMThreadFunc, NULL, 65536, (void *) _this); |
2971 if (_this->hidden->tidPMThread <= 0) { | 2959 if (_this->hidden->tidPMThread <= 0) { |
2972 #ifdef DEBUG_BUILD | 2960 #ifdef DEBUG_BUILD |
2973 printf ("[os2fslib_VideoInit] : Could not create PM thread!\n"); | 2961 printf("[os2fslib_VideoInit] : Could not create PM thread!\n"); |
2974 #endif | 2962 #endif |
2975 SDL_SetError ("Could not create PM thread"); | 2963 SDL_SetError("Could not create PM thread"); |
2976 return -1; | 2964 return -1; |
2977 } | 2965 } |
2978 #ifdef USE_DOSSETPRIORITY | 2966 #ifdef USE_DOSSETPRIORITY |
2979 // Burst the priority of PM Thread! | 2967 // Burst the priority of PM Thread! |
2980 DosSetPriority (PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, | 2968 DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, |
2981 _this->hidden->tidPMThread); | 2969 _this->hidden->tidPMThread); |
2982 #endif | 2970 #endif |
2983 // Wait for the PM thread to initialize! | 2971 // Wait for the PM thread to initialize! |
2984 while (_this->hidden->iPMThreadStatus == 0) | 2972 while (_this->hidden->iPMThreadStatus == 0) |
2985 DosSleep (32); | 2973 DosSleep(32); |
2986 // If the PM thread could not set up everything, then | 2974 // If the PM thread could not set up everything, then |
2987 // report an error! | 2975 // report an error! |
2988 if (_this->hidden->iPMThreadStatus != 1) { | 2976 if (_this->hidden->iPMThreadStatus != 1) { |
2989 #ifdef DEBUG_BUILD | 2977 #ifdef DEBUG_BUILD |
2990 printf ("[os2fslib_VideoInit] : PMThread reported an error : %d\n", | 2978 printf("[os2fslib_VideoInit] : PMThread reported an error : %d\n", |
2991 _this->hidden->iPMThreadStatus); | 2979 _this->hidden->iPMThreadStatus); |
2992 #endif | 2980 #endif |
2993 SDL_SetError ("Error initializing PM thread"); | 2981 SDL_SetError("Error initializing PM thread"); |
2994 return -1; | 2982 return -1; |
2995 } | 2983 } |
2996 | 2984 |
2997 return 0; | 2985 return 0; |
2998 } | 2986 } |
2999 | 2987 |
3000 | 2988 |
3001 static void | 2989 static void |
3002 os2fslib_DeleteDevice (_THIS) | 2990 os2fslib_DeleteDevice(_THIS) |
3003 { | 2991 { |
3004 #ifdef DEBUG_BUILD | 2992 #ifdef DEBUG_BUILD |
3005 printf ("[os2fslib_DeleteDevice]\n"); | 2993 printf("[os2fslib_DeleteDevice]\n"); |
3006 fflush (stdout); | 2994 fflush(stdout); |
3007 #endif | 2995 #endif |
3008 // Free used memory | 2996 // Free used memory |
3009 FSLib_FreeVideoModeList (_this->hidden->pAvailableFSLibVideoModes); | 2997 FSLib_FreeVideoModeList(_this->hidden->pAvailableFSLibVideoModes); |
3010 if (_this->hidden->pListModesResult) | 2998 if (_this->hidden->pListModesResult) |
3011 SDL_free (_this->hidden->pListModesResult); | 2999 SDL_free(_this->hidden->pListModesResult); |
3012 if (_this->hidden->pchSrcBuffer) | 3000 if (_this->hidden->pchSrcBuffer) |
3013 SDL_free (_this->hidden->pchSrcBuffer); | 3001 SDL_free(_this->hidden->pchSrcBuffer); |
3014 DosCloseMutexSem (_this->hidden->hmtxUseSrcBuffer); | 3002 DosCloseMutexSem(_this->hidden->hmtxUseSrcBuffer); |
3015 SDL_free (_this->hidden); | 3003 SDL_free(_this->hidden); |
3016 SDL_free (_this); | 3004 SDL_free(_this); |
3017 FSLib_Uninitialize (); | 3005 FSLib_Uninitialize(); |
3018 } | 3006 } |
3019 | 3007 |
3020 static int | 3008 static int |
3021 os2fslib_Available (void) | 3009 os2fslib_Available(void) |
3022 { | 3010 { |
3023 | 3011 |
3024 // If we can run, it means that we could load FSLib, | 3012 // If we can run, it means that we could load FSLib, |
3025 // so we assume that it's available then! | 3013 // so we assume that it's available then! |
3026 return 1; | 3014 return 1; |
3027 } | 3015 } |
3028 | 3016 |
3029 static void | 3017 static void |
3030 os2fslib_MorphToPM () | 3018 os2fslib_MorphToPM() |
3031 { | 3019 { |
3032 PPIB pib; | 3020 PPIB pib; |
3033 PTIB tib; | 3021 PTIB tib; |
3034 | 3022 |
3035 DosGetInfoBlocks (&tib, &pib); | 3023 DosGetInfoBlocks(&tib, &pib); |
3036 | 3024 |
3037 // Change flag from VIO to PM: | 3025 // Change flag from VIO to PM: |
3038 if (pib->pib_ultype == 2) | 3026 if (pib->pib_ultype == 2) |
3039 pib->pib_ultype = 3; | 3027 pib->pib_ultype = 3; |
3040 } | 3028 } |
3041 | 3029 |
3042 static SDL_VideoDevice * | 3030 static SDL_VideoDevice * |
3043 os2fslib_CreateDevice (int devindex) | 3031 os2fslib_CreateDevice(int devindex) |
3044 { | 3032 { |
3045 SDL_VideoDevice *device; | 3033 SDL_VideoDevice *device; |
3046 | 3034 |
3047 #ifdef DEBUG_BUILD | 3035 #ifdef DEBUG_BUILD |
3048 printf ("[os2fslib_CreateDevice] : Enter\n"); | 3036 printf("[os2fslib_CreateDevice] : Enter\n"); |
3049 fflush (stdout); | 3037 fflush(stdout); |
3050 #endif | 3038 #endif |
3051 | 3039 |
3052 /* Initialize all variables that we clean on shutdown */ | 3040 /* Initialize all variables that we clean on shutdown */ |
3053 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); | 3041 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); |
3054 if (device) { | 3042 if (device) { |
3055 SDL_memset (device, 0, (sizeof *device)); | 3043 SDL_memset(device, 0, (sizeof *device)); |
3056 // Also allocate memory for private data | 3044 // Also allocate memory for private data |
3057 device->hidden = (struct SDL_PrivateVideoData *) | 3045 device->hidden = (struct SDL_PrivateVideoData *) |
3058 SDL_malloc ((sizeof (struct SDL_PrivateVideoData))); | 3046 SDL_malloc((sizeof(struct SDL_PrivateVideoData))); |
3059 } | 3047 } |
3060 if ((device == NULL) || (device->hidden == NULL)) { | 3048 if ((device == NULL) || (device->hidden == NULL)) { |
3061 SDL_OutOfMemory (); | 3049 SDL_OutOfMemory(); |
3062 if (device) | 3050 if (device) |
3063 SDL_free (device); | 3051 SDL_free(device); |
3064 return NULL; | 3052 return NULL; |
3065 } | 3053 } |
3066 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); | 3054 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
3067 | 3055 |
3068 /* Set the function pointers */ | 3056 /* Set the function pointers */ |
3069 #ifdef DEBUG_BUILD | 3057 #ifdef DEBUG_BUILD |
3070 printf ("[os2fslib_CreateDevice] : VideoInit is %p\n", | 3058 printf("[os2fslib_CreateDevice] : VideoInit is %p\n", os2fslib_VideoInit); |
3071 os2fslib_VideoInit); | 3059 fflush(stdout); |
3072 fflush (stdout); | |
3073 #endif | 3060 #endif |
3074 | 3061 |
3075 /* Initialization/Query functions */ | 3062 /* Initialization/Query functions */ |
3076 device->VideoInit = os2fslib_VideoInit; | 3063 device->VideoInit = os2fslib_VideoInit; |
3077 device->ListModes = os2fslib_ListModes; | 3064 device->ListModes = os2fslib_ListModes; |
3097 device->SetIcon = os2fslib_SetIcon; | 3084 device->SetIcon = os2fslib_SetIcon; |
3098 device->IconifyWindow = os2fslib_IconifyWindow; | 3085 device->IconifyWindow = os2fslib_IconifyWindow; |
3099 device->GrabInput = os2fslib_GrabInput; | 3086 device->GrabInput = os2fslib_GrabInput; |
3100 device->GetWMInfo = NULL; | 3087 device->GetWMInfo = NULL; |
3101 /* Cursor manager functions to Windowed mode */ | 3088 /* Cursor manager functions to Windowed mode */ |
3102 os2fslib_SetCursorManagementFunctions (device, 1); | 3089 os2fslib_SetCursorManagementFunctions(device, 1); |
3103 /* Event manager functions */ | 3090 /* Event manager functions */ |
3104 device->InitOSKeymap = os2fslib_InitOSKeymap; | 3091 device->InitOSKeymap = os2fslib_InitOSKeymap; |
3105 device->PumpEvents = os2fslib_PumpEvents; | 3092 device->PumpEvents = os2fslib_PumpEvents; |
3106 /* The function used to dispose of this structure */ | 3093 /* The function used to dispose of this structure */ |
3107 device->free = os2fslib_DeleteDevice; | 3094 device->free = os2fslib_DeleteDevice; |
3108 | 3095 |
3109 // Make sure we'll be able to use Win* API even if the application | 3096 // Make sure we'll be able to use Win* API even if the application |
3110 // was linked to be a VIO application! | 3097 // was linked to be a VIO application! |
3111 os2fslib_MorphToPM (); | 3098 os2fslib_MorphToPM(); |
3112 | 3099 |
3113 // Now initialize FSLib, and query available video modes! | 3100 // Now initialize FSLib, and query available video modes! |
3114 if (!FSLib_Initialize ()) { | 3101 if (!FSLib_Initialize()) { |
3115 // Could not initialize FSLib! | 3102 // Could not initialize FSLib! |
3116 #ifdef DEBUG_BUILD | 3103 #ifdef DEBUG_BUILD |
3117 printf ("[os2fslib_CreateDevice] : Could not initialize FSLib!\n"); | 3104 printf("[os2fslib_CreateDevice] : Could not initialize FSLib!\n"); |
3118 #endif | 3105 #endif |
3119 SDL_SetError ("Could not initialize FSLib!"); | 3106 SDL_SetError("Could not initialize FSLib!"); |
3120 SDL_free (device->hidden); | 3107 SDL_free(device->hidden); |
3121 SDL_free (device); | 3108 SDL_free(device); |
3122 return NULL; | 3109 return NULL; |
3123 } | 3110 } |
3124 device->hidden->pAvailableFSLibVideoModes = FSLib_GetVideoModeList (); | 3111 device->hidden->pAvailableFSLibVideoModes = FSLib_GetVideoModeList(); |
3125 | 3112 |
3126 return device; | 3113 return device; |
3127 } | 3114 } |
3128 | 3115 |
3129 VideoBootStrap OS2FSLib_bootstrap = { | 3116 VideoBootStrap OS2FSLib_bootstrap = { |