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

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 97694b0323326504759a1350ec8ac3fe6357680d..67db2370fb21c6eb1a4ee6840189f8ae96130502 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -6,12 +6,15 @@
#include <dwmapi.h>
#include <shellapi.h>
+#include <wtsapi32.h>
+#pragma comment(lib, "wtsapi32.lib")
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "ui/base/touch/touch_enabled.h"
+#include "ui/base/win/lock_state.h"
#include "ui/base/win/mouse_wheel_util.h"
#include "ui/base/win/shell.h"
#include "ui/base/win/touch_input.h"
@@ -1287,6 +1290,23 @@ void HWNDMessageHandler::RedrawLayeredWindowContents() {
skia::EndPlatformPaint(layered_window_contents_->sk_canvas());
}
+void HWNDMessageHandler::ForceRedrawWindow(int attempts) {
+ if (ui::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 +1406,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 +2075,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