Skip to content

Commit

Permalink
#11 Double Draw: Trying to provide a clean way to force a resolution …
Browse files Browse the repository at this point in the history
…change.
  • Loading branch information
FrigoCoder committed Jan 6, 2018
1 parent ba9df5a commit 699907f
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions FrigoTab/SessionForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ private void BeginSession () {
}

WindowHandle.GetForegroundWindow().PostMessage(WindowMessages.ActivateApp, 0, Thread.CurrentThread.ManagedThreadId);
ChangeDisplaySettings(IntPtr.Zero, 0);
foreach( Screen screen in Screen.AllScreens ) {
ChangeDisplaySettingsEx(screen.DeviceName, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero);
}
Bounds = GetScreenBounds();

backgrounds = new BackgroundWindows(this, finder);
Expand Down Expand Up @@ -133,29 +135,14 @@ private void ActivateEndSession () {
if( applications.Selected == null ) {
return;
}
active = false;
applications.Selected.Application.SetForeground();
active = true;
EndSession();
}

private void DisplayChange () {
bool preserve = active;
if( preserve ) {
EndSession();
}
Bounds = GetScreenBounds();
if( preserve ) {
BeginSession();
}
}

private static Rectangle GetScreenBounds () {
return Screen.AllScreens.Select(screen => screen.Bounds).Aggregate(Rectangle.Union);
}
private static Rectangle GetScreenBounds () => Screen.AllScreens.Select(screen => screen.Bounds).Aggregate(Rectangle.Union);

[DllImport("user32.dll")]
private static extern int ChangeDisplaySettings (IntPtr lpDevMode, int dwFlags);
private static extern int ChangeDisplaySettingsEx (string lpszDeviceName, IntPtr lpDevMode, IntPtr hwnd, int dwflags, IntPtr lParam);

}

Expand Down

0 comments on commit 699907f

Please sign in to comment.