Run on secondary monitor (1 Viewer)

webrant

New Member
December 31, 2006
2
0
I made some small changes to be able to specify which monitor to use.
Save code content into secondarymonitorpatch.patch and apply it.
You also have to specify monitor to use under general section in mediaportal.xml
<entry name="monitor">1</entry>
Search for loglevel to get the correct position.
Works for me atleast ;-)

Code:
Index: d3dapp.cs
===================================================================
--- d3dapp.cs	(revision 12447)
+++ d3dapp.cs	(working copy)
@@ -79,6 +79,8 @@
 
     #endregion
 
+    protected int monitor = -1;
+
     protected bool _minimizeOnStartup = false;  // Minimize to tray on startup and on gui exit
     protected bool _minimizeOnGuiExit = false;
     protected bool _shuttingDown = false;
@@ -314,7 +316,9 @@
       frameStats = null;
 
       this.Text = "D3D9 Sample";
+
       this.ClientSize = new Size(720, 576);
+      
       this.KeyPreview = true;
 
       minDepthBits = 16;
@@ -428,9 +432,18 @@
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Menu = null;
-            this.Location = new Point(0, 0);
-            this.Bounds = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
-            this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+
+            if (this.monitor >= 0)
+            {
+                this.Bounds = Screen.AllScreens[this.monitor].Bounds;
+            }
+            else
+            {
+                this.Location = new Point(0, 0);
+                this.Bounds = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+                this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+
+            }
             //GUIGraphicsContext.DX9Device.PresentationParameters.BackBufferWidth=Screen.PrimaryScreen.Bounds.Width;
             //GUIGraphicsContext.DX9Device.PresentationParameters.BackBufferHeight=Screen.PrimaryScreen.Bounds.Height;
             Log.Info("D3D: Client size: {0}x{1} - Screen: {2}x{3}",
@@ -482,6 +495,9 @@
       // Get display mode of primary adapter (which is assumed to be where the window 
       // will appear)
       DisplayMode primaryDesktopDisplayMode = Manager.Adapters[0].CurrentDisplayMode;
+      
+      if (this.monitor >= 0)
+        primaryDesktopDisplayMode = Manager.Adapters[this.monitor].CurrentDisplayMode;
 
       GraphicsAdapterInfo bestAdapterInfo = null;
       GraphicsDeviceInfo bestDeviceInfo = null;
@@ -489,6 +505,12 @@
 
       foreach (GraphicsAdapterInfo adapterInfo in enumerationSettings.AdapterInfoList)
       {
+          if (this.monitor >= 0)
+          {
+              if (!Screen.AllScreens[this.monitor].DeviceName.StartsWith(adapterInfo.AdapterDetails.DeviceName))
+                  continue;
+          }
+
         foreach (GraphicsDeviceInfo deviceInfo in adapterInfo.DeviceInfoList)
         {
           if (doesRequireHardware && deviceInfo.DevType != DeviceType.Hardware)
@@ -587,6 +609,12 @@
 
       foreach (GraphicsAdapterInfo adapterInfo in enumerationSettings.AdapterInfoList)
       {
+          if (this.monitor >= 0)
+          {
+              if (!Screen.AllScreens[this.monitor].DeviceName.StartsWith(adapterInfo.AdapterDetails.DeviceName))
+                  continue;
+          }
+
         adapterDesktopDisplayMode = Manager.Adapters[adapterInfo.AdapterOrdinal].CurrentDisplayMode;
         foreach (GraphicsDeviceInfo deviceInfo in adapterInfo.DeviceInfoList)
         {
@@ -1737,9 +1765,17 @@
         this.MaximizeBox = false;
         this.MinimizeBox = false;
         this.Menu = null;
-        this.Location = new Point(0, 0);
-        this.Bounds = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
-        this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+
+        if (this.monitor >= 0)
+        {
+            this.Bounds = Screen.AllScreens[this.monitor].Bounds;
+        }
+          else
+          {
+              this.Location = new Point(0, 0);
+              this.Bounds = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+              this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+          }
         this.Update();
 
         Log.Info("D3D: Switching windowed mode -> fullscreen done - Maximized: {0}", isMaximized);
Index: MediaPortal.cs
===================================================================
--- MediaPortal.cs	(revision 12447)
+++ MediaPortal.cs	(working copy)
@@ -464,6 +464,7 @@
     {
       useScreenSaver = xmlreader.GetValueAsBool("general", "screensaver", true);
       timeScreenSaver = xmlreader.GetValueAsInt("general", "screensavertime", 60);
+      this.monitor = xmlreader.GetValueAsInt("general", "monitor", -1);
       clientSizeX = xmlreader.GetValueAsInt("general", "sizex", clientSizeX);
       clientSizeY = xmlreader.GetValueAsInt("general", "sizey", clientSizeY);
       //GUIGraphicsContext.UseSeparateRenderThread = xmlreader.GetValueAsBool("general", "userenderthread", true);
@@ -525,6 +526,11 @@
     DoStartupJobs();
     //    startThread.Priority = ThreadPriority.BelowNormal;
     //    startThread.Start();
+
+    if (this.monitor >= 0)
+    {
+        this.Bounds = Screen.AllScreens[this.monitor].Bounds;
+    }
   }
 
   private void MediaPortalApp_Deactivate(object sender, EventArgs e)
 

Users who are viewing this thread

Top Bottom