Implement hacky workaround for rendering errors on XP and newer when the screen
is locked.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4597 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/Win32PixelBuffer.cxx b/vncviewer/Win32PixelBuffer.cxx
index 71e18c4..8f9bf02 100644
--- a/vncviewer/Win32PixelBuffer.cxx
+++ b/vncviewer/Win32PixelBuffer.cxx
@@ -77,8 +77,15 @@
if (!SelectObject(dc, bitmap))
throw rdr::SystemException("SelectObject failed", GetLastError());
- if (!BitBlt(fl_gc, x, y, w, h, dc, src_x, src_y, SRCCOPY))
- throw rdr::SystemException("BitBlt failed", GetLastError());
+ if (!BitBlt(fl_gc, x, y, w, h, dc, src_x, src_y, SRCCOPY)) {
+ // If the desktop we're rendering to is inactive (like when the screen
+ // is locked or the UAC is active), then GDI calls will randomly fail.
+ // This is completely undocumented so we have no idea how best to deal
+ // with it. For now, we've only seen this error and for this function
+ // so only ignore this combination.
+ if (GetLastError() != ERROR_INVALID_HANDLE)
+ throw rdr::SystemException("BitBlt failed", GetLastError());
+ }
DeleteDC(dc);
}