comparison src/video/win32/SDL_win32window.c @ 3168:6338b7f2d024

Hi, I have prepared a set of patches to readd WindowsCE support to SDL 1.3. I've created a new GAPI/Rawframebuffer and a DirectDraw renderer. Both renderers are work in progress and there are several unimplemented cases. (Notably RenderLine/RenderPoint/RenderFill/QueryTexturePixels/UpdateTexture and texture blending ) Nevertheless I am successfully using these renderers together with the SDL software renderer. (On most devices the SDL software renderer will be much faster as there are only badly optimized vendor drivers available) I send these patches now in this unpolished state because there seems to be some interest in win ce and someone has to start supporting SDL 1.3 Now on to the patches: wince_events_window_fixes.patch fixes some wince incompatibilities and adds fullscreen support via SHFullScreen. NOTE: This patch shouldn't have any side effects on Windows, but I have NOT tested it on Windows, so please double-check. This patch doesn't dependent on the following ones. wince_renderers_system.patch This patch does all necessary modifications to the SDL system. - it adds the renderers to the configure system - it adds the renderers to win32video SDL_ceddrawrender.c SDL_ceddrawrender.h SDL_gapirender_c.h SDL_gapirender.c SDL_gapirender.h these files add the new render drivers and should be placed in src/video/win32 Some notes to people who want to test this: - I have only compiled sdl with ming32ce, so the VisualC files are not up to date - As mingw32ce has no ddraw.h this file must be taken from the MS SDK and modified to work with gcc - I had to modify line 2611 in configure.in to EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer -Wl,--image-base -Wl,0x10000" otherwise GetCPinfo wouldn't link. If someone knows whats causing this I'd be happy to hear about it. It would be great if these patches could make their way into SVN as this would make collaboration much much easier. I'm out of office for the next week and therefore will be unavailable via email. Regards Stefan
author Sam Lantinga <slouken@libsdl.org>
date Sun, 07 Jun 2009 02:44:46 +0000
parents 7f684f249ec9
children 413672b09bb3
comparison
equal deleted inserted replaced
3167:0c85abc61e47 3168:6338b7f2d024
35 35
36 #include "SDL_win32video.h" 36 #include "SDL_win32video.h"
37 37
38 /* This is included after SDL_win32video.h, which includes windows.h */ 38 /* This is included after SDL_win32video.h, which includes windows.h */
39 #include "SDL_syswm.h" 39 #include "SDL_syswm.h"
40
41
42 #define SHFS_SHOWTASKBAR 0x0001
43 #define SHFS_HIDETASKBAR 0x0002
44 #define SHFS_SHOWSIPBUTTON 0x0004
45 #define SHFS_HIDESIPBUTTON 0x0008
46 #define SHFS_SHOWSTARTICON 0x0010
47 #define SHFS_HIDESTARTICON 0x0020
48
49 #ifdef _WIN32_WCE
50 // dynamically load aygshell dll because we want SDL to work on HPC and be300
51 int aygshell_loaded = 0;
52 BOOL(WINAPI * SHFullScreen) (HWND hwndRequester, DWORD dwState) = 0;
53
54
55 static BOOL
56 CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
57 {
58 if (SHFullScreen == 0 && aygshell_loaded == 0) {
59 aygshell_loaded = 0;
60 void *lib = SDL_LoadObject("aygshell.dll");
61 if (lib) {
62 SHFullScreen =
63 (BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib,
64 "SHFullScreen");
65 }
66 }
67
68 if (SHFullScreen) {
69 SHFullScreen(hwndRequester, dwState);
70 //printf("SHFullscreen(%i)\n",dwState);
71 }
72 }
73
74 #endif
40 75
41 extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */ 76 extern HCTX *g_hCtx; /* the table of tablet event contexts, each windows has to have it's own tablet context */
42 static Uint32 highestId = 0; /* the highest id of the tablet context */ 77 static Uint32 highestId = 0; /* the highest id of the tablet context */
43 78
44 /* Fake window to help with DirectInput events. */ 79 /* Fake window to help with DirectInput events. */
383 { 418 {
384 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 419 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
385 RECT rect; 420 RECT rect;
386 DWORD style; 421 DWORD style;
387 HWND top; 422 HWND top;
423 BOOL menu;
388 int x, y; 424 int x, y;
389 425
390 /* Figure out what the window area will be */ 426 /* Figure out what the window area will be */
391 if (window->flags & SDL_WINDOW_FULLSCREEN) { 427 if (window->flags & SDL_WINDOW_FULLSCREEN) {
392 top = HWND_TOPMOST; 428 top = HWND_TOPMOST;
396 style = GetWindowLong(hwnd, GWL_STYLE); 432 style = GetWindowLong(hwnd, GWL_STYLE);
397 rect.left = 0; 433 rect.left = 0;
398 rect.top = 0; 434 rect.top = 0;
399 rect.right = window->w; 435 rect.right = window->w;
400 rect.bottom = window->h; 436 rect.bottom = window->h;
401 AdjustWindowRectEx(&rect, style, 437 #ifdef _WIN32_WCE
402 (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != 438 menu = FALSE;
403 NULL), 0); 439 #else
440 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
441 #endif
442 AdjustWindowRectEx(&rect, style, menu, 0);
404 443
405 if ((window->flags & SDL_WINDOW_FULLSCREEN) 444 if ((window->flags & SDL_WINDOW_FULLSCREEN)
406 || window->x == SDL_WINDOWPOS_CENTERED) { 445 || window->x == SDL_WINDOWPOS_CENTERED) {
407 x = (GetSystemMetrics(SM_CXSCREEN) - window->w) / 2; 446 x = (GetSystemMetrics(SM_CXSCREEN) - window->w) / 2;
408 } else { 447 } else {
423 { 462 {
424 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 463 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
425 RECT rect; 464 RECT rect;
426 DWORD style; 465 DWORD style;
427 HWND top; 466 HWND top;
467 BOOL menu;
428 int w, h; 468 int w, h;
429 469
430 /* Figure out what the window area will be */ 470 /* Figure out what the window area will be */
431 if (window->flags & SDL_WINDOW_FULLSCREEN) { 471 if (window->flags & SDL_WINDOW_FULLSCREEN) {
432 top = HWND_TOPMOST; 472 top = HWND_TOPMOST;
436 style = GetWindowLong(hwnd, GWL_STYLE); 476 style = GetWindowLong(hwnd, GWL_STYLE);
437 rect.left = 0; 477 rect.left = 0;
438 rect.top = 0; 478 rect.top = 0;
439 rect.right = window->w; 479 rect.right = window->w;
440 rect.bottom = window->h; 480 rect.bottom = window->h;
441 AdjustWindowRectEx(&rect, style, 481 #ifdef _WIN32_WCE
442 (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != 482 menu = FALSE;
443 NULL), 0); 483 #else
484 menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
485 #endif
486 AdjustWindowRectEx(&rect, style, menu, 0);
444 w = (rect.right - rect.left); 487 w = (rect.right - rect.left);
445 h = (rect.bottom - rect.top); 488 h = (rect.bottom - rect.top);
446 489
447 SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE)); 490 SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE));
448 } 491 }
451 WIN_ShowWindow(_THIS, SDL_Window * window) 494 WIN_ShowWindow(_THIS, SDL_Window * window)
452 { 495 {
453 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 496 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
454 497
455 ShowWindow(hwnd, SW_SHOW); 498 ShowWindow(hwnd, SW_SHOW);
499
500 #ifdef _WIN32_WCE
501 if (window->flags & SDL_WINDOW_FULLSCREEN) {
502 CE_SHFullScreen(hwnd,
503 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
504 SHFS_HIDESIPBUTTON);
505 }
506 #endif
456 } 507 }
457 508
458 void 509 void
459 WIN_HideWindow(_THIS, SDL_Window * window) 510 WIN_HideWindow(_THIS, SDL_Window * window)
460 { 511 {
461 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 512 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
462 513
463 ShowWindow(hwnd, SW_HIDE); 514 ShowWindow(hwnd, SW_HIDE);
515
516 #ifdef _WIN32_WCE
517 if (window->flags & SDL_WINDOW_FULLSCREEN) {
518 CE_SHFullScreen(hwnd,
519 SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
520 SHFS_SHOWSIPBUTTON);
521 }
522 #endif
464 } 523 }
465 524
466 void 525 void
467 WIN_RaiseWindow(_THIS, SDL_Window * window) 526 WIN_RaiseWindow(_THIS, SDL_Window * window)
468 { 527 {
473 top = HWND_TOPMOST; 532 top = HWND_TOPMOST;
474 } else { 533 } else {
475 top = HWND_NOTOPMOST; 534 top = HWND_NOTOPMOST;
476 } 535 }
477 SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE)); 536 SetWindowPos(hwnd, top, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE));
537
538 #ifdef _WIN32_WCE
539 if (window->flags & SDL_WINDOW_FULLSCREEN) {
540 CE_SHFullScreen(hwnd,
541 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
542 SHFS_HIDESIPBUTTON);
543 }
544 #endif
478 } 545 }
479 546
480 void 547 void
481 WIN_MaximizeWindow(_THIS, SDL_Window * window) 548 WIN_MaximizeWindow(_THIS, SDL_Window * window)
482 { 549 {
483 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 550 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
484 551
485 ShowWindow(hwnd, SW_MAXIMIZE); 552 ShowWindow(hwnd, SW_MAXIMIZE);
553
554 #ifdef _WIN32_WCE
555 if (window->flags & SDL_WINDOW_FULLSCREEN) {
556 CE_SHFullScreen(hwnd,
557 SHFS_HIDESTARTICON | SHFS_HIDETASKBAR |
558 SHFS_HIDESIPBUTTON);
559 }
560 #endif
486 } 561 }
487 562
488 void 563 void
489 WIN_MinimizeWindow(_THIS, SDL_Window * window) 564 WIN_MinimizeWindow(_THIS, SDL_Window * window)
490 { 565 {
491 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; 566 HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
492 567
493 ShowWindow(hwnd, SW_MINIMIZE); 568 ShowWindow(hwnd, SW_MINIMIZE);
569
570 #ifdef _WIN32_WCE
571 if (window->flags & SDL_WINDOW_FULLSCREEN) {
572 CE_SHFullScreen(hwnd,
573 SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR |
574 SHFS_SHOWSIPBUTTON);
575 }
576 #endif
494 } 577 }
495 578
496 void 579 void
497 WIN_RestoreWindow(_THIS, SDL_Window * window) 580 WIN_RestoreWindow(_THIS, SDL_Window * window)
498 { 581 {
577 SDL_SetError("Unable to create Helper Window Class: error %d.", 660 SDL_SetError("Unable to create Helper Window Class: error %d.",
578 GetLastError()); 661 GetLastError());
579 return -1; 662 return -1;
580 } 663 }
581 664
665 HWND hWndParent = NULL;
666 #ifndef _WIN32_WCE
667 /* WinCE doesn't have HWND_MESSAGE */
668 hWndParent = HWND_MESSAGE;
669 #endif
670
582 /* Create the window. */ 671 /* Create the window. */
583 SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName, 672 SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName,
584 SDL_HelperWindowName, 673 SDL_HelperWindowName,
585 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 674 WS_OVERLAPPED, CW_USEDEFAULT,
586 CW_USEDEFAULT, CW_USEDEFAULT, 675 CW_USEDEFAULT, CW_USEDEFAULT,
587 CW_USEDEFAULT, HWND_MESSAGE, NULL, 676 CW_USEDEFAULT, hWndParent, NULL,
588 hInstance, NULL); 677 hInstance, NULL);
589 if (SDL_HelperWindow == NULL) { 678 if (SDL_HelperWindow == NULL) {
590 UnregisterClass(SDL_HelperWindowClassName, hInstance); 679 UnregisterClass(SDL_HelperWindowClassName, hInstance);
591 SDL_SetError("Unable to create Helper Window: error %d.", 680 SDL_SetError("Unable to create Helper Window: error %d.",
592 GetLastError()); 681 GetLastError());