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 190af84fb10f45f60582c4b25c731669369a96e2..6edf5baa6d5c2203608c40725253380dc9a19910 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" |
@@ -1385,6 +1387,8 @@ LRESULT HWNDMessageHandler::OnCreate(CREATESTRUCT* create_struct) { |
scroll_styles_set_ = true; |
} |
#endif |
+ WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION); |
sky
2014/01/16 16:36:37
Docs indicate you need to unregister.
|
+ |
// TODO(beng): move more of NWW::OnCreate here. |
return 0; |
} |
@@ -2321,6 +2325,35 @@ void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) { |
SetMsgHandled(FALSE); |
} |
+void HWNDMessageHandler::ForceRedrawWindow(int attempts) { |
+ HDESK input_desktop = ::OpenInputDesktop(0, 0, GENERIC_READ); |
+ if (!input_desktop) { |
cpu_(ooo_6.6-7.5)
2014/01/16 18:35:08
son, I am not sure what you are trying to do here
|
+ // 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; |
+ } |
+ ::CloseDesktop(input_desktop); |
+ InvalidateRect(hwnd(), NULL, FALSE); |
+} |
+ |
+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); |
+} |
+ |
void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
for (size_t i = 0; i < touch_events.size() && ref; ++i) |