Skip to content

Commit 4f4ce54

Browse files
committed
fix amd/nvidia refresh rate and resolution issues
1 parent b9db102 commit 4f4ce54

24 files changed

+1174
-723
lines changed

ColorControl/ColorControl.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<PublisherName>Maassoft</PublisherName>
1919
<Company>Maassoft</Company>
2020
<ApplicationRevision>0</ApplicationRevision>
21-
<ApplicationVersion>9.8.2.1</ApplicationVersion>
22-
<Version>9.8.2.1</Version>
21+
<ApplicationVersion>9.9.0.0</ApplicationVersion>
22+
<Version>9.9.0.0</Version>
2323
<UseApplicationTrust>false</UseApplicationTrust>
2424
<PublishWizardCompleted>true</PublishWizardCompleted>
2525
<BootstrapperEnabled>false</BootstrapperEnabled>

ColorControl/MainForm.cs

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public partial class MainForm : Form
3838
private readonly KeyboardShortcutDispatcher _keyboardShortcutDispatcher;
3939
private readonly UpdateManager _updateManager;
4040
private Config _config;
41-
private bool _setVisibleCalled = false;
4241

4342
private LgPanel _lgPanel;
4443
private SamsungPanel _samsungPanel;
@@ -48,8 +47,8 @@ public partial class MainForm : Form
4847

4948
private GamePanel _gamePanel;
5049

51-
public MainForm(GlobalContext globalContext, ServiceManager serviceManager,
52-
IServiceProvider serviceProvider, ElevationService elevationService, NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
50+
public MainForm(GlobalContext globalContext, ServiceManager serviceManager, IServiceProvider serviceProvider, ElevationService elevationService,
51+
NotifyIconManager notifyIconManager, KeyboardShortcutDispatcher keyboardShortcutDispatcher, UpdateManager updateManager)
5352
{
5453
InitializeComponent();
5554

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

119+
//Logger.Debug($"Panel {panel.GetType().Name}, size: {panel.Size.Width}x{panel.Size.Height}");
120+
120121
return panel;
121122
}
122123
catch (Exception ex)
@@ -136,7 +137,12 @@ public void OpenForm()
136137

137138
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
138139
{
139-
if (!(SystemShutdown || EndSession || Program.UserExit) && _config.MinimizeOnClose)
140+
if (Program.UserExit)
141+
{
142+
return;
143+
}
144+
145+
if (!(SystemShutdown || EndSession) && _config.MinimizeOnClose)
140146
{
141147
e.Cancel = true;
142148
WindowState = FormWindowState.Minimized;
@@ -149,9 +155,9 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
149155
if (SystemShutdown)
150156
{
151157
Logger.Debug($"MainForm_FormClosing: SystemShutdown");
152-
153-
//_powerEventDispatcher.SendEvent(PowerEventDispatcher.Event_Shutdown);
154158
}
159+
160+
Program.Exit();
155161
}
156162

157163
private void GlobalSave()
@@ -232,33 +238,13 @@ private void SaveConfig()
232238
Utils.WriteObject(Program.ConfigFilename, _config);
233239
}
234240

235-
private async void MainForm_Shown(object sender, EventArgs e)
241+
private void MainForm_Shown(object sender, EventArgs e)
236242
{
237243
InitSelectedTab();
238244

239245
_elevationService.CheckElevationMethod();
240246
}
241247

242-
protected override void SetVisibleCore(bool value)
243-
{
244-
//if (!_setVisibleCalled && _config.StartMinimized && !Debugger.IsAttached)
245-
//{
246-
// _setVisibleCalled = true;
247-
// if (_config.MinimizeToTray)
248-
// {
249-
// value = false;
250-
// }
251-
// else
252-
// {
253-
// WindowState = FormWindowState.Minimized;
254-
// }
255-
//}
256-
if (!IsDisposed)
257-
{
258-
base.SetVisibleCore(value);
259-
}
260-
}
261-
262248
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
263249
{
264250
InitSelectedTab();
@@ -282,7 +268,7 @@ private void InitSelectedTab()
282268

283269
private void InitOptionsTab()
284270
{
285-
if (tabInfo.Controls.Count > 0)
271+
if (tabOptions.Controls.Count > 0)
286272
{
287273
return;
288274
}
@@ -328,10 +314,6 @@ private async Task AfterInitialized()
328314
{
329315
await _amdPanel.AfterInitialized();
330316
}
331-
//if (_trayIcon.Visible)
332-
//{
333-
// await CheckForUpdates();
334-
//}
335317
}
336318

337319
private void MainForm_Deactivate(object sender, EventArgs e)

ColorControl/MainWorker.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ internal class MainWorker
3030
private readonly WinApiService _winApiService;
3131
private readonly WinApiAdminService _winApiAdminService;
3232
private readonly UpdateManager _updateManager;
33-
private bool _isInitialized;
3433
private bool _queryEndSession;
3534
private nint _screenStateNotify;
3635

@@ -62,28 +61,22 @@ public MainWorker(
6261

6362
public async Task DoWork()
6463
{
65-
while (!_backgroundWorker.CancellationPending)
64+
if (_backgroundWorker.CancellationPending)
6665
{
66+
return;
67+
}
6768

68-
if (!_isInitialized)
69-
{
70-
await Init();
71-
}
72-
73-
//await Task.Delay(1000);
74-
75-
System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);
69+
await Init();
7670

77-
_serviceManager.Save();
78-
_notifyIconManager.HideIcon();
71+
System.Windows.Forms.Application.Run(_windowMessageDispatcher.MessageForm);
7972

80-
if (_screenStateNotify != 0)
81-
{
82-
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
83-
_screenStateNotify = 0;
84-
}
73+
_serviceManager.Save();
74+
_notifyIconManager.HideIcon();
8575

86-
break;
76+
if (_screenStateNotify != 0)
77+
{
78+
WinApi.UnregisterPowerSettingNotification(_screenStateNotify);
79+
_screenStateNotify = 0;
8780
}
8881
}
8982

@@ -116,8 +109,6 @@ private async Task Init()
116109

117110
_keyboardShortcutDispatcher.RegisterShortcut(SHORTCUTID_SCREENSAVER, _config.ScreenSaverShortcut);
118111
_keyboardShortcutDispatcher.RegisterEventHandler(KeyboardShortcutDispatcher.Event_HotKey, HandleHotKeyEvent);
119-
120-
_isInitialized = true;
121112
}
122113

123114
private bool _startupSent = false;

0 commit comments

Comments
 (0)