Refactor monitor matching and persistence to use a single, stable Id (format: "{Source}_{EdidId}_{MonitorNumber}") across all components. Remove HardwareId and DeviceKey properties from Monitor, update ProfileMonitorSetting to use MonitorId, and simplify MonitorMatchingHelper logic. Update DDC/CI, WMI, ViewModels, Settings UI, and unit tests to rely on Id for all lookups, state management, and handle mapping. Improves reliability for multi-monitor setups and simplifies codebase by removing legacy fallback logic.
Refactor GetUserFriendlyName to use UserFriendlyNameLength for accurate string extraction from the WMI UserFriendlyName buffer. This ensures only valid characters are included, improving reliability when parsing monitor names.
Replaced legacy parsing and matching methods with a streamlined approach using `QueryDisplayConfig` and `MonitorDisplayInfo` to align monitor numbering with Windows Display Settings' "Identify" feature. Removed redundant methods and tests for parsing display numbers and device paths. Introduced a `MonitorNumber` property in `MonitorDisplayInfo` for consistent numbering. Updated `MonitorDiscoveryHelper` and `WmiController` to use the new logic. Enhanced logging for better debugging and maintainability.
Introduced a new GPO rule to manage PowerDisplay's enabled state via Group Policy, including updates to `GPOWrapper` and policy files (`PowerToys.admx` and `PowerToys.adml`).
Enhanced the PowerDisplay UI with profile management features, including quick apply, add, edit, and delete functionality. Updated `MainWindow.xaml` and `PowerDisplayPage.xaml` to support these changes, and added localized strings for improved accessibility.
Refactored `MainViewModel` to include a `Profiles` collection, `HasProfiles` property, and `ApplyProfileCommand`. Added methods to load profiles from disk and signal updates to PowerDisplay.
Improved error handling in `DdcCiController` and `WmiController` with input validation and WMI error classification. Optimized handle cleanup in `PhysicalMonitorHandleManager` with a more efficient algorithm.
Refactored `dllmain.cpp` to prevent duplicate PowerDisplay process launches. Updated initialization logic in `MainWindow.xaml.cs` to ensure proper ViewModel setup.
Localized strings for tooltips, warnings, and dialogs. Improved async behavior, logging, and UI accessibility.
Removed unused methods across multiple files, including `GetContrastAsync`, `GetVolumeAsync`, and `SaveCurrentSettingsAsync` in `DdcCiController.cs` and `WmiController.cs`. Simplified the `IMonitorController` interface by removing redundant methods.
Replaced `ProcessThemeChangeAsync` with a synchronous `ProcessThemeChange` in `LightSwitchListener.cs`. Changed `ParseVcpCodesToIntegers` visibility to private in `MonitorFeatureHelper.cs` and removed related helper methods.
Eliminated retry logic by removing `ExecuteWithRetryAsync` in `RetryHelper.cs`. Simplified `SetBrightnessAsync` in `MonitorManager.cs` using a generic helper. Streamlined `DisplayName` in `MonitorViewModel.cs` and removed unnecessary property change notifications.
These changes reduce complexity, improve maintainability, and streamline the codebase by removing unused or redundant functionality.
Updated the `WmiSetBrightness` method to pass `Timeout` and
`Brightness` parameters as strings instead of numeric types
to ensure compatibility with WMI driver implementations
that require string values. Updated comments to reflect
this change and clarify the reasoning behind it.
Updated the `Brightness` parameter in the `WmiSetBrightness` method to use `int` instead of casting to `byte`, addressing potential `WBEM_E_TYPE_MISMATCH` errors (0x80041005) caused by certain WMI driver implementations expecting `VT_I4` instead of `VT_UI1`.
Added comments to clarify the rationale for this change. Applied the fix in two sections of `WmiController.cs`, including both dynamic and hardcoded `Brightness` values.
Introduced functionality to get and set monitor input sources using VESA MCCS VCP code 0x60. This includes backend logic, UI integration, and error handling.
Backend changes:
- Added `GetInputSourceAsync` and `SetInputSourceAsync` in `DdcCiController.cs` for input source management.
- Defined `VcpCodeInputSource` constant in `NativeConstants.cs`.
- Updated `Monitor.cs` to include `CurrentInputSource`, `InputSourceName`, and support detection for input sources.
- Enhanced `MonitorManager.cs` to initialize and manage input source capabilities.
UI changes:
- Added a "More Actions" button in `MainWindow.xaml` for input source switching.
- Implemented a flyout menu to display and select available input sources.
- Added `InputSourceItem_Click` handler in `MainWindow.xaml.cs`.
ViewModel changes:
- Introduced `InputSourceItem` class for UI representation of input sources.
- Updated `MonitorViewModel.cs` to expose input source properties and handle switching.
Other improvements:
- Added detailed logging for input source operations.
- Implemented fallback mechanisms for robust behavior.
- Enhanced user experience with dynamic UI updates for input source changes.
- Renamed project entries in `PowerToys.sln` for consistency.
- Added new projects: "runner," "NewShellExtensionContextMenu," and "BgcodePreviewHandlerCpp."
- Introduced `MonitorMatchingHelper` to centralize monitor identification logic.
- Added unit tests for `MonitorMatchingHelper` to validate parsing and matching.
- Updated `MonitorInfo` with `MonitorNumber`, `TotalMonitorCount`, and `DisplayName` for dynamic formatting.
- Enhanced WMI monitor matching with pre-fetched display devices.
- Updated UI components to use dynamic `DisplayName` for monitors.
- Added `PowerDisplay.Lib.UnitTests` project for testing.
- Improved serialization, logging, and null handling in `PowerDisplayViewModel`.
- Removed redundant parsing logic from `MonitorDiscoveryHelper`.
Enhanced multi-monitor support by introducing a `MonitorNumber` property in the `Monitor` model to represent the Windows DISPLAY number. Updated the `MonitorViewModel` to include a `DisplayName` property that appends the monitor number to the name when multiple monitors are visible.
Modified `MainWindow.xaml` to bind to `DisplayName` instead of `Name`, ensuring the UI reflects the updated naming convention. Added logic to update `DisplayName` dynamically when the monitor count changes, improving clarity in multi-monitor setups.
Included comments in `MonitorViewModel` for better code readability and maintainability.
Refactored namespaces to improve modularity, including moving `PowerDisplay.Native` to `PowerDisplay.Common.Drivers`. Introduced the `IMonitorData` interface for better abstraction of monitor hardware data. Replaced `ColorTemperature` with `ColorTemperatureVcp` for precise VCP-based color temperature control, adding utilities for Kelvin conversion.
Enhanced monitor state management with a new `MonitorStateFile` for JSON persistence and updated `MonitorStateManager` for debounced saves. Added `MonitorMatchingHelper` for consistent monitor identification and `ProfileHelper` for profile management operations.
Refactored P/Invoke declarations into helper classes, updated UI bindings for `ColorTemperatureVcp`, and improved logging for better runtime visibility. Removed redundant code, added new utility classes (`MonitorValueConverter`, `MonitorMatchingHelper`), and ensured backward compatibility.
These changes improve code organization, maintainability, and extensibility while aligning with hardware-level control standards.