Skip to content

Commit

Permalink
fix amd/nvidia refresh rate and resolution issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Maassoft committed Apr 14, 2024
1 parent b9db102 commit 4f4ce54
Show file tree
Hide file tree
Showing 24 changed files with 1,174 additions and 723 deletions.
4 changes: 2 additions & 2 deletions ColorControl/ColorControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PublisherName>Maassoft</PublisherName>
<Company>Maassoft</Company>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>9.8.2.1</ApplicationVersion>
<Version>9.8.2.1</Version>
<ApplicationVersion>9.9.0.0</ApplicationVersion>
<Version>9.9.0.0</Version>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>false</BootstrapperEnabled>
Expand Down
46 changes: 14 additions & 32 deletions ColorControl/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public partial class MainForm : Form
private readonly KeyboardShortcutDispatcher _keyboardShortcutDispatcher;
private readonly UpdateManager _updateManager;
private Config _config;
private bool _setVisibleCalled = false;

private LgPanel _lgPanel;
private SamsungPanel _samsungPanel;
Expand All @@ -48,8 +47,8 @@ public partial class MainForm : Form

private GamePanel _gamePanel;

public MainForm(GlobalContext globalContext, ServiceManager serviceManager,
IServiceProvider serviceProvider, ElevationService elevationService, NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
public MainForm(GlobalContext globalContext, ServiceManager serviceManager, IServiceProvider serviceProvider, ElevationService elevationService,
NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
{
InitializeComponent();

Expand Down Expand Up @@ -117,6 +116,8 @@ private T InitPanel<T>(string displayName) where T : UserControl, IModulePanel
panel.Size = tabPage.ClientSize;
panel.BackColor = SystemColors.Window;

//Logger.Debug($"Panel {panel.GetType().Name}, size: {panel.Size.Width}x{panel.Size.Height}");

return panel;
}
catch (Exception ex)
Expand All @@ -136,7 +137,12 @@ public void OpenForm()

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!(SystemShutdown || EndSession || Program.UserExit) && _config.MinimizeOnClose)
if (Program.UserExit)
{
return;
}

if (!(SystemShutdown || EndSession) && _config.MinimizeOnClose)
{
e.Cancel = true;
WindowState = FormWindowState.Minimized;
Expand All @@ -149,9 +155,9 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
if (SystemShutdown)
{
Logger.Debug($"MainForm_FormClosing: SystemShutdown");

//_powerEventDispatcher.SendEvent(PowerEventDispatcher.Event_Shutdown);
}

Program.Exit();
}

private void GlobalSave()
Expand Down Expand Up @@ -232,33 +238,13 @@ private void SaveConfig()
Utils.WriteObject(Program.ConfigFilename, _config);
}

private async void MainForm_Shown(object sender, EventArgs e)
private void MainForm_Shown(object sender, EventArgs e)
{
InitSelectedTab();

_elevationService.CheckElevationMethod();
}

protected override void SetVisibleCore(bool value)
{
//if (!_setVisibleCalled && _config.StartMinimized && !Debugger.IsAttached)
//{
// _setVisibleCalled = true;
// if (_config.MinimizeToTray)
// {
// value = false;
// }
// else
// {
// WindowState = FormWindowState.Minimized;
// }
//}
if (!IsDisposed)
{
base.SetVisibleCore(value);
}
}

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
InitSelectedTab();
Expand All @@ -282,7 +268,7 @@ private void InitSelectedTab()

private void InitOptionsTab()
{
if (tabInfo.Controls.Count > 0)
if (tabOptions.Controls.Count > 0)
{
return;
}
Expand Down Expand Up @@ -328,10 +314,6 @@ private async Task AfterInitialized()
{
await _amdPanel.AfterInitialized();
}
//if (_trayIcon.Visible)
//{
// await CheckForUpdates();
//}
}

private void MainForm_Deactivate(object sender, EventArgs e)
Expand Down
31 changes: 11 additions & 20 deletions ColorControl/MainWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ internal class MainWorker
private readonly WinApiService _winApiService;
private readonly WinApiAdminService _winApiAdminService;
private readonly UpdateManager _updateManager;
private bool _isInitialized;
private bool _queryEndSession;
private nint _screenStateNotify;

Expand Down Expand Up @@ -62,28 +61,22 @@ public MainWorker(

public async Task DoWork()
{
while (!_backgroundWorker.CancellationPending)
if (_backgroundWorker.CancellationPending)
{
return;
}

if (!_isInitialized)
{
await Init();
}

//await Task.Delay(1000);

System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);
await Init();

_serviceManager.Save();
_notifyIconManager.HideIcon();
System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);

if (_screenStateNotify != 0)
{
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
_screenStateNotify = 0;
}
_serviceManager.Save();
_notifyIconManager.HideIcon();

break;
if (_screenStateNotify != 0)
{
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
_screenStateNotify = 0;
}
}

Expand Down Expand Up @@ -116,8 +109,6 @@ private async Task Init()

_keyboardShortcutDispatcher.RegisterShortcut(SHORTCUTID_SCREENSAVER, _config.ScreenSaverShortcut);
_keyboardShortcutDispatcher.RegisterEventHandler(KeyboardShortcutDispatcher.Event_HotKey, HandleHotKeyEvent);

_isInitialized = true;
}

private bool _startupSent = false;
Expand Down
Loading

0 comments on commit 4f4ce54

Please sign in to comment.