Mercurial > sdl-ios-xcode
comparison src/video/wincommon/SDL_sysevents.c @ 1145:d31afac94eff
Patch from Martin Lange (mala-sdl at hotmail.com) to unregister SDL's win32
windowclass when shutting down the video subsystem...this allows you to
safely unload/reload the SDL shared library on Windows between
initializations.
Discussion is here:
http://www.devolution.com/pipermail/sdl/2005-February/067424.html
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 27 Sep 2005 09:00:42 +0000 |
parents | 31fa08b36380 |
children | 7d8e1925f35b |
comparison
equal
deleted
inserted
replaced
1144:509295d5a023 | 1145:d31afac94eff |
---|---|
560 void *handle; | 560 void *handle; |
561 | 561 |
562 if ( SDL_handle ) { | 562 if ( SDL_handle ) { |
563 handle = SDL_handle; | 563 handle = SDL_handle; |
564 } else { | 564 } else { |
565 /* Warning: | |
566 If SDL is built as a DLL, this will return a handle to | |
567 the DLL, not the application, and DirectInput may fail | |
568 to initialize. | |
569 */ | |
570 handle = GetModuleHandle(NULL); | 565 handle = GetModuleHandle(NULL); |
571 } | 566 } |
572 return(handle); | 567 return(handle); |
573 } | 568 } |
574 | 569 |
575 /* This allows the SDL_WINDOWID hack */ | 570 /* This allows the SDL_WINDOWID hack */ |
576 const char *SDL_windowid = NULL; | 571 const char *SDL_windowid = NULL; |
577 | 572 |
573 static int app_registered = 0; | |
574 | |
578 /* Register the class for this application -- exported for winmain.c */ | 575 /* Register the class for this application -- exported for winmain.c */ |
579 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) | 576 int SDL_RegisterApp(char *name, Uint32 style, void *hInst) |
580 { | 577 { |
581 static int initialized = 0; | |
582 WNDCLASS class; | 578 WNDCLASS class; |
583 #ifdef WM_MOUSELEAVE | 579 #ifdef WM_MOUSELEAVE |
584 HMODULE handle; | 580 HMODULE handle; |
585 #endif | 581 #endif |
586 | 582 |
587 /* Only do this once... */ | 583 /* Only do this once... */ |
588 if ( initialized ) { | 584 if ( app_registered ) { |
589 return(0); | 585 return(0); |
590 } | 586 } |
591 | 587 |
592 /* This function needs to be passed the correct process handle | 588 /* This function needs to be passed the correct process handle |
593 by the application. | 589 by the application. |
644 #endif /* WM_MOUSELEAVE */ | 640 #endif /* WM_MOUSELEAVE */ |
645 | 641 |
646 /* Check for SDL_WINDOWID hack */ | 642 /* Check for SDL_WINDOWID hack */ |
647 SDL_windowid = getenv("SDL_WINDOWID"); | 643 SDL_windowid = getenv("SDL_WINDOWID"); |
648 | 644 |
649 initialized = 1; | 645 app_registered = 1; |
650 return(0); | 646 return(0); |
651 } | 647 } |
652 | 648 |
649 /* | |
650 * Unregisters the windowclass registered in SDL_RegisterApp above. | |
651 * Called from DIB_VideoQuit and DX5_VideoQuit when | |
652 * SDL_QuitSubSystem(INIT_VIDEO) is called. | |
653 */ | |
654 void SDL_UnRegisterApp() | |
655 { | |
656 WNDCLASS class; | |
657 | |
658 /* SDL_RegisterApp might not have been called before */ | |
659 if (app_registered) { | |
660 /* Check for any registered windowclasses. */ | |
661 if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) { | |
662 UnregisterClass(SDL_Appname, SDL_Instance); | |
663 } | |
664 } | |
665 app_registered = 0; | |
666 } | |
667 |