Skip to content

Commit 3355e2b

Browse files
committed
1.5.7
-Fix: If a monitor is in HDR mode, but Auto HDR is not activated for it, HDRProfile cannot activate HDR, because recognize it as it is already activated
1 parent 1b2d874 commit 3355e2b

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

Source/HDRProfile/HDRProfileHandler.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private void MonitorManager_HDRIsActiveChanged(object sender, EventArgs e)
160160
private void MonitorManager_AutoHDRChanged(object sender, EventArgs e)
161161
{
162162
SaveSettings();
163-
UpdateHDRBasedOnCurrentApplication();
163+
SetHDRBasedOnCurrentApplication();
164164
}
165165

166166
private void TrayMenuHelper_OpenViewRequested(object sender, EventArgs e)
@@ -242,7 +242,7 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
242242
Logs.AddException(ex);
243243
}
244244
if (e.PropertyName.Equals(nameof(Settings.HDRMode)))
245-
UpdateHDRBasedOnCurrentApplication();
245+
SetHDRBasedOnCurrentApplication();
246246
Logs.LoggingEnabled = Settings.Logging;
247247
SaveSettings();
248248
}
@@ -264,13 +264,13 @@ private void StartApplication(ApplicationItem application)
264264
try
265265
{
266266
MonitorManager.ActivateHDR();
267-
System.Threading.Thread.Sleep(3000);
267+
System.Threading.Thread.Sleep(2500);
268268
Process process = new Process();
269269
process.StartInfo = new ProcessStartInfo(application.ApplicationFilePath);
270270
process.Start();
271271
Stopwatch stopwatch = new Stopwatch();
272272
stopwatch.Start();
273-
System.Threading.Thread.Sleep(3000);
273+
System.Threading.Thread.Sleep(500);
274274
}
275275
catch (Exception ex)
276276
{
@@ -316,7 +316,7 @@ public void Start()
316316
MonitorManager.StartMonitoring();
317317
Logs.Add($"HDR Monitoring started", false);
318318
Started = true;
319-
UpdateHDRBasedOnCurrentApplication();
319+
SetHDRBasedOnCurrentApplication();
320320

321321
}
322322
}
@@ -413,11 +413,11 @@ private void RemoveApplication(ApplicationItem process)
413413
private void ProcessWatcher_RunningOrFocusedChanged(object sender, EventArgs e)
414414
{
415415
CurrentApplication = ProcessWatcher.CurrentRunningApplicationItem;
416-
UpdateHDRBasedOnCurrentApplication();
416+
SetHDRBasedOnCurrentApplication();
417417

418418
}
419419

420-
private void UpdateHDRBasedOnCurrentApplication()
420+
private void SetHDRBasedOnCurrentApplication()
421421
{
422422
lock (_accessLock)
423423
{

Source/HDRProfile/MonitorManager.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using CodectoryCore.UI.Wpf;
55
using System;
66
using System.Collections.Generic;
7+
using System.Collections.ObjectModel;
78
using System.Drawing;
89
using System.Linq;
910
using System.Management;
@@ -53,6 +54,7 @@ public struct DISPLAY_DEVICE
5354
}
5455

5556

57+
5658
public class MonitorManager : BaseViewModel
5759
{
5860
[DllImport("user32.dll")]
@@ -77,9 +79,8 @@ public class MonitorManager : BaseViewModel
7779

7880
public event EventHandler AutoHDRChanged;
7981

80-
//private List<Monitor> _monitors = new List<Monitor>();
8182

82-
//public List<Monitor> Monitors { get => _monitors; set { _monitors = value; OnPropertyChanged(); } }
83+
public ObservableCollection<Monitor> Monitors => Settings.Monitors;
8384

8485
public MonitorManager(HDRProfileSettings settings)
8586
{
@@ -118,17 +119,21 @@ private void HDRMonitorLoop()
118119
{
119120
while (!_monitorCancelRequested)
120121
{
121-
foreach (Monitor monitor in Settings.Monitors)
122-
monitor.HDRState = HDRController.GetHDRState(monitor.UID);
122+
bool currentValue = false;
123123

124-
bool currentValue = HDRController.GetGlobalHDRState();
124+
foreach (Monitor monitor in Monitors)
125+
{
126+
monitor.UpdateHDRState();
127+
if (monitor.AutoHDR)
128+
currentValue = currentValue || monitor.HDRState;
129+
}
125130
bool changed = GlobalHDRIsActive != currentValue;
126131
GlobalHDRIsActive = currentValue;
127132
if (changed)
128133
{
129134
try { HDRIsActiveChanged?.Invoke(null, EventArgs.Empty); } catch { }
130135
}
131-
System.Threading.Thread.Sleep(50);
136+
System.Threading.Thread.Sleep(100);
132137
}
133138
}
134139

@@ -209,27 +214,27 @@ private void MergeMonitors(List<Monitor> monitors)
209214
{
210215

211216
List<Monitor> toRemove = new List<Monitor>();
212-
foreach (Monitor monitor in Settings.Monitors)
217+
foreach (Monitor monitor in Monitors)
213218
{
214219
if (!monitors.Any(m => m.UID.Equals(monitor.UID)))
215220
toRemove.Add(monitor);
216221
}
217222
foreach (Monitor monitor in toRemove)
218-
Settings.Monitors.Remove(monitor);
223+
Monitors.Remove(monitor);
219224
foreach (Monitor monitor in monitors)
220225
{
221226
if (!Settings.Monitors.Any(m => m.UID.Equals(monitor.UID)))
222227
Settings.Monitors.Add(monitor);
223228
else
224229
{
225-
Monitor existingMonitor = Settings.Monitors.First(m => m.UID.Equals(monitor.UID));
230+
Monitor existingMonitor = Monitors.First(m => m.UID.Equals(monitor.UID));
226231
existingMonitor.Name = monitor.Name;
227232
existingMonitor.RefreshRate = monitor.RefreshRate;
228233
existingMonitor.Resolution = monitor.Resolution;
229234
}
230235
}
231236

232-
foreach (Monitor monitor in Settings.Monitors)
237+
foreach (Monitor monitor in Monitors)
233238
{
234239
monitor.PropertyChanged += Monitor_PropertyChanged;
235240
}

Source/HDRProfile/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.5.6.0")]
56-
[assembly: AssemblyFileVersion("1.5.6.0")]
55+
[assembly: AssemblyVersion("1.5.7.0")]
56+
[assembly: AssemblyFileVersion("1.5.7.0")]

0 commit comments

Comments
 (0)