Index: ui/views/win/hwnd_message_handler.cc |
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
index 8fe91e4b3a98d88f44d909082d7a3633c52a98cb..de3f5cb4fecf640af2337225d111fcb18cc76cd6 100644 |
--- a/ui/views/win/hwnd_message_handler.cc |
+++ b/ui/views/win/hwnd_message_handler.cc |
@@ -6,6 +6,8 @@ |
#include <dwmapi.h> |
#include <shellapi.h> |
+#include <wtsapi32.h> |
+#pragma comment(lib, "wtsapi32.lib") |
#include "base/bind.h" |
#include "base/debug/trace_event.h" |
@@ -315,6 +317,21 @@ void AddScrollStylesToWindow(HWND window) { |
} |
} |
+bool IsWorkstationLocked() { |
sky
2014/01/24 00:36:07
This looks like a copy of that in idle_win. How ab
|
+ bool is_locked = true; |
+ HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ); |
+ if (input_desk) { |
+ wchar_t name[256] = {0}; |
+ DWORD needed = 0; |
+ if (::GetUserObjectInformation( |
+ input_desk, UOI_NAME, name, sizeof(name), &needed)) { |
+ is_locked = lstrcmpi(name, L"default") != 0; |
+ } |
+ ::CloseDesktop(input_desk); |
+ } |
+ return is_locked; |
+} |
cpu_(ooo_6.6-7.5)
2014/01/23 23:01:13
if ::OpenInputDesktop fails I don't know if it is
|
+ |
} // namespace |
// A scoping class that prevents a window from being able to redraw in response |
@@ -1287,6 +1304,23 @@ void HWNDMessageHandler::RedrawLayeredWindowContents() { |
skia::EndPlatformPaint(layered_window_contents_->sk_canvas()); |
} |
+void HWNDMessageHandler::ForceRedrawWindow(int attempts) { |
+ if (IsWorkstationLocked()) { |
+ // Presents will continue to fail as long as the input desktop is |
+ // unavailable. |
+ if (--attempts <= 0) |
+ return; |
+ base::MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&HWNDMessageHandler::ForceRedrawWindow, |
+ weak_factory_.GetWeakPtr(), |
+ attempts), |
+ base::TimeDelta::FromMilliseconds(500)); |
+ return; |
+ } |
+ InvalidateRect(hwnd(), NULL, FALSE); |
+} |
+ |
// Message handlers ------------------------------------------------------------ |
void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) { |
@@ -1386,11 +1420,14 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { |
delegate_->HandleCreate(); |
+ WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION); |
+ |
// TODO(beng): move more of NWW::OnCreate here. |
return 0; |
} |
void HWNDMessageHandler::OnDestroy() { |
+ WTSUnRegisterSessionNotification(hwnd()); |
delegate_->HandleDestroying(); |
} |
@@ -2052,6 +2089,16 @@ LRESULT HWNDMessageHandler::OnScrollMessage(UINT message, |
return 0; |
} |
+void HWNDMessageHandler::OnSessionChange(WPARAM status_code, |
+ PWTSSESSION_NOTIFICATION session_id) { |
+ // Direct3D presents are ignored while the screen is locked, so force the |
+ // window to be redrawn on unlock. |
+ if (status_code == WTS_SESSION_UNLOCK) |
+ ForceRedrawWindow(10); |
+ |
+ SetMsgHandled(FALSE); |
+} |
+ |
LRESULT HWNDMessageHandler::OnSetCursor(UINT message, |
WPARAM w_param, |
LPARAM l_param) { |