Commit Graph

334 Commits

Author SHA1 Message Date
Terry MacDonald
8cc59583e1 Updated branch with latest develop hotfixes 2022-07-15 09:04:56 +12:00
Terry MacDonald
eefa361773 Fixed error when returning from Mosaic layouts in WIndows 10
There was an error that occurred in NvAPI_SetDisplayConfig when attempting to go from an NVIDIA Surround to a non-NVIDIA Surround setup on a machine that has multiple video cards installed in it. This is due to the fact that the NVIDIA driver only sees the displays connected to NVIDIA video adapters.

The previous DM logic tried to set the DisplayConfig after switching to or from a Surround display profile, but this would fail when returning from a a Surround display profile on Win 10 devices. It appears that the NVIDIA driver AUTOMATICALLY disables all additional displays in windows when it returns from a Surround profile. This simple fact means that the DisplayConfig won't be applied properly, and it errors with an NVAPI_INVALID_ARGUMENT error. This doesn't actually matter though, as the WinLibrary comes to the rescue.

WinLibrary can see all the video adapters available, and so will turn the required displays back on and set them up just right! We *may* lose are some specific DisplayConfig parameters abeing set as part of this process, but I'm not totally sure about that as WinLibrary is basically feature parity with the DisplayConfig settings as far as I can tell.

The fix is to look specifically for the NVAPI_INVALID_ARGUMENT error when attempting to set the NvAPI_DisplayConfig, and if this happens we check if we were going from a surround profile to a non-surround profile. If that is true, then we simply ignore that error. WinLibrary then clears up that problem and everything proceeds as normal.

This should (fingers crossed) fix #119!

This change also makes it far faster to grab and set the tabaskbar settings from registry, though this logic may not detect some Windows 10 formats which appear to be LOCALDISPLAY(\d,\d,\d\d) settings which I've never seen before. It should be generally much faster and more reliable.
2022-07-14 22:41:59 +12:00
Terry MacDonald
cb51ea9245 Set all the JSON.net default values
We now properly set the default JSON values for everything except Display Profiles, which should avoid crashes to desktop if we miss setting a value from it's default in the future. This should help with application robustness.
2022-07-08 09:59:29 +12:00
Terry MacDonald
d719cecad2 Standardised JSON.net settings across modules
Just noticed that the Settings, Display Profiles and Game Shortcuts all had different json.net settings for reading and writing across all the modules. Have now standardised across them to make them act the same way.
2022-07-08 09:00:35 +12:00
Terry MacDonald
bd619a131e Merge branch 'develop' into feature-installed-programs 2022-07-03 20:07:57 +12:00
Terry MacDonald
83b8938e1a Reduces config scanning delay as much as possible
WinLibrary currently waits 5 seconds if it can't read the taskbar registry, and then it tries again. This is because based on my testing, if a screen layout changes, windows takes up to 20 seconds to update registry to record this fact. We have to wait until windows has finished 4 times before we are sure to have passed the 20 second window.

This is likely the delay you have mentioned. I *think* that I can slightly speed this up. We only MUST to do this delay when we are recording the config (i.e. creating a new display profile), and other times it's kind of a nice to have. So I've attempted to speed this up using a 'fastScan' option for the WinLibrary GetActiveConfig function. This will enable it to only query once for the general scans of the active config, and if there is a problem getting the data it will just accept that fact and will still return quickly. But it will still take up to 20 seconds when creating a new display profile as it is REALLY important we get that data correctly.

Fixes #129
2022-07-02 15:08:54 +12:00
Terry MacDonald
8122295716 Merged v2.4.0 release into branch 2022-07-01 14:04:27 +12:00
Terry MacDonald
20c390d6f9 Fixed ProcessPriority error in StartProgramControl
This is now working properly.
2022-06-29 20:37:20 +12:00
Terry MacDonald
e99db6d4af Updated NLog exception logging format to capture all details
Updated the NLog exception handling to make use of the additional logging options released recently. This will help provide me with more details when users create the Support ZIP File.
2022-06-28 13:47:56 +12:00
Terry MacDonald
5cb653f449 Remove uneeded DPI_VALUES array
Had forgotten to remove the uneeded DPI_VALUES array. This would have crashed the WinLibrary SetDisplayConfig process.
2022-06-28 11:43:18 +12:00
Terry MacDonald
2e18ca1832 Change to work with the new DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED option
This change means that DisplayMagician only supports Windows 10 (version 1809 or later), or Windows 11. This fixes issue #123.
2022-06-28 11:39:14 +12:00
Terry MacDonald
01d6c1b9a9 First attempt at setting Process DPI Awareness
This is required so that the undocumented DISPLAYCONFIG_SOURCE_DPI_SCALE_GET Windows CCD call is given the correct information by Windows 10/11. It gives an abnormal number on some hardware if this is not set. What we do now is set the process DPI context to "System Aware" on boot, but when we are either getting or setting the Windows DPI settings, we quickly swap to "Monitor Aware v2" DPI context, before swapping back to "System Aware" when we're done. This *should* return the correct per monitor settings.
2022-06-28 09:29:18 +12:00
Terry MacDonald
9827cfac9a Fixed excessive config gathering
The NVAPI and Windows APIs were checked multiple times in a row due to a logic error. THis has been partially corrected, but needs a lot of work to straighten it out.
2022-06-18 21:31:37 +12:00
Terry MacDonald
076f9524cd Remove unneeded NvAPI_Mosaic_GetSupportedTopoInfo function
This function isn't needed, but seems to be unreliable when it's used. So diabling it within NVIDIALibrary to reduce the chances of there being memory errors thrown.
2022-06-17 10:34:31 +12:00
Terry MacDonald
e893fbac69 Increased logging and improved uplay library processing 2022-06-17 10:18:55 +12:00
dependabot[bot]
8866334a8f
Bump NLog from 5.0.0 to 5.0.1
Bumps [NLog](https://github.com/NLog/NLog) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/NLog/NLog/releases)
- [Changelog](https://github.com/NLog/NLog/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/NLog/NLog/compare/v5.0...v5.0.1)

---
updated-dependencies:
- dependency-name: NLog
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-13 08:29:52 +00:00
Terry MacDonald
2d2cbcbe90 Updated WInLibrary and TaskBarLayout to latest versions
This change adds validation and additional checks to TaskBarLayout. Adds some extra logging to WinLibrary.
2022-06-12 22:04:05 +12:00
Terry MacDonald
cb43f74629 Fixed potential bug with window taskbar location during screen generation
There is a possibility that there are two displays with the same UID. This happens with software created displays such as SpaceDesk and Superdisplay. This means that we need to try and figure out which screen is the right screen, and then when we know which screen we were really wanting to
2022-06-10 18:52:26 +12:00
Terry MacDonald
d98730a9b2 Fixed exception in RemoveProfile function 2022-06-10 17:34:56 +12:00
Terry MacDonald
47912cf2e4 Updated TaskBarLayout and WinLibrary to latest versions 2022-06-10 17:29:58 +12:00
Terry MacDonald
7d17b5ae10 Fixed second CTD when changing from Surround to non-surround.
The NVIDIA Driver seems to not like any other SetTopoFlags except NONE. There is a CTD if anything is selected :(. So as a workaround I will leave send a NONE SetTopoFlag so DisplayMagician can work.

Also have updated the Display Profiles Window logic so that it repositions DisplayMagician in the center of the screen on the primary display. This has to be done when changing Display Profiles using the Apply Button, as the display coordinates change, and sometimes this results in the current position being off screen. This was causing confusion amongst users. But now just always moving to the middle of the primary screen I can always be sure that the UI is visible.
2022-06-09 22:56:07 +12:00
Terry MacDonald
97d9caf2af Fixed CTD in patchAdapterids
Error with PatchAdapterIds that caused a crash to desktop. Has now been fixed. Should fix #117 and #118
2022-06-09 22:25:37 +12:00
Terry MacDonald
dab58a5a2b Updated WinLibrary to the latest version.
Fixes #114
2022-06-04 09:52:27 +12:00
Terry MacDonald
aede23a83d Updated NVIDIALibrary and WinLibrary to handle win display reordering
NVIDIALibrary and WinLibrary were too rigid in their equality testing, which meant that there was a problem when Windows reordered the displays in the path. This happens randomly when changing to cloned displays, and after a reboot. This would muck up the equality testing, which would prevent users selecting the display profiles. This has now been corrected (as far as we can tell so far).

There is a slight chance that further testing may find other parts of the Windows Display Config that randomly change and need to be updated. Thanks Microsoft.
2022-06-03 21:47:33 +12:00
Terry MacDonald
aee177ecb7 Added upgrading logic for Display Profiles to 2.4
DM will now warn users they will need to recreate their Display Profiles again. I really hope this is the last time I have to do this to my lovely users.
2022-06-03 21:43:30 +12:00
Terry MacDonald
6e82557ec6 Removed some uneeded variables from AMDLibrary 2022-06-02 20:18:02 +12:00
Terry MacDonald
3fba28087c Made TaskBarLayout creation more robust
TaskBarLayout now catches exceptions recording the taskbar location and handles them properly. It will skip any screenss that it cannot access the taskbar information for. The Screen layout generator for NVIDIA, AMD and Windows have all been updated to handle having no taskbar layout information (it just assumes the taskbar is down the bottom of the screen).

Hopefully fixes #114
2022-06-02 19:51:07 +12:00
Terry MacDonald
56c2410d85 Updated WinLibrary so it patches adapter IDs accurately
This was a major error that somehow slipped through previous work. WinLibrary was only partially patching the Windows Display Config when it was being loaded, and that resulted in some parts  of the Windows Display Config not working after a windows reboot. This should now be fixed!

Fixes #103
2022-06-02 18:14:51 +12:00
Terry MacDonald
a318dc64f2 Adding WIndows DPI Scaling config patching for DisplayMagician
IMPORTANT: This patching means that DisplayMagician is able to use your existing Display Profiles, but there is a catch! DisplayMagician won't be able to detect that your old profiles are currently in use... in other words DisplayMagician will constantly think that you have a new Display Profile until you save a copy of the DisplayProfile again.

This occurs because DisplayMagician now gets and compares the NVIDIA 3D Settings and there is no way for us to figure out what previous 3D settings were in use when you set up previous display profiles. For that reason we'll just need you to save new Display Profiles.
2022-05-31 20:55:48 +12:00
Terry MacDonald
340387dcc4 Updated WinLibrary, NVIDIALibrary and AMDLIbrary to latest versions
Updated video libraries to v1.7.5
2022-05-31 09:02:18 +12:00
Terry MacDonald
a93c9e62d2 Added Windows per source DPI scaling settings 2022-05-30 10:01:43 +12:00
Terry MacDonald
f40640ccbd Updated UpdateActiveConfig 2022-05-29 21:16:55 +12:00
Terry MacDonald
567c9b7af2 Reduced the displayid calls for profile comparison 2022-05-29 21:01:08 +12:00
Terry MacDonald
f6b1eed990 Fixed ProgramSetting loading and use
There was a flaw in the way that ProgramSettings was being used that meant there was a lot of reloading and saving going on which was unnecessary. Additionally there were some errors in the way that the Settings file was upgraded which mean that the old settings were keeping on getting overwritten. Fixes #104.
2022-05-28 21:09:53 +12:00
Terry MacDonald
29c590a972 Fixed High CPU issue
Replaced Task.Delay with Thread.Sleep as we were incorrectly pausing the monitoring thread. Should fix #110.
2022-05-18 21:32:33 +12:00
dependabot[bot]
335250035c
Bump NLog from 4.7.15 to 5.0.0
Bumps [NLog](https://github.com/NLog/NLog) from 4.7.15 to 5.0.0.
- [Release notes](https://github.com/NLog/NLog/releases)
- [Changelog](https://github.com/NLog/NLog/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/NLog/NLog/compare/v4.7.15...v5.0)

---
updated-dependencies:
- dependency-name: NLog
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-17 08:27:33 +00:00
Terry MacDonald
f8a9ca8e1e Added in partial DRS Setting support
This DRS Support is just reserving a space for the future addition of DRS Settings pulled from the driver. This will allow the recording of settings listed in the 3D Settings within the NVIDIA Control panel.
2022-04-20 20:35:51 +12:00
Terry MacDonald
9a745ea3e7 Adjusted mainform startup now we're singleinstance
Made some adjustments to when the MainForm is loaded, and how the NotifyIcon works for system tray.

Also Adjusted the way that the Windows Screens are computed so that we can reuse some of the code in AMD and NVIDIA screen generation so that the additional non-NVIDIA and non-AMD connected screens are still shown.
2022-04-20 17:39:34 +12:00
Terry MacDonald
ae7bb095e2 Revamped display layout image shortcut generation
Made many changes to simplify the configuration and make the profile display layout image generation faster and more reliable.
2022-04-19 21:12:00 +12:00
Terry MacDonald
51806494ab Added checks for non-NVIDIA screens to NVIDIA mode
This will ensure that all screens show up in the images even if they aren't connected through an NVIDIA device. I also made the same changes to the AMD mode.
2022-04-19 15:23:35 +12:00
Terry MacDonald
b7194dd6e9 Added extra logging 2022-04-19 09:51:35 +12:00
Terry MacDonald
f042622921 Added SpaceDesk to recognised PCI devices
Also improved logging around PatchAdapterIDs
2022-04-19 09:31:07 +12:00
Terry MacDonald
ff93a1007c Found exception when tracking taskbar location
This is a subtle error, caused by either the NVIDIA driver being slow, or windows being slow in updating the location of the windows taskbar edge. This was causing an error in the GetNVIDIASCreenPositions function. Have added a 0.5 second delay to allow windows to update iit's display layout before we try to read it which should help, and also if we can't find the taskbar location in the settings, we just assume it is at the bottom. This should avoid exception.
2022-04-17 23:15:55 +12:00
Terry MacDonald
6f778f556d Detect 0 width and height screens and alert
Added specific checks to find and alert on 0 width or 0 height screens. This will then break other parts of the display layout.

Also moved the cloned screen check higher up to ensure we skip them properly.
2022-04-16 15:07:10 +12:00
Terry MacDonald
cc5f334917 Fix to ToTightestBitmap
Removed a divide by zero issue with ToTighestBitmap that could cause issues.
2022-04-16 14:55:24 +12:00
Terry MacDonald
c99c166b3d Cloned display image layout fixes
Cloned displays weren't showing properly in the image layouts, and this fixes that issue.
2022-04-15 15:13:27 +12:00
Terry MacDonald
fa05920618 Fixed Desktop right-click menu
Had forgottent to update the profiles json file to new v2.3 filename.
2022-04-15 11:46:46 +12:00
Terry MacDonald
25b8d1102f [WIP] Partially overhauled NVIDIA screen calculations
Had some mistakes in the way that the profile graphics images were calculated on NVIDIA video cards. This meant that in some situations it calculated the image structures incorrectly, and didn't put the displays in the right places. This now changes that fact.

There is still an outstanding issue that the GetNVIDIAScreenPositions function still doesn't put the taskbar location in the right place yet. I need to fix that tomorrow.
2022-04-13 22:48:32 +12:00
Terry MacDonald
11792ec1a3 Fixed incorrect log function name 2022-04-13 09:30:27 +12:00
Terry MacDonald
e4aab07b03 Tweaked error messages to better represent errorlevel
Changed a few ERROR level log messages to WARN as that better represents their classification.
2022-04-10 09:40:28 +12:00