microsoft/WPFDXInterop

isNewSurface is insufficient to detect screensaver/lock/Ctrl-Alt-Delete losses

FlsZen opened this issue · 0 comments

The OnRender callback's Boolean/isNewSurface flag isn't set as true after the desktop is locked / Ctrl-Alt-Delete pressed / screensaver / etc., so while rendering is happening, the visible image isn't being updated. I'm not a DX expert, so I'm not sure what goes on under the hood, but I did notice that the device's NativePointer changes in these circumstances.

To detect these situations, my code now notices that the device's NativePointer changes:
if (isNewSurface || device.NativePointer != _currentDevice) {
_currentDevice = device.NativePointer;
...set up as new...
{