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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <wtsapi32.h>
10 #pragma comment(lib, "wtsapi32.lib")
9 11
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
12 #include "base/win/win_util.h" 14 #include "base/win/win_util.h"
13 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
14 #include "ui/base/touch/touch_enabled.h" 16 #include "ui/base/touch/touch_enabled.h"
17 #include "ui/base/win/lock_state.h"
15 #include "ui/base/win/mouse_wheel_util.h" 18 #include "ui/base/win/mouse_wheel_util.h"
16 #include "ui/base/win/shell.h" 19 #include "ui/base/win/shell.h"
17 #include "ui/base/win/touch_input.h" 20 #include "ui/base/win/touch_input.h"
18 #include "ui/events/event.h" 21 #include "ui/events/event.h"
19 #include "ui/events/event_utils.h" 22 #include "ui/events/event_utils.h"
20 #include "ui/events/gestures/gesture_sequence.h" 23 #include "ui/events/gestures/gesture_sequence.h"
21 #include "ui/events/keycodes/keyboard_code_conversion_win.h" 24 #include "ui/events/keycodes/keyboard_code_conversion_win.h"
22 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/canvas_skia_paint.h" 26 #include "ui/gfx/canvas_skia_paint.h"
24 #include "ui/gfx/icon_util.h" 27 #include "ui/gfx/icon_util.h"
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 POINT position = {wr.left, wr.top}; 1283 POINT position = {wr.left, wr.top};
1281 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas()); 1284 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas());
1282 POINT zero = {0, 0}; 1285 POINT zero = {0, 0};
1283 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; 1286 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA};
1284 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, 1287 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero,
1285 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); 1288 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
1286 invalid_rect_.SetRect(0, 0, 0, 0); 1289 invalid_rect_.SetRect(0, 0, 0, 0);
1287 skia::EndPlatformPaint(layered_window_contents_->sk_canvas()); 1290 skia::EndPlatformPaint(layered_window_contents_->sk_canvas());
1288 } 1291 }
1289 1292
1293 void HWNDMessageHandler::ForceRedrawWindow(int attempts) {
1294 if (ui::IsWorkstationLocked()) {
1295 // Presents will continue to fail as long as the input desktop is
1296 // unavailable.
1297 if (--attempts <= 0)
1298 return;
1299 base::MessageLoop::current()->PostDelayedTask(
1300 FROM_HERE,
1301 base::Bind(&HWNDMessageHandler::ForceRedrawWindow,
1302 weak_factory_.GetWeakPtr(),
1303 attempts),
1304 base::TimeDelta::FromMilliseconds(500));
1305 return;
1306 }
1307 InvalidateRect(hwnd(), NULL, FALSE);
1308 }
1309
1290 // Message handlers ------------------------------------------------------------ 1310 // Message handlers ------------------------------------------------------------
1291 1311
1292 void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) { 1312 void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) {
1293 if (delegate_->IsWidgetWindow() && !active && 1313 if (delegate_->IsWidgetWindow() && !active &&
1294 thread_id != GetCurrentThreadId()) { 1314 thread_id != GetCurrentThreadId()) {
1295 delegate_->HandleAppDeactivated(); 1315 delegate_->HandleAppDeactivated();
1296 // Also update the native frame if it is rendering the non-client area. 1316 // Also update the native frame if it is rendering the non-client area.
1297 if (!remove_standard_frame_ && !delegate_->IsUsingCustomFrame()) 1317 if (!remove_standard_frame_ && !delegate_->IsUsingCustomFrame())
1298 DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0); 1318 DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0);
1299 } 1319 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 #if !defined(USE_AURA) 1399 #if !defined(USE_AURA)
1380 // We need to add ourselves as a message loop observer so that we can repaint 1400 // We need to add ourselves as a message loop observer so that we can repaint
1381 // aggressively if the contents of our window become invalid. Unfortunately 1401 // aggressively if the contents of our window become invalid. Unfortunately
1382 // WM_PAINT messages are starved and we get flickery redrawing when resizing 1402 // WM_PAINT messages are starved and we get flickery redrawing when resizing
1383 // if we do not do this. 1403 // if we do not do this.
1384 base::MessageLoopForUI::current()->AddObserver(this); 1404 base::MessageLoopForUI::current()->AddObserver(this);
1385 #endif 1405 #endif
1386 1406
1387 delegate_->HandleCreate(); 1407 delegate_->HandleCreate();
1388 1408
1409 WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION);
1410
1389 // TODO(beng): move more of NWW::OnCreate here. 1411 // TODO(beng): move more of NWW::OnCreate here.
1390 return 0; 1412 return 0;
1391 } 1413 }
1392 1414
1393 void HWNDMessageHandler::OnDestroy() { 1415 void HWNDMessageHandler::OnDestroy() {
1416 WTSUnRegisterSessionNotification(hwnd());
1394 delegate_->HandleDestroying(); 1417 delegate_->HandleDestroying();
1395 } 1418 }
1396 1419
1397 void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel, 1420 void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel,
1398 const CSize& screen_size) { 1421 const CSize& screen_size) {
1399 delegate_->HandleDisplayChange(); 1422 delegate_->HandleDisplayChange();
1400 } 1423 }
1401 1424
1402 LRESULT HWNDMessageHandler::OnDwmCompositionChanged(UINT msg, 1425 LRESULT HWNDMessageHandler::OnDwmCompositionChanged(UINT msg,
1403 WPARAM w_param, 1426 WPARAM w_param,
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 2068
2046 LRESULT HWNDMessageHandler::OnScrollMessage(UINT message, 2069 LRESULT HWNDMessageHandler::OnScrollMessage(UINT message,
2047 WPARAM w_param, 2070 WPARAM w_param,
2048 LPARAM l_param) { 2071 LPARAM l_param) {
2049 MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime() }; 2072 MSG msg = { hwnd(), message, w_param, l_param, GetMessageTime() };
2050 ui::ScrollEvent event(msg); 2073 ui::ScrollEvent event(msg);
2051 delegate_->HandleScrollEvent(event); 2074 delegate_->HandleScrollEvent(event);
2052 return 0; 2075 return 0;
2053 } 2076 }
2054 2077
2078 void HWNDMessageHandler::OnSessionChange(WPARAM status_code,
2079 PWTSSESSION_NOTIFICATION session_id) {
2080 // Direct3D presents are ignored while the screen is locked, so force the
2081 // window to be redrawn on unlock.
2082 if (status_code == WTS_SESSION_UNLOCK)
2083 ForceRedrawWindow(10);
2084
2085 SetMsgHandled(FALSE);
2086 }
2087
2055 LRESULT HWNDMessageHandler::OnSetCursor(UINT message, 2088 LRESULT HWNDMessageHandler::OnSetCursor(UINT message,
2056 WPARAM w_param, 2089 WPARAM w_param,
2057 LPARAM l_param) { 2090 LPARAM l_param) {
2058 // Reimplement the necessary default behavior here. Calling DefWindowProc can 2091 // Reimplement the necessary default behavior here. Calling DefWindowProc can
2059 // trigger weird non-client painting for non-glass windows with custom frames. 2092 // trigger weird non-client painting for non-glass windows with custom frames.
2060 // Using a ScopedRedrawLock to prevent caption rendering artifacts may allow 2093 // Using a ScopedRedrawLock to prevent caption rendering artifacts may allow
2061 // content behind this window to incorrectly paint in front of this window. 2094 // content behind this window to incorrectly paint in front of this window.
2062 // Invalidating the window to paint over either set of artifacts is not ideal. 2095 // Invalidating the window to paint over either set of artifacts is not ideal.
2063 wchar_t* cursor = IDC_ARROW; 2096 wchar_t* cursor = IDC_ARROW;
2064 switch (LOWORD(l_param)) { 2097 switch (LOWORD(l_param)) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2359 SetMsgHandled(FALSE); 2392 SetMsgHandled(FALSE);
2360 } 2393 }
2361 2394
2362 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { 2395 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) {
2363 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 2396 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
2364 for (size_t i = 0; i < touch_events.size() && ref; ++i) 2397 for (size_t i = 0; i < touch_events.size() && ref; ++i)
2365 delegate_->HandleTouchEvent(touch_events[i]); 2398 delegate_->HandleTouchEvent(touch_events[i]);
2366 } 2399 }
2367 2400
2368 } // namespace views 2401 } // namespace views
OLDNEW
« 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