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 "content/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <dwmapi.h> | |
8 #include <InputScope.h> | 7 #include <InputScope.h> |
9 #include <wtsapi32.h> | 8 #include <wtsapi32.h> |
10 #pragma comment(lib, "wtsapi32.lib") | 9 #pragma comment(lib, "wtsapi32.lib") |
11 | 10 |
12 #include <algorithm> | 11 #include <algorithm> |
13 #include <map> | 12 #include <map> |
14 #include <stack> | 13 #include <stack> |
15 | 14 |
16 #include "base/bind.h" | 15 #include "base/bind.h" |
17 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 screen_info.depth = dev_mode.dmBitsPerPel; | 324 screen_info.depth = dev_mode.dmBitsPerPel; |
326 screen_info.depthPerComponent = dev_mode.dmBitsPerPel / 3; // Assumes RGB | 325 screen_info.depthPerComponent = dev_mode.dmBitsPerPel / 3; // Assumes RGB |
327 screen_info.deviceScaleFactor = ui::win::GetDeviceScaleFactor(); | 326 screen_info.deviceScaleFactor = ui::win::GetDeviceScaleFactor(); |
328 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; | 327 screen_info.isMonochrome = dev_mode.dmColor == DMCOLOR_MONOCHROME; |
329 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); | 328 screen_info.rect = gfx::Rect(monitor_info.rcMonitor); |
330 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); | 329 screen_info.availableRect = gfx::Rect(monitor_info.rcWork); |
331 | 330 |
332 *results = screen_info; | 331 *results = screen_info; |
333 } | 332 } |
334 | 333 |
335 void SetDwmPresentParameters(HWND window) { | |
336 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
337 BOOL is_composited; | |
338 HRESULT result = DwmIsCompositionEnabled(&is_composited); | |
339 if (SUCCEEDED(result) && is_composited) { | |
340 DWM_PRESENT_PARAMETERS present_parameters = {0}; | |
341 present_parameters.cbSize = sizeof(present_parameters); | |
342 present_parameters.cBuffer = 2; | |
343 | |
344 result = DwmSetPresentParameters(window, &present_parameters); | |
345 if (FAILED(result)) | |
346 DLOG(ERROR) << "Unable to set present parameters: 0x%08X", result; | |
347 } | |
348 } | |
349 } | |
350 | |
351 } // namespace | 334 } // namespace |
352 | 335 |
353 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; | 336 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
354 | 337 |
355 // Wrapper for maintaining touchstate associated with a WebTouchEvent. | 338 // Wrapper for maintaining touchstate associated with a WebTouchEvent. |
356 class WebTouchState { | 339 class WebTouchState { |
357 public: | 340 public: |
358 explicit WebTouchState(const RenderWidgetHostViewWin* window); | 341 explicit WebTouchState(const RenderWidgetHostViewWin* window); |
359 | 342 |
360 // Updates the current touchpoint state with the supplied touches. | 343 // Updates the current touchpoint state with the supplied touches. |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { | 1220 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { |
1238 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate"); | 1221 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCreate"); |
1239 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale | 1222 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale |
1240 // of a browser process. | 1223 // of a browser process. |
1241 OnInputLangChange(0, 0); | 1224 OnInputLangChange(0, 0); |
1242 // Marks that window as supporting mouse-wheel messages rerouting so it is | 1225 // Marks that window as supporting mouse-wheel messages rerouting so it is |
1243 // scrolled when under the mouse pointer even if inactive. | 1226 // scrolled when under the mouse pointer even if inactive. |
1244 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); | 1227 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(m_hWnd)); |
1245 | 1228 |
1246 WTSRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION); | 1229 WTSRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION); |
1247 SetDwmPresentParameters(m_hWnd); | |
1248 | 1230 |
1249 UpdateDesiredTouchMode(); | 1231 UpdateDesiredTouchMode(); |
1250 UpdateIMEState(); | 1232 UpdateIMEState(); |
1251 | 1233 |
1252 return 0; | 1234 return 0; |
1253 } | 1235 } |
1254 | 1236 |
1255 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, | 1237 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, |
1256 HWND window) { | 1238 HWND window) { |
1257 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate"); | 1239 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnActivate"); |
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 GetClientRect(¤tRect); | 2557 GetClientRect(¤tRect); |
2576 | 2558 |
2577 // Ensure window does not have zero area because D3D cannot create a zero | 2559 // Ensure window does not have zero area because D3D cannot create a zero |
2578 // area swap chain. | 2560 // area swap chain. |
2579 int width = std::max(1, | 2561 int width = std::max(1, |
2580 static_cast<int>(currentRect.right - currentRect.left)); | 2562 static_cast<int>(currentRect.right - currentRect.left)); |
2581 int height = std::max(1, | 2563 int height = std::max(1, |
2582 static_cast<int>(currentRect.bottom - currentRect.top)); | 2564 static_cast<int>(currentRect.bottom - currentRect.top)); |
2583 | 2565 |
2584 compositor_host_window_ = CreateWindowEx( | 2566 compositor_host_window_ = CreateWindowEx( |
2585 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 2567 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
2586 MAKEINTATOM(atom), 0, | 2568 MAKEINTATOM(atom), 0, |
2587 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, | 2569 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, |
2588 0, 0, width, height, m_hWnd, 0, instance, 0); | 2570 0, 0, width, height, m_hWnd, 0, instance, 0); |
2589 ui::CheckWindowCreated(compositor_host_window_); | 2571 ui::CheckWindowCreated(compositor_host_window_); |
2590 | 2572 |
2591 ui::SetWindowUserData(compositor_host_window_, this); | 2573 ui::SetWindowUserData(compositor_host_window_, this); |
2592 | 2574 |
2593 SetDwmPresentParameters(compositor_host_window_); | |
2594 | |
2595 gfx::GLSurfaceHandle surface_handle(compositor_host_window_, | 2575 gfx::GLSurfaceHandle surface_handle(compositor_host_window_, |
2596 gfx::NATIVE_TRANSPORT); | 2576 gfx::NATIVE_TRANSPORT); |
2597 | |
2598 return surface_handle; | 2577 return surface_handle; |
2599 } | 2578 } |
2600 | 2579 |
2601 void RenderWidgetHostViewWin::OnAcceleratedCompositingStateChange() { | 2580 void RenderWidgetHostViewWin::OnAcceleratedCompositingStateChange() { |
2602 bool show = render_widget_host_->is_accelerated_compositing_active(); | 2581 bool show = render_widget_host_->is_accelerated_compositing_active(); |
2603 // When we first create the compositor, we will get a show request from | 2582 // When we first create the compositor, we will get a show request from |
2604 // the renderer before we have gotten the create request from the GPU. In this | 2583 // the renderer before we have gotten the create request from the GPU. In this |
2605 // case, simply ignore the show request. | 2584 // case, simply ignore the show request. |
2606 if (compositor_host_window_ == NULL) | 2585 if (compositor_host_window_ == NULL) |
2607 return; | 2586 return; |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3223 return new RenderWidgetHostViewWin(widget); | 3202 return new RenderWidgetHostViewWin(widget); |
3224 } | 3203 } |
3225 | 3204 |
3226 // static | 3205 // static |
3227 void RenderWidgetHostViewPort::GetDefaultScreenInfo( | 3206 void RenderWidgetHostViewPort::GetDefaultScreenInfo( |
3228 WebKit::WebScreenInfo* results) { | 3207 WebKit::WebScreenInfo* results) { |
3229 GetScreenInfoForWindow(0, results); | 3208 GetScreenInfoForWindow(0, results); |
3230 } | 3209 } |
3231 | 3210 |
3232 } // namespace content | 3211 } // namespace content |
OLD | NEW |