Index: modules/video_output/directx/directx.c
===================================================================
RCS file: /var/cvs/videolan/vlc/modules/video_output/directx/directx.c,v
retrieving revision 1.31
diff -u -r1.31 directx.c
--- modules/video_output/directx/directx.c	2 Jan 2004 22:17:57 -0000	1.31
+++ modules/video_output/directx/directx.c	3 Jan 2004 23:21:11 -0000
@@ -114,12 +114,16 @@
 #define TRIPLEBUF_LONGTEXT N_( \
     "Try to use triple bufferring when using YUV overlays. That results in " \
     "much better video quality (no flickering)." )
+#define DISPLAYNAME_TEXT N_("Name of desired display device")
+#define DISPLAYNAME_LONGTEXT N_("In a multimonitor configuration, you can specify the windows device name " \
+    "of the display that you want the video window to open on.  For example, \"\\.\DISPLAY1\" or \"\\.\DISPLAY2\".")
 
 vlc_module_begin();
     add_category_hint( N_("Video"), NULL, VLC_FALSE );
     add_bool( "directx-hw-yuv", 1, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT, VLC_TRUE );
     add_bool( "directx-use-sysmem", 0, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT, VLC_TRUE );
     add_bool( "directx-3buffering", 1, NULL, TRIPLEBUF_TEXT, TRIPLEBUF_LONGTEXT, VLC_TRUE );
+    add_string( "directx-displayname", "", NULL, DISPLAYNAME_TEXT, DISPLAYNAME_LONGTEXT, VLC_TRUE );
     set_description( _("DirectX video output") );
     set_capability( "video output", 100 );
     add_shortcut( "directx" );
@@ -185,6 +189,7 @@
     var_Create( p_vout, "directx-use-sysmem", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
     var_Create( p_vout, "directx-hw-yuv", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_vout, "directx-3buffering", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
+    var_Create( p_vout, "directx-displayname", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
 
     p_vout->p_sys->b_cursor_hidden = 0;
     p_vout->p_sys->i_lastmoved = mdate();
@@ -640,15 +645,46 @@
                                  LPTSTR psz_drivername, VOID* p_context,
                                  HMONITOR hmon )
 {
+	BOOL displayMatches = FALSE;
+
     vout_thread_t *p_vout = (vout_thread_t *)p_context;
     msg_Dbg( p_vout, "DirectXEnumCallback: %s, %s", psz_desc, psz_drivername );
 
-    if( hmon && hmon == p_vout->p_sys->hmonitor )
-    {
-        msg_Dbg( p_vout, "selecting %s, %s", psz_desc, psz_drivername );
-        p_vout->p_sys->p_display_driver = malloc( sizeof(GUID) );
-        if( p_vout->p_sys->p_display_driver )
-            memcpy( p_vout->p_sys->p_display_driver, p_guid, sizeof(GUID) );
+    vlc_value_t preferredDisplayName;
+    var_Get(p_vout, "directx-displayname", &preferredDisplayName);
+    msg_Dbg( p_vout, "directx-displayname: %s", preferredDisplayName.psz_string );
+    
+    if( hmon ) {
+		if( strcmp(preferredDisplayName.psz_string, "") == 0 && hmon == p_vout->p_sys->hmonitor )
+		{
+			displayMatches = TRUE;
+		}
+		else if( strcmp(psz_drivername, preferredDisplayName.psz_string) == 0 )
+		{
+			MONITORINFOEX mix;
+			memset(&mix, 0, sizeof(MONITORINFOEX));
+			mix.cbSize = sizeof(MONITORINFOEX);
+
+			if (p_vout->p_sys->GetMonitorInfo(hmon, &mix)) {
+				RECT rc;
+				GetWindowRect(p_vout->p_sys->hwnd, &rc);
+				rc.left = mix.rcWork.left;
+				rc.top = mix.rcWork.top;
+				msg_Dbg( p_vout, "DirectXEnumCallback: Setting window position to %d,%d", rc.left, rc.top);
+				SetWindowPos(p_vout->p_sys->hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+				p_vout->p_sys->hmonitor = hmon;
+			}
+
+			displayMatches = TRUE;
+		}
+
+		if( displayMatches )
+		{
+        	msg_Dbg( p_vout, "selecting %s, %s", psz_desc, psz_drivername );
+        	p_vout->p_sys->p_display_driver = malloc( sizeof(GUID) );
+        	if( p_vout->p_sys->p_display_driver )
+            	memcpy( p_vout->p_sys->p_display_driver, p_guid, sizeof(GUID) );
+		}
     }
 
     return TRUE; /* Keep enumerating */
