comparison src/video/os2fslib/SDL_os2fslib.c @ 1442:e3242177fe4a

Updated OS/2 build, yay!
author Sam Lantinga <slouken@libsdl.org>
date Sun, 26 Feb 2006 19:30:21 +0000
parents d910939febfa
children 8d9bb0cf2c2a
comparison
equal deleted inserted replaced
1441:b9f034536fa0 1442:e3242177fe4a
18 18
19 Sam Lantinga 19 Sam Lantinga
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23
24 #define _ULS_CALLCONV_
25 #define CALLCONV _System
26 #include <unidef.h> // Unicode API
27 #include <uconv.h> // Unicode API (codepage conversion)
23 28
24 #include <process.h> 29 #include <process.h>
25 #include <time.h> 30 #include <time.h>
26 31
27 #include "SDL_video.h" 32 #include "SDL_video.h"
113 // Same as WinSetWindowPos(), but takes care for the window to be 118 // Same as WinSetWindowPos(), but takes care for the window to be
114 // always on the screen, the titlebar will be accessable everytime. 119 // always on the screen, the titlebar will be accessable everytime.
115 // 120 //
116 ///////////////////////////////////////////////////////////////////// 121 /////////////////////////////////////////////////////////////////////
117 static BOOL SetAccessableWindowPos(HWND hwnd, HWND hwndInsertBehind, 122 static BOOL SetAccessableWindowPos(HWND hwnd, HWND hwndInsertBehind,
118 LONG x, LONG y, 123 LONG x, LONG y,
119 LONG cx, LONG cy, 124 LONG cx, LONG cy,
120 ULONG fl) 125 ULONG fl)
121 { 126 {
122 SWP swpDesktop, swp; 127 SWP swpDesktop, swp;
123 // Get desktop area 128 // Get desktop area
124 WinQueryWindowPos(HWND_DESKTOP, &swpDesktop); 129 WinQueryWindowPos(HWND_DESKTOP, &swpDesktop);
167 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl | SWP_MOVE); 172 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl | SWP_MOVE);
168 } else 173 } else
169 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl); 174 return WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
170 } 175 }
171 176
177 static UniChar NativeCharToUniChar(int chcode)
178 {
179 UniChar ucResult = (UniChar) chcode;
180 int rc;
181 UconvObject ucoTemp;
182 char achFrom[2];
183 char *pchFrom;
184 size_t iFromCount;
185 UniChar aucTo[10];
186 UniChar *pucTo;
187 size_t iToCount;
188 size_t iNonIdentical;
189
190 // Create unicode convert object
191 rc = UniCreateUconvObject(L"", &ucoTemp);
192 if (rc!=ULS_SUCCESS)
193 {
194 // Could not create convert object!
195 return ucResult;
196 }
197
198 // Convert language code string to unicode string
199 achFrom[0] = (char) chcode;
200 achFrom[1] = 0;
201 iFromCount = sizeof(char) * 2;
202 iToCount = sizeof(UniChar) * 2;
203 pucTo = &(aucTo[0]);
204 pchFrom = &(achFrom[0]);
205
206 rc = UniUconvToUcs(ucoTemp,
207 &pchFrom,
208 &iFromCount,
209 &pucTo,
210 &iToCount,
211 &iNonIdentical);
212
213 if (rc!=ULS_SUCCESS)
214 {
215 // Could not convert language code to UCS string!
216 UniFreeUconvObject(ucoTemp);
217 return ucResult;
218 }
219
220 UniFreeUconvObject(ucoTemp);
221
222 #ifdef DEBUG_BUILD
223 printf("%02x converted to %02x\n", (int) chcode, (int) (aucTo[0]));
224 #endif
225
226 return aucTo[0];
227 }
228
172 ///////////////////////////////////////////////////////////////////// 229 /////////////////////////////////////////////////////////////////////
173 // 230 //
174 // TranslateKey 231 // TranslateKey
175 // 232 //
176 // This creates SDL Keycodes from VK_ and hardware scan codes 233 // This creates SDL Keycodes from VK_ and hardware scan codes
182 keysym->mod = KMOD_NONE; 239 keysym->mod = KMOD_NONE;
183 keysym->unicode = 0; 240 keysym->unicode = 0;
184 241
185 if (iPressed && SDL_TranslateUNICODE) 242 if (iPressed && SDL_TranslateUNICODE)
186 { 243 {
187 // TODO:
188 // Implement real unicode conversion!
189 if (chcode) 244 if (chcode)
190 keysym->unicode = chcode; 245 keysym->unicode = NativeCharToUniChar(chcode);
191 else 246 else
192 keysym->unicode = vkey; 247 keysym->unicode = vkey;
193 } 248 }
194 249
195 keysym->sym = HWScanKeyMap[scancode]; 250 keysym->sym = HWScanKeyMap[scancode];
205 // Change syms, if Unicode stuff is required 260 // Change syms, if Unicode stuff is required
206 // I think it's silly, but it's SDL... 261 // I think it's silly, but it's SDL...
207 switch (keysym->sym) 262 switch (keysym->sym)
208 { 263 {
209 case SDLK_BACKQUOTE: 264 case SDLK_BACKQUOTE:
210 keysym->sym = '~'; 265 keysym->sym = '~';
211 break; 266 break;
212 case SDLK_1: 267 case SDLK_1:
213 keysym->sym = SDLK_EXCLAIM; 268 keysym->sym = SDLK_EXCLAIM;
214 break; 269 break;
215 case SDLK_2: 270 case SDLK_2:
216 keysym->sym = SDLK_AT; 271 keysym->sym = SDLK_AT;
217 break; 272 break;
218 case SDLK_3: 273 case SDLK_3:
219 keysym->sym = SDLK_HASH; 274 keysym->sym = SDLK_HASH;
220 break; 275 break;
221 case SDLK_4: 276 case SDLK_4:
222 keysym->sym = SDLK_DOLLAR; 277 keysym->sym = SDLK_DOLLAR;
223 break; 278 break;
224 case SDLK_5: 279 case SDLK_5:
225 keysym->sym = '%'; 280 keysym->sym = '%';
226 break; 281 break;
227 case SDLK_6: 282 case SDLK_6:
228 keysym->sym = SDLK_CARET; 283 keysym->sym = SDLK_CARET;
229 break; 284 break;
230 case SDLK_7: 285 case SDLK_7:
231 keysym->sym = SDLK_AMPERSAND; 286 keysym->sym = SDLK_AMPERSAND;
232 break; 287 break;
233 case SDLK_8: 288 case SDLK_8:
234 keysym->sym = SDLK_ASTERISK; 289 keysym->sym = SDLK_ASTERISK;
235 break; 290 break;
236 case SDLK_9: 291 case SDLK_9:
237 keysym->sym = SDLK_LEFTPAREN; 292 keysym->sym = SDLK_LEFTPAREN;
238 break; 293 break;
239 case SDLK_0: 294 case SDLK_0:
240 keysym->sym = SDLK_RIGHTPAREN; 295 keysym->sym = SDLK_RIGHTPAREN;
241 break; 296 break;
242 case SDLK_MINUS: 297 case SDLK_MINUS:
243 keysym->sym = SDLK_UNDERSCORE; 298 keysym->sym = SDLK_UNDERSCORE;
244 break; 299 break;
245 case SDLK_PLUS: 300 case SDLK_PLUS:
246 keysym->sym = SDLK_EQUALS; 301 keysym->sym = SDLK_EQUALS;
247 break; 302 break;
248 303
249 case SDLK_LEFTBRACKET: 304 case SDLK_LEFTBRACKET:
250 keysym->sym = '{'; 305 keysym->sym = '{';
251 break; 306 break;
252 case SDLK_RIGHTBRACKET: 307 case SDLK_RIGHTBRACKET:
253 keysym->sym = '}'; 308 keysym->sym = '}';
254 break; 309 break;
255 310
256 case SDLK_SEMICOLON: 311 case SDLK_SEMICOLON:
257 keysym->sym = SDLK_COLON; 312 keysym->sym = SDLK_COLON;
258 break; 313 break;
259 case SDLK_QUOTE: 314 case SDLK_QUOTE:
260 keysym->sym = SDLK_QUOTEDBL; 315 keysym->sym = SDLK_QUOTEDBL;
261 break; 316 break;
262 case SDLK_BACKSLASH: 317 case SDLK_BACKSLASH:
263 keysym->sym = '|'; 318 keysym->sym = '|';
264 break; 319 break;
265 320
266 case SDLK_COMMA: 321 case SDLK_COMMA:
267 keysym->sym = SDLK_LESS; 322 keysym->sym = SDLK_LESS;
268 break; 323 break;
269 case SDLK_PERIOD: 324 case SDLK_PERIOD:
270 keysym->sym = SDLK_GREATER; 325 keysym->sym = SDLK_GREATER;
271 break; 326 break;
272 case SDLK_SLASH: 327 case SDLK_SLASH:
273 keysym->sym = SDLK_QUESTION; 328 keysym->sym = SDLK_QUESTION;
274 break; 329 break;
275 330
276 default: 331 default:
277 break; 332 break;
278 } 333 }
279 } 334 }
280 return keysym; 335 return keysym;
281 } 336 }
282 337
283 #define CONVERTMOUSEPOSITION() \ 338 #define CONVERTMOUSEPOSITION() \
284 /* We have to inverse the mouse position, because every non-os/2 system */ \ 339 /* We have to inverse the mouse position, because every non-os/2 system */ \
285 /* has a coordinate system where the (0;0) is the top-left corner, */ \ 340 /* has a coordinate system where the (0;0) is the top-left corner, */ \
286 /* while on os/2 it's the bottom left corner! */ \ 341 /* while on os/2 it's the bottom left corner! */ \
287 if (FSLib_QueryFSMode(hwnd)) \ 342 if (FSLib_QueryFSMode(hwnd)) \
288 { \ 343 { \
289 /* We're in FS mode! */ \ 344 /* We're in FS mode! */ \
290 /* In FS mode our window is as big as fullscreen mode, but not necessary as */ \ 345 /* In FS mode our window is as big as fullscreen mode, but not necessary as */ \
291 /* big as the source buffer (can be bigger) */ \ 346 /* big as the source buffer (can be bigger) */ \
292 /* So, limit mouse pos to source buffer size! */ \ 347 /* So, limit mouse pos to source buffer size! */ \
293 if (ppts->x<0) ppts->x = 0; \ 348 if (ppts->x<0) ppts->x = 0; \
294 if (ppts->y<0) ppts->y = 0; \ 349 if (ppts->y<0) ppts->y = 0; \
295 if (ppts->x>=pVideo->hidden->SrcBufferDesc.uiXResolution) ppts->x = pVideo->hidden->SrcBufferDesc.uiXResolution-1; \ 350 if (ppts->x>=pVideo->hidden->SrcBufferDesc.uiXResolution) ppts->x = pVideo->hidden->SrcBufferDesc.uiXResolution-1; \
296 if (ppts->y>=pVideo->hidden->SrcBufferDesc.uiYResolution) ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution-1; \ 351 if (ppts->y>=pVideo->hidden->SrcBufferDesc.uiYResolution) ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution-1; \
297 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ \ 352 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ \
298 ptl.x = ppts->x; ptl.y = ppts->y; \ 353 ptl.x = ppts->x; ptl.y = ppts->y; \
299 WinMapWindowPoints(pVideo->hidden->hwndClient, HWND_DESKTOP, &ptl, 1); \ 354 WinMapWindowPoints(pVideo->hidden->hwndClient, HWND_DESKTOP, &ptl, 1); \
300 WinSetPointerPos(HWND_DESKTOP, ptl.x, ptl.y); \ 355 WinSetPointerPos(HWND_DESKTOP, ptl.x, ptl.y); \
301 /* Then convert OS/2 position to SDL position */ \ 356 /* Then convert OS/2 position to SDL position */ \
302 ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution - ppts->y - 1; \ 357 ppts->y = pVideo->hidden->SrcBufferDesc.uiYResolution - ppts->y - 1; \
303 } else \ 358 } else \
304 { \ 359 { \
305 SWP swpClient; \ 360 SWP swpClient; \
306 /* We're in windowed mode! */ \ 361 /* We're in windowed mode! */ \
307 WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient); \ 362 WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient); \
308 /* Convert OS/2 mouse position to SDL position, and also scale it! */ \ 363 /* Convert OS/2 mouse position to SDL position, and also scale it! */ \
309 (ppts->x) = (ppts->x) * pVideo->hidden->SrcBufferDesc.uiXResolution / swpClient.cx; \ 364 (ppts->x) = (ppts->x) * pVideo->hidden->SrcBufferDesc.uiXResolution / swpClient.cx; \
310 (ppts->y) = (ppts->y) * pVideo->hidden->SrcBufferDesc.uiYResolution / swpClient.cy; \ 365 (ppts->y) = (ppts->y) * pVideo->hidden->SrcBufferDesc.uiYResolution / swpClient.cy; \
311 (ppts->y) = pVideo->hidden->SrcBufferDesc.uiYResolution - (ppts->y) - 1; \ 366 (ppts->y) = pVideo->hidden->SrcBufferDesc.uiYResolution - (ppts->y) - 1; \
312 } 367 }
313 368
314 369
315 370
316 ///////////////////////////////////////////////////////////////////// 371 /////////////////////////////////////////////////////////////////////
317 // 372 //
349 return (MRESULT) TRUE; 404 return (MRESULT) TRUE;
350 } 405 }
351 */ 406 */
352 407
353 // If it's not repeated, then let's see if its pressed or released! 408 // If it's not repeated, then let's see if its pressed or released!
354 if (SHORT1FROMMP(mp1) & KC_KEYUP) 409 if (SHORT1FROMMP(mp1) & KC_KEYUP)
355 { 410 {
356 // A key has been released 411 // A key has been released
357 SDL_keysym keysym; 412 SDL_keysym keysym;
358 413
359 #ifdef DEBUG_BUILD 414 #ifdef DEBUG_BUILD
360 // printf("WM_CHAR, keyup, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code 415 // printf("WM_CHAR, keyup, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code
361 #endif 416 #endif
362 417
363 // One problem is with F1, which gets only the keyup message because 418 // One problem is with F1, which gets only the keyup message because
364 // it is a system key. 419 // it is a system key.
365 // So, when we get keyup message, we simulate keydown too! 420 // So, when we get keyup message, we simulate keydown too!
366 // UPDATE: 421 // UPDATE:
367 // This problem should be solved now, that the accelerator keys are 422 // This problem should be solved now, that the accelerator keys are
368 // disabled for this window! 423 // disabled for this window!
369 /* 424 /*
370 if (SHORT2FROMMP(mp2)==VK_F1) 425 if (SHORT2FROMMP(mp2)==VK_F1)
371 { 426 {
372 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code 427 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code
373 SHORT1FROMMP(mp2), // Character code 428 SHORT1FROMMP(mp2), // Character code
374 CHAR4FROMMP(mp1), // HW Scan code 429 CHAR4FROMMP(mp1), // HW Scan code
375 &keysym,0)); 430 &keysym,0));
376 }*/ 431 }*/
377 432
378 SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code 433 SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code
379 SHORT1FROMMP(mp2), // Character code 434 SHORT1FROMMP(mp2), // Character code
380 CHAR4FROMMP(mp1), // HW Scan code 435 CHAR4FROMMP(mp1), // HW Scan code
381 &keysym,0)); 436 &keysym,0));
382 437
383 } else 438 } else
384 { 439 {
385 // A key has been pressed 440 // A key has been pressed
386 SDL_keysym keysym; 441 SDL_keysym keysym;
387 442
388 #ifdef DEBUG_BUILD 443 #ifdef DEBUG_BUILD
389 // printf("WM_CHAR, keydown, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code 444 // printf("WM_CHAR, keydown, code is [0x%0x]\n", CHAR4FROMMP(mp1)); // HW scan code
390 #endif 445 #endif
391 // Check for fastkeys: ALT+HOME to toggle FS mode 446 // Check for fastkeys: ALT+HOME to toggle FS mode
392 // ALT+END to close app 447 // ALT+END to close app
393 if ((SHORT1FROMMP(mp1) & KC_ALT) && 448 if ((SHORT1FROMMP(mp1) & KC_ALT) &&
394 (SHORT2FROMMP(mp2) == VK_HOME)) 449 (SHORT2FROMMP(mp2) == VK_HOME))
395 { 450 {
396 #ifdef DEBUG_BUILD 451 #ifdef DEBUG_BUILD
397 printf(" Pressed ALT+HOME!\n"); fflush(stdout); 452 printf(" Pressed ALT+HOME!\n"); fflush(stdout);
398 #endif 453 #endif
399 // Only switch between fullscreen and back if it's not 454 // Only switch between fullscreen and back if it's not
400 // a resizable mode! 455 // a resizable mode!
401 if ( 456 if (
402 (!pVideo->hidden->pSDLSurface) || 457 (!pVideo->hidden->pSDLSurface) ||
403 ((pVideo->hidden->pSDLSurface) 458 ((pVideo->hidden->pSDLSurface)
404 && ((pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE)==0) 459 && ((pVideo->hidden->pSDLSurface->flags & SDL_RESIZABLE)==0)
405 ) 460 )
406 ) 461 )
407 FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd)); 462 FSLib_ToggleFSMode(hwnd, !FSLib_QueryFSMode(hwnd));
408 #ifdef DEBUG_BUILD 463 #ifdef DEBUG_BUILD
409 else 464 else
410 printf(" Resizable mode, so discarding ALT+HOME!\n"); fflush(stdout); 465 printf(" Resizable mode, so discarding ALT+HOME!\n"); fflush(stdout);
411 #endif 466 #endif
412 } else 467 } else
413 if ((SHORT1FROMMP(mp1) & KC_ALT) && 468 if ((SHORT1FROMMP(mp1) & KC_ALT) &&
414 (SHORT2FROMMP(mp2) == VK_END)) 469 (SHORT2FROMMP(mp2) == VK_END))
415 { 470 {
416 #ifdef DEBUG_BUILD 471 #ifdef DEBUG_BUILD
417 printf(" Pressed ALT+END!\n"); fflush(stdout); 472 printf(" Pressed ALT+END!\n"); fflush(stdout);
418 #endif 473 #endif
419 // Close window, and get out of loop! 474 // Close window, and get out of loop!
420 // Also send event to SDL application, but we won't 475 // Also send event to SDL application, but we won't
421 // wait for it to be processed! 476 // wait for it to be processed!
422 SDL_PrivateQuit(); 477 SDL_PrivateQuit();
423 WinPostMsg(hwnd, WM_QUIT, 0, 0); 478 WinPostMsg(hwnd, WM_QUIT, 0, 0);
424 } else 479 } else
425 { 480 {
426 481
427 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code 482 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(SHORT2FROMMP(mp2), // VK_ code
428 SHORT1FROMMP(mp2), // Character code 483 SHORT1FROMMP(mp2), // Character code
429 CHAR4FROMMP(mp1), // HW Scan code 484 CHAR4FROMMP(mp1), // HW Scan code
430 &keysym,1)); 485 &keysym,1));
431 486
432 } 487 }
433 } 488 }
434 } 489 }
435 return (MRESULT) TRUE; 490 return (MRESULT) TRUE;
436 491
437 case WM_TRANSLATEACCEL: 492 case WM_TRANSLATEACCEL:
438 { 493 {
439 PQMSG pqmsg; 494 PQMSG pqmsg;
440 pqmsg = (PQMSG) mp1; 495 pqmsg = (PQMSG) mp1;
441 if (mp1) 496 if (mp1)
442 { 497 {
443 if (pqmsg->msg == WM_CHAR) 498 if (pqmsg->msg == WM_CHAR)
444 { 499 {
445 // WM_CHAR message! 500 // WM_CHAR message!
446 // Let's filter the ALT keypress and all other acceleration keys! 501 // Let's filter the ALT keypress and all other acceleration keys!
447 return (MRESULT) FALSE; 502 return (MRESULT) FALSE;
448 } 503 }
449 } 504 }
450 break; // Default processing (pass to parent until frame control) 505 break; // Default processing (pass to parent until frame control)
451 } 506 }
452 507
453 case WM_PAINT: // Window redraw! 508 case WM_PAINT: // Window redraw!
454 #ifdef DEBUG_BUILD 509 #ifdef DEBUG_BUILD
558 } 613 }
559 } 614 }
560 #ifdef DEBUG_BUILD 615 #ifdef DEBUG_BUILD
561 else 616 else
562 { 617 {
563 printf("WM_PAINT : No pVideo!\n"); fflush(stdout); 618 printf("WM_PAINT : No pVideo!\n"); fflush(stdout);
564 } 619 }
565 #endif 620 #endif
566 WinEndPaint(ps); 621 WinEndPaint(ps);
567 #ifdef DEBUG_BUILD 622 #ifdef DEBUG_BUILD
568 printf("WM_PAINT : Done.\n"); 623 printf("WM_PAINT : Done.\n");
571 return 0; 626 return 0;
572 627
573 case WM_SIZE: 628 case WM_SIZE:
574 { 629 {
575 #ifdef DEBUG_BUILD 630 #ifdef DEBUG_BUILD
576 printf("WM_SIZE : (%d %d)\n", 631 printf("WM_SIZE : (%d %d)\n",
577 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); fflush(stdout); 632 SHORT1FROMMP(mp2), SHORT2FROMMP(mp2)); fflush(stdout);
578 #endif 633 #endif
579 iWindowSizeX = SHORT1FROMMP(mp2); 634 iWindowSizeX = SHORT1FROMMP(mp2);
580 iWindowSizeY = SHORT2FROMMP(mp2); 635 iWindowSizeY = SHORT2FROMMP(mp2);
581 bWindowResized = 1; 636 bWindowResized = 1;
582 637
583 // Make sure the window will be redrawn 638 // Make sure the window will be redrawn
584 WinInvalidateRegion(hwnd, NULL, TRUE); 639 WinInvalidateRegion(hwnd, NULL, TRUE);
585 } 640 }
586 break; 641 break;
587 642
588 case WM_FSLIBNOTIFICATION: 643 case WM_FSLIBNOTIFICATION:
589 #ifdef DEBUG_BUILD 644 #ifdef DEBUG_BUILD
590 printf("WM_FSLIBNOTIFICATION\n"); fflush(stdout); 645 printf("WM_FSLIBNOTIFICATION\n"); fflush(stdout);
591 #endif 646 #endif
592 if ((int)mp1 == FSLN_TOGGLEFSMODE) 647 if ((int)mp1 == FSLN_TOGGLEFSMODE)
593 { 648 {
594 // FS mode changed, reblit image! 649 // FS mode changed, reblit image!
595 pVideo = FSLib_GetUserParm(hwnd); 650 pVideo = FSLib_GetUserParm(hwnd);
596 if (pVideo) 651 if (pVideo)
597 { 652 {
598 if (!pVideo->hidden->pSDLSurface) 653 if (!pVideo->hidden->pSDLSurface)
599 { 654 {
600 // Resizable surface and in resizing! 655 // Resizable surface and in resizing!
601 // So, don't blit now! 656 // So, don't blit now!
649 #endif 704 #endif
650 705
651 DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer); 706 DosReleaseMutexSem(pVideo->hidden->hmtxUseSrcBuffer);
652 } 707 }
653 } 708 }
654 } 709 }
655 } 710 }
656 return (MPARAM) 1; 711 return (MPARAM) 1;
657 712
658 case WM_ACTIVATE: 713 case WM_ACTIVATE:
659 #ifdef DEBUG_BUILD 714 #ifdef DEBUG_BUILD
668 { 723 {
669 // Went into focus 724 // Went into focus
670 if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured)) 725 if ((pVideo->hidden->iMouseVisible) && (!bMouseCaptured))
671 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE)); 726 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
672 else 727 else
673 WinSetPointer(HWND_DESKTOP, NULL); 728 WinSetPointer(HWND_DESKTOP, NULL);
674 729
675 if (bMouseCapturable) 730 if (bMouseCapturable)
676 { 731 {
677 // Re-capture the mouse, if we captured it before! 732 // Re-capture the mouse, if we captured it before!
678 WinSetCapture(HWND_DESKTOP, hwnd); 733 WinSetCapture(HWND_DESKTOP, hwnd);
679 bMouseCaptured = 1; 734 bMouseCaptured = 1;
680 { 735 {
681 SWP swpClient; 736 SWP swpClient;
682 POINTL ptl; 737 POINTL ptl;
683 // Center the mouse to the middle of the window! 738 // Center the mouse to the middle of the window!
687 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ 742 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
688 WinSetPointerPos(HWND_DESKTOP, 743 WinSetPointerPos(HWND_DESKTOP,
689 ptl.x + swpClient.cx/2, 744 ptl.x + swpClient.cx/2,
690 ptl.y + swpClient.cy/2); 745 ptl.y + swpClient.cy/2);
691 } 746 }
692 } 747 }
693 } else 748 } else
694 { 749 {
695 // Went out of focus 750 // Went out of focus
696 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE)); 751 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE));
697 752
698 if (bMouseCaptured) 753 if (bMouseCaptured)
699 { 754 {
700 // Release the mouse 755 // Release the mouse
701 WinSetCapture(HWND_DESKTOP, hwnd); 756 WinSetCapture(HWND_DESKTOP, hwnd);
702 bMouseCaptured = 0; 757 bMouseCaptured = 0;
703 } 758 }
704 } 759 }
705 } 760 }
706 #ifdef DEBUG_BUILD 761 #ifdef DEBUG_BUILD
707 printf("WM_ACTIVATE done\n"); fflush(stdout); 762 printf("WM_ACTIVATE done\n"); fflush(stdout);
708 #endif 763 #endif
715 #endif 770 #endif
716 771
717 pVideo = FSLib_GetUserParm(hwnd); 772 pVideo = FSLib_GetUserParm(hwnd);
718 if (pVideo) 773 if (pVideo)
719 { 774 {
720 SDL_PrivateMouseButton(SDL_PRESSED, 775 SDL_PrivateMouseButton(SDL_PRESSED,
721 SDL_BUTTON_LEFT, 776 SDL_BUTTON_LEFT,
722 0, 0); // Don't report mouse movement! 777 0, 0); // Don't report mouse movement!
723 778
724 if (bMouseCapturable) 779 if (bMouseCapturable)
725 { 780 {
726 // We should capture the mouse! 781 // We should capture the mouse!
727 if (!bMouseCaptured) 782 if (!bMouseCaptured)
728 { 783 {
729 WinSetCapture(HWND_DESKTOP, hwnd); 784 WinSetCapture(HWND_DESKTOP, hwnd);
730 WinSetPointer(HWND_DESKTOP, NULL); 785 WinSetPointer(HWND_DESKTOP, NULL);
731 bMouseCaptured = 1; 786 bMouseCaptured = 1;
732 { 787 {
733 SWP swpClient; 788 SWP swpClient;
734 POINTL ptl; 789 POINTL ptl;
739 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ 794 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
740 WinSetPointerPos(HWND_DESKTOP, 795 WinSetPointerPos(HWND_DESKTOP,
741 ptl.x + swpClient.cx/2, 796 ptl.x + swpClient.cx/2,
742 ptl.y + swpClient.cy/2); 797 ptl.y + swpClient.cy/2);
743 } 798 }
744 } 799 }
745 } 800 }
746 } 801 }
747 break; 802 break;
748 case WM_BUTTON1UP: 803 case WM_BUTTON1UP:
749 #ifdef DEBUG_BUILD 804 #ifdef DEBUG_BUILD
750 printf("WM_BUTTON1UP\n"); fflush(stdout); 805 printf("WM_BUTTON1UP\n"); fflush(stdout);
759 #endif 814 #endif
760 815
761 pVideo = FSLib_GetUserParm(hwnd); 816 pVideo = FSLib_GetUserParm(hwnd);
762 if (pVideo) 817 if (pVideo)
763 { 818 {
764 SDL_PrivateMouseButton(SDL_PRESSED, 819 SDL_PrivateMouseButton(SDL_PRESSED,
765 SDL_BUTTON_RIGHT, 820 SDL_BUTTON_RIGHT,
766 0, 0); // Don't report mouse movement! 821 0, 0); // Don't report mouse movement!
767 822
768 if (bMouseCapturable) 823 if (bMouseCapturable)
769 { 824 {
770 // We should capture the mouse! 825 // We should capture the mouse!
771 if (!bMouseCaptured) 826 if (!bMouseCaptured)
772 { 827 {
773 WinSetCapture(HWND_DESKTOP, hwnd); 828 WinSetCapture(HWND_DESKTOP, hwnd);
774 WinSetPointer(HWND_DESKTOP, NULL); 829 WinSetPointer(HWND_DESKTOP, NULL);
775 bMouseCaptured = 1; 830 bMouseCaptured = 1;
776 { 831 {
777 SWP swpClient; 832 SWP swpClient;
778 POINTL ptl; 833 POINTL ptl;
783 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ 838 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
784 WinSetPointerPos(HWND_DESKTOP, 839 WinSetPointerPos(HWND_DESKTOP,
785 ptl.x + swpClient.cx/2, 840 ptl.x + swpClient.cx/2,
786 ptl.y + swpClient.cy/2); 841 ptl.y + swpClient.cy/2);
787 } 842 }
788 } 843 }
789 } 844 }
790 845
791 } 846 }
792 break; 847 break;
793 case WM_BUTTON2UP: 848 case WM_BUTTON2UP:
794 #ifdef DEBUG_BUILD 849 #ifdef DEBUG_BUILD
808 { 863 {
809 SDL_PrivateMouseButton(SDL_PRESSED, 864 SDL_PrivateMouseButton(SDL_PRESSED,
810 SDL_BUTTON_MIDDLE, 865 SDL_BUTTON_MIDDLE,
811 0, 0); // Don't report mouse movement! 866 0, 0); // Don't report mouse movement!
812 867
813 if (bMouseCapturable) 868 if (bMouseCapturable)
814 { 869 {
815 // We should capture the mouse! 870 // We should capture the mouse!
816 if (!bMouseCaptured) 871 if (!bMouseCaptured)
817 { 872 {
818 WinSetCapture(HWND_DESKTOP, hwnd); 873 WinSetCapture(HWND_DESKTOP, hwnd);
819 WinSetPointer(HWND_DESKTOP, NULL); 874 WinSetPointer(HWND_DESKTOP, NULL);
820 bMouseCaptured = 1; 875 bMouseCaptured = 1;
821 { 876 {
822 SWP swpClient; 877 SWP swpClient;
823 POINTL ptl; 878 POINTL ptl;
828 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ 883 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
829 WinSetPointerPos(HWND_DESKTOP, 884 WinSetPointerPos(HWND_DESKTOP,
830 ptl.x + swpClient.cx/2, 885 ptl.x + swpClient.cx/2,
831 ptl.y + swpClient.cy/2); 886 ptl.y + swpClient.cy/2);
832 } 887 }
833 } 888 }
834 } 889 }
835 } 890 }
836 break; 891 break;
837 case WM_BUTTON3UP: 892 case WM_BUTTON3UP:
838 #ifdef DEBUG_BUILD 893 #ifdef DEBUG_BUILD
839 printf("WM_BUTTON3UP\n"); fflush(stdout); 894 printf("WM_BUTTON3UP\n"); fflush(stdout);
856 } else 911 } else
857 { 912 {
858 POINTS *ppts = (POINTS *) (&mp1); 913 POINTS *ppts = (POINTS *) (&mp1);
859 POINTL ptl; 914 POINTL ptl;
860 915
861 CONVERTMOUSEPOSITION();
862
863 if (bMouseCaptured) 916 if (bMouseCaptured)
864 { 917 {
865 SWP swpClient; 918 SWP swpClient;
919
920 WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient);
921
866 // Send relative mouse position, and re-center the mouse 922 // Send relative mouse position, and re-center the mouse
867 // Reposition the mouse to the center of the screen/window 923 // Reposition the mouse to the center of the screen/window
868 SDL_PrivateMouseMotion(0, // Buttons not changed 924 SDL_PrivateMouseMotion(0, // Buttons not changed
869 1, // Relative position 925 1, // Relative position
870 ppts->x - (pVideo->hidden->SrcBufferDesc.uiXResolution/2), 926 ppts->x - (swpClient.cx/2),
871 ppts->y+1 - (pVideo->hidden->SrcBufferDesc.uiYResolution/2)); 927 (swpClient.cy/2) - ppts->y);
872 928
873 WinQueryWindowPos(pVideo->hidden->hwndClient, &swpClient);
874 ptl.x = 0; ptl.y = 0; 929 ptl.x = 0; ptl.y = 0;
875 WinMapWindowPoints(pVideo->hidden->hwndClient, HWND_DESKTOP, &ptl, 1); 930 WinMapWindowPoints(pVideo->hidden->hwndClient, HWND_DESKTOP, &ptl, 1);
876 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */ 931 pVideo->hidden->iSkipWMMOUSEMOVE++; /* Don't take next WM_MOUSEMOVE into account! */
877 // Center the mouse to the middle of the window! 932 // Center the mouse to the middle of the window!
878 WinSetPointerPos(HWND_DESKTOP, 933 WinSetPointerPos(HWND_DESKTOP,
879 ptl.x + swpClient.cx/2, 934 ptl.x + swpClient.cx/2,
880 ptl.y + swpClient.cy/2); 935 ptl.y + swpClient.cy/2);
881 } else 936 } else
882 { 937 {
938 CONVERTMOUSEPOSITION();
939
883 // Send absolute mouse position 940 // Send absolute mouse position
884 SDL_PrivateMouseMotion(0, // Buttons not changed 941 SDL_PrivateMouseMotion(0, // Buttons not changed
885 0, // Absolute position 942 0, // Absolute position
886 ppts->x, 943 ppts->x,
887 ppts->y); 944 ppts->y);
984 return WinDefWindowProc(hwnd, msg, mp1, mp2); 1041 return WinDefWindowProc(hwnd, msg, mp1, mp2);
985 } 1042 }
986 1043
987 ///////////////////////////////////////////////////////////////////// 1044 /////////////////////////////////////////////////////////////////////
988 // 1045 //
1046 // FrameWndProc
1047 //
1048 // This is the message processing window procedure for the
1049 // frame window of SDLWindowClass.
1050 //
1051 /////////////////////////////////////////////////////////////////////
1052 static MRESULT EXPENTRY FrameWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1053 {
1054 PFNWP pOldFrameProc;
1055 MRESULT result;
1056 PTRACKINFO ti;
1057 int cx, cy, ncx, ncy;
1058 RECTL rclTemp;
1059 PSWP pswpTemp;
1060
1061 SDL_VideoDevice *pVideo = NULL;
1062
1063 pVideo = (SDL_VideoDevice *) WinQueryWindowULong(hwnd, QWL_USER);
1064
1065 pOldFrameProc = pVideo->hidden->pfnOldFrameProc;
1066
1067 if ((pVideo->hidden->bProportionalResize) &&
1068 (msg==WM_ADJUSTWINDOWPOS) &&
1069 (!FSLib_QueryFSMode(pVideo->hidden->hwndClient))
1070 )
1071 {
1072 pswpTemp = (PSWP) mp1;
1073
1074 /* Resizing? */
1075 if (pswpTemp->fl & SWP_SIZE)
1076 {
1077 /* Calculate client size */
1078 rclTemp.xLeft = pswpTemp->x;
1079 rclTemp.xRight = pswpTemp->x + pswpTemp->cx;
1080 rclTemp.yBottom = pswpTemp->y;
1081 rclTemp.yTop = pswpTemp->y + pswpTemp->cy;
1082 WinCalcFrameRect(hwnd, &rclTemp, TRUE);
1083
1084 ncx = cx = rclTemp.xRight - rclTemp.xLeft;
1085 ncy = cy = rclTemp.yTop - rclTemp.yBottom;
1086
1087 /* Calculate new size to keep it proportional */
1088
1089 if ((pVideo->hidden->ulResizingFlag & TF_LEFT) || (pVideo->hidden->ulResizingFlag & TF_RIGHT))
1090 {
1091 /* The window is resized horizontally */
1092 ncy = pVideo->hidden->SrcBufferDesc.uiYResolution * cx / pVideo->hidden->SrcBufferDesc.uiXResolution;
1093 } else
1094 if ((pVideo->hidden->ulResizingFlag & TF_TOP) || (pVideo->hidden->ulResizingFlag & TF_BOTTOM))
1095 {
1096 /* The window is resized vertically */
1097 ncx = pVideo->hidden->SrcBufferDesc.uiXResolution * cy / pVideo->hidden->SrcBufferDesc.uiYResolution;
1098 }
1099
1100 /* Calculate back frame coordinates */
1101 rclTemp.xLeft = pswpTemp->x;
1102 rclTemp.xRight = pswpTemp->x + ncx;
1103 rclTemp.yBottom = pswpTemp->y;
1104 rclTemp.yTop = pswpTemp->y + ncy;
1105 WinCalcFrameRect(hwnd, &rclTemp, FALSE);
1106
1107 /* Store new size/position info */
1108 pswpTemp->cx = rclTemp.xRight - rclTemp.xLeft;
1109
1110 if (!(pVideo->hidden->ulResizingFlag & TF_TOP))
1111 {
1112 pswpTemp->y = pswpTemp->y + pswpTemp->cy - (rclTemp.yTop - rclTemp.yBottom);
1113 pswpTemp->cy = rclTemp.yTop - rclTemp.yBottom;
1114 } else
1115 {
1116 pswpTemp->cy = rclTemp.yTop - rclTemp.yBottom;
1117 }
1118 }
1119 }
1120
1121 result = (*pOldFrameProc)(hwnd, msg, mp1, mp2);
1122
1123 if ((pVideo->hidden->bProportionalResize) && (msg==WM_QUERYTRACKINFO))
1124 {
1125 ti = (PTRACKINFO) mp2;
1126
1127 /* Store the direction of resizing */
1128 if ((ti->fs & TF_LEFT) || (ti->fs & TF_RIGHT) ||
1129 (ti->fs & TF_TOP) || (ti->fs & TF_BOTTOM))
1130 pVideo->hidden->ulResizingFlag = ti->fs;
1131 }
1132
1133 return result;
1134 }
1135
1136 /////////////////////////////////////////////////////////////////////
1137 //
989 // PMThreadFunc 1138 // PMThreadFunc
990 // 1139 //
991 // This function implements the PM-Thread, which initializes the 1140 // This function implements the PM-Thread, which initializes the
992 // application window itself, the DIVE, and start message processing. 1141 // application window itself, the DIVE, and start message processing.
993 // 1142 //
1035 "SDL Application", 1184 "SDL Application",
1036 NULLHANDLE, 0, 1185 NULLHANDLE, 0,
1037 &(pVideo->hidden->SrcBufferDesc), 1186 &(pVideo->hidden->SrcBufferDesc),
1038 WndProc, 1187 WndProc,
1039 &(pVideo->hidden->hwndClient), 1188 &(pVideo->hidden->hwndClient),
1040 &(pVideo->hidden->hwndFrame)); 1189 &(pVideo->hidden->hwndFrame));
1041 1190
1042 #ifdef DEBUG_BUILD 1191 #ifdef DEBUG_BUILD
1043 printf("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc); 1192 printf("[PMThreadFunc] : FSLib_CreateWindow() rc = %d\n", rc);
1044 fflush(stdout); 1193 fflush(stdout);
1045 #endif 1194 #endif
1082 (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - (rectl.xRight-rectl.xLeft)) / 2, 1231 (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - (rectl.xRight-rectl.xLeft)) / 2,
1083 (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - (rectl.yTop-rectl.yBottom)) / 2, 1232 (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - (rectl.yTop-rectl.yBottom)) / 2,
1084 (rectl.xRight-rectl.xLeft), 1233 (rectl.xRight-rectl.xLeft),
1085 (rectl.yTop-rectl.yBottom), 1234 (rectl.yTop-rectl.yBottom),
1086 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE); 1235 SWP_SIZE | SWP_ACTIVATE | SWP_SHOW | SWP_MOVE);
1236
1237 // Subclass frame procedure and store old window proc address
1238 pVideo->hidden->pfnOldFrameProc =
1239 WinSubclassWindow(pVideo->hidden->hwndFrame, FrameWndProc);
1240 WinSetWindowULong(pVideo->hidden->hwndFrame, QWL_USER, (ULONG) pVideo);
1087 1241
1088 #ifdef DEBUG_BUILD 1242 #ifdef DEBUG_BUILD
1089 printf("[PMThreadFunc] : Entering message loop\n"); fflush(stdout); 1243 printf("[PMThreadFunc] : Entering message loop\n"); fflush(stdout);
1090 #endif 1244 #endif
1091 pVideo->hidden->iPMThreadStatus = 1; 1245 pVideo->hidden->iPMThreadStatus = 1;
1812 // Remember if there was an error at WinCreateMsgQueue(), because we don't 1966 // Remember if there was an error at WinCreateMsgQueue(), because we don't
1813 // want to destroy somebody else's queue later. :) 1967 // want to destroy somebody else's queue later. :)
1814 hmqerror = WinGetLastError(hab); 1968 hmqerror = WinGetLastError(hab);
1815 1969
1816 WinSetWindowPos(_this->hidden->hwndFrame, HWND_TOP, 1970 WinSetWindowPos(_this->hidden->hwndFrame, HWND_TOP,
1817 0, 0, 0, 0, SWP_MINIMIZE); 1971 0, 0, 0, 0, SWP_MINIMIZE);
1818 1972
1819 // Now destroy the message queue, if we've created it! 1973 // Now destroy the message queue, if we've created it!
1820 if (ERRORIDERROR(hmqerror)==0) 1974 if (ERRORIDERROR(hmqerror)==0)
1821 WinDestroyMsgQueue(hmq); 1975 WinDestroyMsgQueue(hmq);
1822 1976
2137 specified -- the desired bpp will be emulated with a shadow 2291 specified -- the desired bpp will be emulated with a shadow
2138 surface if necessary. If a new mode is returned, this function 2292 surface if necessary. If a new mode is returned, this function
2139 should take care of cleaning up the current mode. 2293 should take care of cleaning up the current mode.
2140 */ 2294 */
2141 static SDL_Surface *os2fslib_SetVideoMode(_THIS, SDL_Surface *current, 2295 static SDL_Surface *os2fslib_SetVideoMode(_THIS, SDL_Surface *current,
2142 int width, int height, int bpp, Uint32 flags) 2296 int width, int height, int bpp, Uint32 flags)
2143 { 2297 {
2144 static int bFirstCall = 1; 2298 static int bFirstCall = 1;
2145 FSLib_VideoMode_p pModeInfo, pModeInfoFound; 2299 FSLib_VideoMode_p pModeInfo, pModeInfoFound;
2146 FSLib_VideoMode TempModeInfo; 2300 FSLib_VideoMode TempModeInfo;
2147 HAB hab; 2301 HAB hab;
2473 pRect->y = 0; 2627 pRect->y = 0;
2474 pRect->w = pFSMode->uiXResolution; 2628 pRect->w = pFSMode->uiXResolution;
2475 pRect->h = pFSMode->uiYResolution; 2629 pRect->h = pFSMode->uiYResolution;
2476 #ifdef DEBUG_BUILD 2630 #ifdef DEBUG_BUILD
2477 // printf("!!! Seems to be good!\n"); 2631 // printf("!!! Seems to be good!\n");
2478 // printf("F: %dx%d\n", pRect->w, pRect->h); 2632 // printf("F: %dx%d\n", pRect->w, pRect->h);
2479 #endif 2633 #endif
2480 // And insert into list of pRects 2634 // And insert into list of pRects
2481 if (!(_this->hidden->pListModesResult)) 2635 if (!(_this->hidden->pListModesResult))
2482 { 2636 {
2483 #ifdef DEBUG_BUILD 2637 #ifdef DEBUG_BUILD
2487 // We're the first one to be inserted! 2641 // We're the first one to be inserted!
2488 _this->hidden->pListModesResult = (SDL_Rect**) SDL_malloc(2*sizeof(SDL_Rect*)); 2642 _this->hidden->pListModesResult = (SDL_Rect**) SDL_malloc(2*sizeof(SDL_Rect*));
2489 if (_this->hidden->pListModesResult) 2643 if (_this->hidden->pListModesResult)
2490 { 2644 {
2491 _this->hidden->pListModesResult[0] = pRect; 2645 _this->hidden->pListModesResult[0] = pRect;
2492 _this->hidden->pListModesResult[1] = NULL; 2646 _this->hidden->pListModesResult[1] = NULL;
2493 } else 2647 } else
2494 { 2648 {
2495 SDL_free(pRect); 2649 SDL_free(pRect);
2496 } 2650 }
2497 } else 2651 } else
2599 // Initialize some internal variables 2753 // Initialize some internal variables
2600 _this->hidden->pListModesResult = NULL; 2754 _this->hidden->pListModesResult = NULL;
2601 _this->hidden->fInFocus = 0; 2755 _this->hidden->fInFocus = 0;
2602 _this->hidden->iSkipWMMOUSEMOVE = 0; 2756 _this->hidden->iSkipWMMOUSEMOVE = 0;
2603 _this->hidden->iMouseVisible = 1; 2757 _this->hidden->iMouseVisible = 1;
2758
2759 if (getenv("SDL_USE_PROPORTIONAL_WINDOW"))
2760 _this->hidden->bProportionalResize = 1;
2761 else
2762 {
2763 PPIB pib;
2764 PTIB tib;
2765 char *pchFileName, *pchTemp;
2766 char achConfigFile[CCHMAXPATH];
2767 FILE *hFile;
2768
2769 /* No environment variable to have proportional window.
2770 * Ok, let's check if this executable is in config file!
2771 */
2772 _this->hidden->bProportionalResize = 0;
2773
2774 DosGetInfoBlocks(&tib, &pib);
2775 pchTemp = pchFileName = pib->pib_pchcmd;
2776 while (*pchTemp)
2777 {
2778 if (*pchTemp=='\\')
2779 pchFileName = pchTemp+1;
2780 pchTemp++;
2781 }
2782 if (getenv("HOME"))
2783 {
2784 sprintf(achConfigFile, "%s\\.sdl.proportionals", getenv("HOME"));
2785 hFile = fopen(achConfigFile, "rt");
2786 if (!hFile)
2787 {
2788 /* Seems like the file cannot be opened or does not exist.
2789 * Let's try to create it with defaults!
2790 */
2791 hFile = fopen(achConfigFile, "wt");
2792 if (hFile)
2793 {
2794 fprintf(hFile, "; This file is a config file of SDL/2, containing\n");
2795 fprintf(hFile, "; the list of executables that must have proportional\n");
2796 fprintf(hFile, "; windows.\n");
2797 fprintf(hFile, ";\n");
2798 fprintf(hFile, "; You can add executable filenames into this file,\n");
2799 fprintf(hFile, "; one under the other. If SDL finds that a given\n");
2800 fprintf(hFile, "; program is in this list, then that application\n");
2801 fprintf(hFile, "; will have proportional windows, just like if\n");
2802 fprintf(hFile, "; the SET SDL_USE_PROPORTIONAL_WINDOW env. variable\n");
2803 fprintf(hFile, "; would have been set for that process.\n");
2804 fprintf(hFile, ";\n");
2805 fprintf(hFile, "\n");
2806 fprintf(hFile, "dosbox.exe\n");
2807 fclose(hFile);
2808 }
2809
2810 hFile = fopen(achConfigFile, "rt");
2811 }
2812
2813 if (hFile)
2814 {
2815 while (fgets(achConfigFile, sizeof(achConfigFile), hFile))
2816 {
2817 /* Cut \n from end of string */
2818
2819 while (achConfigFile[strlen(achConfigFile)-1] == '\n')
2820 achConfigFile[strlen(achConfigFile)-1] = 0;
2821
2822 /* Compare... */
2823 if (stricmp(achConfigFile, pchFileName)==0)
2824 {
2825 /* Found it in config file! */
2826 _this->hidden->bProportionalResize = 1;
2827 break;
2828 }
2829 }
2830 fclose(hFile);
2831 }
2832 }
2833 }
2834
2604 DosCreateMutexSem(NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE); 2835 DosCreateMutexSem(NULL, &(_this->hidden->hmtxUseSrcBuffer), 0, FALSE);
2605 2836
2606 // Now create our window with a default size 2837 // Now create our window with a default size
2607 2838
2608 // For this, we select the first available fullscreen mode as 2839 // For this, we select the first available fullscreen mode as
2775 3006
2776 return device; 3007 return device;
2777 } 3008 }
2778 3009
2779 VideoBootStrap OS2FSLib_bootstrap = { 3010 VideoBootStrap OS2FSLib_bootstrap = {
2780 "os2fslib", "OS/2 Video Output using FSLib", 3011 "os2fslib", "OS/2 Video Output using FSLib",
2781 os2fslib_Available, os2fslib_CreateDevice 3012 os2fslib_Available, os2fslib_CreateDevice
2782 }; 3013 };
2783 3014