OLD | NEW |
---|---|
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" |
15 #include "ui/base/win/mouse_wheel_util.h" | 17 #include "ui/base/win/mouse_wheel_util.h" |
16 #include "ui/base/win/shell.h" | 18 #include "ui/base/win/shell.h" |
17 #include "ui/base/win/touch_input.h" | 19 #include "ui/base/win/touch_input.h" |
18 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1378 // Look into moving the WS_VSCROLL and WS_HSCROLL style setting logic to the | 1380 // Look into moving the WS_VSCROLL and WS_HSCROLL style setting logic to the |
1379 // CalculateWindowStylesFromInitParams function. Doing it there seems to | 1381 // CalculateWindowStylesFromInitParams function. Doing it there seems to |
1380 // cause some interactive tests to fail. Investigation needed. | 1382 // cause some interactive tests to fail. Investigation needed. |
1381 if (IsTopLevelWindow(hwnd())) { | 1383 if (IsTopLevelWindow(hwnd())) { |
1382 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); | 1384 long current_style = ::GetWindowLong(hwnd(), GWL_STYLE); |
1383 ::SetWindowLong(hwnd(), GWL_STYLE, | 1385 ::SetWindowLong(hwnd(), GWL_STYLE, |
1384 current_style | WS_VSCROLL | WS_HSCROLL); | 1386 current_style | WS_VSCROLL | WS_HSCROLL); |
1385 scroll_styles_set_ = true; | 1387 scroll_styles_set_ = true; |
1386 } | 1388 } |
1387 #endif | 1389 #endif |
1390 WTSRegisterSessionNotification(hwnd(), NOTIFY_FOR_THIS_SESSION); | |
sky
2014/01/16 16:36:37
Docs indicate you need to unregister.
| |
1391 | |
1388 // TODO(beng): move more of NWW::OnCreate here. | 1392 // TODO(beng): move more of NWW::OnCreate here. |
1389 return 0; | 1393 return 0; |
1390 } | 1394 } |
1391 | 1395 |
1392 void HWNDMessageHandler::OnDestroy() { | 1396 void HWNDMessageHandler::OnDestroy() { |
1393 delegate_->HandleDestroying(); | 1397 delegate_->HandleDestroying(); |
1394 } | 1398 } |
1395 | 1399 |
1396 void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel, | 1400 void HWNDMessageHandler::OnDisplayChange(UINT bits_per_pixel, |
1397 const CSize& screen_size) { | 1401 const CSize& screen_size) { |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2314 MARGINS m = {10, 10, 10, 10}; | 2318 MARGINS m = {10, 10, 10, 10}; |
2315 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2319 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2316 } | 2320 } |
2317 if (window_pos->flags & SWP_SHOWWINDOW) | 2321 if (window_pos->flags & SWP_SHOWWINDOW) |
2318 delegate_->HandleVisibilityChanged(true); | 2322 delegate_->HandleVisibilityChanged(true); |
2319 else if (window_pos->flags & SWP_HIDEWINDOW) | 2323 else if (window_pos->flags & SWP_HIDEWINDOW) |
2320 delegate_->HandleVisibilityChanged(false); | 2324 delegate_->HandleVisibilityChanged(false); |
2321 SetMsgHandled(FALSE); | 2325 SetMsgHandled(FALSE); |
2322 } | 2326 } |
2323 | 2327 |
2328 void HWNDMessageHandler::ForceRedrawWindow(int attempts) { | |
2329 HDESK input_desktop = ::OpenInputDesktop(0, 0, GENERIC_READ); | |
2330 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
| |
2331 // Presents will continue to fail as long as the input desktop is | |
2332 // unavailable. | |
2333 if (--attempts <= 0) | |
2334 return; | |
2335 base::MessageLoop::current()->PostDelayedTask( | |
2336 FROM_HERE, | |
2337 base::Bind(&HWNDMessageHandler::ForceRedrawWindow, | |
2338 weak_factory_.GetWeakPtr(), | |
2339 attempts), | |
2340 base::TimeDelta::FromMilliseconds(500)); | |
2341 return; | |
2342 } | |
2343 ::CloseDesktop(input_desktop); | |
2344 InvalidateRect(hwnd(), NULL, FALSE); | |
2345 } | |
2346 | |
2347 void HWNDMessageHandler::OnSessionChange(WPARAM status_code, | |
2348 PWTSSESSION_NOTIFICATION session_id) { | |
2349 // Direct3D presents are ignored while the screen is locked, so force the | |
2350 // window to be redrawn on unlock. | |
2351 if (status_code == WTS_SESSION_UNLOCK) | |
2352 ForceRedrawWindow(10); | |
2353 | |
2354 SetMsgHandled(FALSE); | |
2355 } | |
2356 | |
2324 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2357 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
2325 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2358 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
2326 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2359 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
2327 delegate_->HandleTouchEvent(touch_events[i]); | 2360 delegate_->HandleTouchEvent(touch_events[i]); |
2328 } | 2361 } |
2329 | 2362 |
2330 } // namespace views | 2363 } // namespace views |
OLD | NEW |