src/video/windib/SDL_dibevents.c
changeset 145 29a638dc26db
parent 140 3c35d8f160bd
child 252 e8157fcb3114
     1.1 --- a/src/video/windib/SDL_dibevents.c	Thu Aug 09 06:14:06 2001 +0000
     1.2 +++ b/src/video/windib/SDL_dibevents.c	Thu Aug 09 12:21:32 2001 +0000
     1.3 @@ -54,6 +54,10 @@
     1.4  #define REPEATED_KEYMASK	(1<<30)
     1.5  #define EXTENDED_KEYMASK	(1<<24)
     1.6  
     1.7 +/* DJM: If the user setup the window for us, we want to save his window proc,
     1.8 +   and give him a chance to handle some messages. */
     1.9 +static WNDPROC userWindowProc = NULL;
    1.10 +
    1.11  /* The main Win32 event handler */
    1.12  LONG
    1.13   DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    1.14 @@ -150,6 +154,13 @@
    1.15  				wmmsg.wParam = wParam;
    1.16  				wmmsg.lParam = lParam;
    1.17  				posted = SDL_PrivateSysWMEvent(&wmmsg);
    1.18 +
    1.19 +			/* DJM: If the user isn't watching for private
    1.20 +				messages in her SDL event loop, then pass it
    1.21 +				along to any win32 specific window proc.
    1.22 +			 */
    1.23 +			} else if (userWindowProc) {
    1.24 +				return userWindowProc(hwnd, msg, wParam, lParam);
    1.25  			}
    1.26  		}
    1.27  		break;
    1.28 @@ -339,6 +350,14 @@
    1.29  	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
    1.30  	if ( SDL_windowid ) {
    1.31  		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
    1.32 +
    1.33 +      /* DJM: we want all event's for the user specified
    1.34 +         window to be handled by SDL.
    1.35 +       */
    1.36 +      if (SDL_Window) {
    1.37 +         userWindowProc = (WNDPROC)GetWindowLong(SDL_Window, GWL_WNDPROC);
    1.38 +         SetWindowLong(SDL_Window, GWL_WNDPROC, (LONG)WinMessage);
    1.39 +      }
    1.40  	} else {
    1.41  		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
    1.42                          (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),