From 75b47af11469cce55e8f9165f247834aa58d181c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 16 Nov 2022 01:10:44 +0100 Subject: [PATCH] Reduce OSD flickering --- CommonHelpers/OSDHelpers.cs | 13 ++++++++++++- PerformanceOverlay/Controller.cs | 3 +-- PowerControl/Controller.cs | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CommonHelpers/OSDHelpers.cs b/CommonHelpers/OSDHelpers.cs index 422675f..d907ab9 100644 --- a/CommonHelpers/OSDHelpers.cs +++ b/CommonHelpers/OSDHelpers.cs @@ -15,12 +15,23 @@ namespace CommonHelpers return uint.MaxValue; var osdSlot = typeof(OSD).GetField("m_osdSlot", - System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var value = osdSlot.GetValue(osd); if (value is null) return uint.MaxValue; return (uint)value; } + + public static uint OSDIndex(String name) + { + var entries = OSD.GetOSDEntries().ToList(); + for (int i = 0; i < entries.Count(); i++) + { + if (entries[i].Owner == name) + return (uint)i; + } + return 0; + } } } diff --git a/PerformanceOverlay/Controller.cs b/PerformanceOverlay/Controller.cs index f7562d3..728920c 100644 --- a/PerformanceOverlay/Controller.cs +++ b/PerformanceOverlay/Controller.cs @@ -204,9 +204,8 @@ namespace PerformanceOverlay try { // recreate OSD if not index 0 - if (osd != null && osd.OSDIndex() != 0) + if (OSDHelpers.OSDIndex("PerformanceOverlay") != 0) osdClose(); - if (osd == null) osd = new OSD("PerformanceOverlay"); diff --git a/PowerControl/Controller.cs b/PowerControl/Controller.cs index d1dd9b6..f40e5d7 100644 --- a/PowerControl/Controller.cs +++ b/PowerControl/Controller.cs @@ -266,8 +266,8 @@ namespace PowerControl try { - // recreate OSD if not index 0 - if (osd != null && osd.OSDIndex() == 0) + // recreate OSD if index 0 + if (OSDHelpers.OSDIndex("Power Control") == 0 && OSD.GetOSDCount() > 1) osdClose(); if (osd == null) osd = new OSD("Power Control");