Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 140453002: Repaint windows on screen unlock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c4a52976c3f8fda93a3c16828b6232e15db4fc1c..c333e8cdb1f53ccf32611189faab6bc90d14c2b1 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() {
+ bool is_locked = true;
+ HDESK input_desk = ::OpenInputDesktop(0, 0, GENERIC_READ);
cpu_(ooo_6.6-7.5) 2014/01/19 20:52:45 Opening the input desktop still has me confused. Y
+ 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;
+}
+
} // 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) {
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698