Index: trunk/src/sdl/sdl_input.cc
===================================================================
--- trunk/src/sdl/sdl_input.cc	(revision 492)
+++ trunk/src/sdl/sdl_input.cc	(revision 505)
@@ -20,8 +20,9 @@
 static bool sdl_key_event_to_io_event( const SDL_KeyboardEvent& ke, io_event& kevent )
 {
-	kevent.type        = EV_KEY;
-	kevent.key.pressed = ( ke.state != SDL_RELEASED );
-	kevent.key.ascii   = 0;
-	kevent.key.code    = KEY_NONE;
+	kevent.type          = EV_KEY;
+	kevent.key.window_id = ke.windowID;
+	kevent.key.pressed   = ( ke.state != SDL_RELEASED );
+	kevent.key.ascii     = 0;
+	kevent.key.code      = KEY_NONE;
 
 	uint32 ucode = static_cast<uint32>( ke.keysym.sym );
@@ -107,9 +108,10 @@
 static bool sdl_mouse_button_to_io_event( const SDL_MouseButtonEvent& mb, io_event& mevent )
 {
-	mevent.type            = EV_MOUSE_BUTTON;
-	mevent.mbutton.button  = MOUSE_NONE;
-	mevent.mbutton.pressed = (mb.state != SDL_RELEASED);
-	mevent.mbutton.x       = static_cast< uint16 >( mb.x );
-	mevent.mbutton.y       = static_cast< uint16 >( mb.y );
+	mevent.type              = EV_MOUSE_BUTTON;
+	mevent.mbutton.window_id = mb.windowID;
+	mevent.mbutton.button    = MOUSE_NONE;
+	mevent.mbutton.pressed   = (mb.state != SDL_RELEASED);
+	mevent.mbutton.x         = static_cast< uint16 >( mb.x );
+	mevent.mbutton.y         = static_cast< uint16 >( mb.y );
 
 	switch ( mb.button )
@@ -126,7 +128,8 @@
 static bool sdl_mouse_wheel_to_io_event( const SDL_MouseWheelEvent& mm, io_event& mevent )
 {
-	mevent.type          = EV_MOUSE_WHEEL;
-	mevent.mwheel.x      = static_cast< sint32 >( mm.x );
-	mevent.mwheel.y      = static_cast< sint32 >( mm.y );
+	mevent.type             = EV_MOUSE_WHEEL;
+	mevent.mwheel.window_id = mm.windowID;
+	mevent.mwheel.x         = static_cast< sint32 >( mm.x );
+	mevent.mwheel.y         = static_cast< sint32 >( mm.y );
 	return true;
 }
@@ -134,10 +137,11 @@
 static bool sdl_mouse_motion_to_io_event( const SDL_MouseMotionEvent& mm, io_event& mevent )
 {
-	mevent.type          = EV_MOUSE_MOVE;
-	mevent.mmove.pressed = (mm.state != SDL_RELEASED);
-	mevent.mmove.x       = static_cast< uint16 >( mm.x );
-	mevent.mmove.y       = static_cast< uint16 >( mm.y );
-	mevent.mmove.rx      = static_cast< sint16 >( mm.xrel );
-	mevent.mmove.ry      = static_cast< sint16 >( mm.yrel );
+	mevent.type            = EV_MOUSE_MOVE;
+	mevent.mmove.window_id = mm.windowID;
+	mevent.mmove.pressed   = (mm.state != SDL_RELEASED);
+	mevent.mmove.x         = static_cast< uint16 >( mm.x );
+	mevent.mmove.y         = static_cast< uint16 >( mm.y );
+	mevent.mmove.rx        = static_cast< sint16 >( mm.xrel );
+	mevent.mmove.ry        = static_cast< sint16 >( mm.yrel );
 	return true;
 }
@@ -222,4 +226,6 @@
 	case SDL_VIDEOEXPOSE     : return false;
 */
+	case SDL_WINDOWEVENT_ENTER: ioevent.type = EV_SYSTEM; ioevent.system.param1 = 1; ioevent.system.param1 = e.window.windowID; return true;
+	case SDL_WINDOWEVENT_LEAVE: ioevent.type = EV_SYSTEM; ioevent.system.param1 = 0; ioevent.system.param1 = e.window.windowID; return true;
 	case SDL_SYSWMEVENT      : ioevent.type = EV_SYSTEM; return true;
 	case SDL_QUIT            : ioevent.type = EV_QUIT;   return true;
Index: trunk/src/sdl/sdl_window.cc
===================================================================
--- trunk/src/sdl/sdl_window.cc	(revision 492)
+++ trunk/src/sdl/sdl_window.cc	(revision 505)
@@ -133,2 +133,13 @@
 	SDL_GL_SetSwapInterval( enabled ? 1 : 0 );
 }
+
+void nv::sdl::window::make_current()
+{
+	SDL_GLContext native = static_cast<SDL_GLContext>( m_context->get_native_handle() );
+	SDL_GL_MakeCurrent( static_cast<SDL_Window*>( m_handle ), native );
+}
+
+nv::uint32 nv::sdl::window::window_id()
+{
+	return SDL_GetWindowID( static_cast<SDL_Window*>( m_handle ) );
+}
Index: trunk/src/sdl/sdl_window_manager.cc
===================================================================
--- trunk/src/sdl/sdl_window_manager.cc	(revision 492)
+++ trunk/src/sdl/sdl_window_manager.cc	(revision 505)
@@ -17,4 +17,5 @@
 sdl::window_manager::window_manager()
 {
+	primal_window = nullptr;
 	nv::load_sdl_library();
 
@@ -29,5 +30,7 @@
 {
 	if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
-	return new sdl::window( dev, width, height, fullscreen );
+	sdl::window* result = new sdl::window( dev, width, height, fullscreen );
+	primal_window = result->get_handle();
+	return result;
 }
 
@@ -35,5 +38,12 @@
 {
 	if ( ! SDL_WasInit( SDL_INIT_VIDEO ) ) SDL_InitSubSystem( SDL_INIT_VIDEO );
-	return SDL_CreateWindowFrom( sys_w_handle );
+	if ( primal_window )
+	{
+		char buffer[128];
+		sprintf( buffer, "%p", primal_window );
+		NV_ASSERT( SDL_SetHint( "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT", buffer ) == SDL_TRUE );
+	}
+	primal_window = SDL_CreateWindowFrom( sys_w_handle );
+	return primal_window;
 }
 
