mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-07 15:23:55 +00:00
PowerControl: Tweaks and fixes (#29)
* Fix context menu, add osd toggle * Update values on number of displays change * Check display info in DeviceManager * Refactor OSD toggle * Isolate display context setup * Move more context stuff to the display initialize method
This commit is contained in:
parent
1074143a6e
commit
64f4050de5
3 changed files with 119 additions and 2 deletions
|
|
@ -11,6 +11,30 @@ namespace PowerControl.Helpers
|
|||
{
|
||||
internal class DeviceManager
|
||||
{
|
||||
private static Screen[] screens = new Screen[0];
|
||||
public static int NumberOfDisplays
|
||||
{
|
||||
get { return screens.Length; }
|
||||
}
|
||||
|
||||
public static void LoadDisplays()
|
||||
{
|
||||
screens = Screen.AllScreens;
|
||||
}
|
||||
|
||||
public static bool RefreshDisplays()
|
||||
{
|
||||
var newScreens = Screen.AllScreens;
|
||||
|
||||
if (HaveScreensChanged(newScreens))
|
||||
{
|
||||
screens = newScreens;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string[]? GetDevices(Guid? classGuid)
|
||||
{
|
||||
string? filter = null;
|
||||
|
|
@ -126,6 +150,25 @@ namespace PowerControl.Helpers
|
|||
}
|
||||
}
|
||||
|
||||
private static bool HaveScreensChanged(Screen[] newScreens)
|
||||
{
|
||||
if (screens.Length != newScreens.Length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < screens.Length; i++)
|
||||
{
|
||||
if (screens[i].DeviceName != newScreens[i].DeviceName ||
|
||||
screens[i].Primary != newScreens[i].Primary)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport("setupapi.dll", CharSet = CharSet.Auto)]
|
||||
static extern int CM_Locate_DevNode(out IntPtr pdnDevInst, string pDeviceID, int ulFlags);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue