diff --git a/Borderless.cs b/Borderless.cs index d720938..257eec6 100644 --- a/Borderless.cs +++ b/Borderless.cs @@ -185,14 +185,20 @@ private void RemoveBorder(String procName) //actually make it frameless | WindowStyleFlags.ExtendedComposited))); - var bounds = Screen.PrimaryScreen.Bounds; + //Get the screen bounds from the screen the window is currently active on. + //If on multiple screens it will grab bounds from the screen it is most on. + //If not on any screen it grabs bounds from the screen closest + var bounds = Screen.FromHandle(pFoundWindow).Bounds; + if (!_borderlessWindows.Contains(pFoundWindow.ToInt32().ToString())) { - Native.SetWindowPos(pFoundWindow, 0, 0, 0, bounds.Width, bounds.Height, - SWP_NOZORDER | SWP_SHOWWINDOW); + //Using bounds.X and bounds.Y instead of 0, 0 so it will orient the window + //on the screen it is currently occupying instead of using the primary screen + Native.SetWindowPos(pFoundWindow, 0, bounds.X, bounds.Y, bounds.Width, bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW); _borderlessWindows.Add(pFoundWindow.ToInt32().ToString()); } //today I learn the definition of a hot fix - + + //no more outside window // CheckNativeResult(() => Native.MoveWindow(pFoundWindow, 0, 0, bounds.Width, bounds.Height, true)); //resets window to main monito @@ -326,4 +332,4 @@ private void TrayIconExit(object sender, EventArgs e) Environment.Exit(0); } } -} \ No newline at end of file +}