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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 23769011: Move a bunch of windows stuff from ui/base/win to ui/gfx/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bustage. Created 7 years, 3 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
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 "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 <InputScope.h> 7 #include <InputScope.h>
8 #include <wtsapi32.h> 8 #include <wtsapi32.h>
9 #pragma comment(lib, "wtsapi32.lib") 9 #pragma comment(lib, "wtsapi32.lib")
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "ui/base/events/event.h" 60 #include "ui/base/events/event.h"
61 #include "ui/base/events/event_utils.h" 61 #include "ui/base/events/event_utils.h"
62 #include "ui/base/ime/composition_text.h" 62 #include "ui/base/ime/composition_text.h"
63 #include "ui/base/ime/win/imm32_manager.h" 63 #include "ui/base/ime/win/imm32_manager.h"
64 #include "ui/base/ime/win/tsf_input_scope.h" 64 #include "ui/base/ime/win/tsf_input_scope.h"
65 #include "ui/base/l10n/l10n_util_win.h" 65 #include "ui/base/l10n/l10n_util_win.h"
66 #include "ui/base/touch/touch_device.h" 66 #include "ui/base/touch/touch_device.h"
67 #include "ui/base/touch/touch_enabled.h" 67 #include "ui/base/touch/touch_enabled.h"
68 #include "ui/base/ui_base_switches.h" 68 #include "ui/base/ui_base_switches.h"
69 #include "ui/base/view_prop.h" 69 #include "ui/base/view_prop.h"
70 #include "ui/base/win/hwnd_util.h"
71 #include "ui/base/win/mouse_wheel_util.h" 70 #include "ui/base/win/mouse_wheel_util.h"
72 #include "ui/base/win/touch_input.h" 71 #include "ui/base/win/touch_input.h"
73 #include "ui/gfx/canvas.h" 72 #include "ui/gfx/canvas.h"
74 #include "ui/gfx/dpi_win.h"
75 #include "ui/gfx/rect.h" 73 #include "ui/gfx/rect.h"
76 #include "ui/gfx/rect_conversions.h" 74 #include "ui/gfx/rect_conversions.h"
77 #include "ui/gfx/screen.h" 75 #include "ui/gfx/screen.h"
78 #include "ui/gfx/text_elider.h" 76 #include "ui/gfx/text_elider.h"
77 #include "ui/gfx/win/dpi.h"
78 #include "ui/gfx/win/hwnd_util.h"
79 #include "webkit/common/cursors/webcursor.h" 79 #include "webkit/common/cursors/webcursor.h"
80 #include "win8/util/win8_util.h" 80 #include "win8/util/win8_util.h"
81 81
82 using base::TimeDelta; 82 using base::TimeDelta;
83 using base::TimeTicks; 83 using base::TimeTicks;
84 using ui::ViewProp; 84 using ui::ViewProp;
85 using WebKit::WebInputEvent; 85 using WebKit::WebInputEvent;
86 using WebKit::WebMouseEvent; 86 using WebKit::WebMouseEvent;
87 using WebKit::WebTextDirection; 87 using WebKit::WebTextDirection;
88 88
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 close_on_deactivate_ = true; 444 close_on_deactivate_ = true;
445 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos, 445 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos,
446 WS_EX_TOOLWINDOW); 446 WS_EX_TOOLWINDOW);
447 } 447 }
448 448
449 void RenderWidgetHostViewWin::InitAsFullscreen( 449 void RenderWidgetHostViewWin::InitAsFullscreen(
450 RenderWidgetHostView* reference_host_view) { 450 RenderWidgetHostView* reference_host_view) {
451 gfx::Rect pos = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow( 451 gfx::Rect pos = gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(
452 reference_host_view->GetNativeView()).bounds(); 452 reference_host_view->GetNativeView()).bounds();
453 is_fullscreen_ = true; 453 is_fullscreen_ = true;
454 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0); 454 DoPopupOrFullscreenInit(gfx::GetWindowToParentTo(true), pos, 0);
455 } 455 }
456 456
457 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { 457 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const {
458 return render_widget_host_; 458 return render_widget_host_;
459 } 459 }
460 460
461 void RenderWidgetHostViewWin::WasShown() { 461 void RenderWidgetHostViewWin::WasShown() {
462 if (!is_hidden_) 462 if (!is_hidden_)
463 return; 463 return;
464 464
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 static BOOL CALLBACK AddChildWindowToVector(HWND hwnd, LPARAM lparam) { 568 static BOOL CALLBACK AddChildWindowToVector(HWND hwnd, LPARAM lparam) {
569 std::vector<HWND>* vector = reinterpret_cast<std::vector<HWND>*>(lparam); 569 std::vector<HWND>* vector = reinterpret_cast<std::vector<HWND>*>(lparam);
570 vector->push_back(hwnd); 570 vector->push_back(hwnd);
571 return TRUE; 571 return TRUE;
572 } 572 }
573 573
574 void RenderWidgetHostViewWin::CleanupCompositorWindow() { 574 void RenderWidgetHostViewWin::CleanupCompositorWindow() {
575 if (!compositor_host_window_) 575 if (!compositor_host_window_)
576 return; 576 return;
577 577
578 ui::SetWindowUserData(compositor_host_window_, NULL); 578 gfx::SetWindowUserData(compositor_host_window_, NULL);
579 579
580 // Hide the compositor and parent it to the desktop rather than destroying 580 // Hide the compositor and parent it to the desktop rather than destroying
581 // it immediately. The GPU process has a grace period to stop accessing the 581 // it immediately. The GPU process has a grace period to stop accessing the
582 // window. TODO(apatrick): the GPU process should acknowledge that it has 582 // window. TODO(apatrick): the GPU process should acknowledge that it has
583 // finished with the window handle and the browser process should destroy it 583 // finished with the window handle and the browser process should destroy it
584 // at that point. 584 // at that point.
585 ::ShowWindow(compositor_host_window_, SW_HIDE); 585 ::ShowWindow(compositor_host_window_, SW_HIDE);
586 ::SetParent(compositor_host_window_, NULL); 586 ::SetParent(compositor_host_window_, NULL);
587 587
588 BrowserThread::PostDelayedTask( 588 BrowserThread::PostDelayedTask(
(...skipping 30 matching lines...) Expand all
619 else 619 else
620 return !!render_widget_host_->GetBackingStore(false); 620 return !!render_widget_host_->GetBackingStore(false);
621 } 621 }
622 622
623 void RenderWidgetHostViewWin::Show() { 623 void RenderWidgetHostViewWin::Show() {
624 ShowWindow(SW_SHOW); 624 ShowWindow(SW_SHOW);
625 WasShown(); 625 WasShown();
626 } 626 }
627 627
628 void RenderWidgetHostViewWin::Hide() { 628 void RenderWidgetHostViewWin::Hide() {
629 if (!is_fullscreen_ && GetParent() == ui::GetWindowToParentTo(true)) { 629 if (!is_fullscreen_ && GetParent() == gfx::GetWindowToParentTo(true)) {
630 LOG(WARNING) << "Hide() called twice in a row: " << this << ":" 630 LOG(WARNING) << "Hide() called twice in a row: " << this << ":"
631 << GetParent(); 631 << GetParent();
632 return; 632 return;
633 } 633 }
634 634
635 if (::GetFocus() == m_hWnd) 635 if (::GetFocus() == m_hWnd)
636 ::SetFocus(NULL); 636 ::SetFocus(NULL);
637 ShowWindow(SW_HIDE); 637 ShowWindow(SW_HIDE);
638 638
639 WasHidden(); 639 WasHidden();
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 // an event to the renderer which would then eventually send over 2311 // an event to the renderer which would then eventually send over
2312 // a setFocus call to the plugin widget. This would ensure that 2312 // a setFocus call to the plugin widget. This would ensure that
2313 // the renderer (webkit) knows about the plugin widget receiving 2313 // the renderer (webkit) knows about the plugin widget receiving
2314 // focus. 2314 // focus.
2315 // TODO(iyengar) Do the right thing as per the above comment. 2315 // TODO(iyengar) Do the right thing as per the above comment.
2316 POINT cursor_pos = {0}; 2316 POINT cursor_pos = {0};
2317 ::GetCursorPos(&cursor_pos); 2317 ::GetCursorPos(&cursor_pos);
2318 ::ScreenToClient(m_hWnd, &cursor_pos); 2318 ::ScreenToClient(m_hWnd, &cursor_pos);
2319 HWND child_window = ::RealChildWindowFromPoint(m_hWnd, cursor_pos); 2319 HWND child_window = ::RealChildWindowFromPoint(m_hWnd, cursor_pos);
2320 if (::IsWindow(child_window) && child_window != m_hWnd) { 2320 if (::IsWindow(child_window) && child_window != m_hWnd) {
2321 if (ui::GetClassName(child_window) == kWrapperNativeWindowClassName) 2321 if (gfx::GetClassName(child_window) == kWrapperNativeWindowClassName)
2322 child_window = ::GetWindow(child_window, GW_CHILD); 2322 child_window = ::GetWindow(child_window, GW_CHILD);
2323 2323
2324 ::SetFocus(child_window); 2324 ::SetFocus(child_window);
2325 return MA_NOACTIVATE; 2325 return MA_NOACTIVATE;
2326 } 2326 }
2327 } 2327 }
2328 handled = FALSE; 2328 handled = FALSE;
2329 render_widget_host_->OnPointerEventActivate(); 2329 render_widget_host_->OnPointerEventActivate();
2330 return MA_ACTIVATE; 2330 return MA_ACTIVATE;
2331 } 2331 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 // clear the BrowserAccessibilityManager, because the renderer is 2457 // clear the BrowserAccessibilityManager, because the renderer is
2458 // dead and any accessibility information we have is now stale. 2458 // dead and any accessibility information we have is now stale.
2459 SetBrowserAccessibilityManager(NULL); 2459 SetBrowserAccessibilityManager(NULL);
2460 } 2460 }
2461 2461
2462 static void PaintCompositorHostWindow(HWND hWnd) { 2462 static void PaintCompositorHostWindow(HWND hWnd) {
2463 PAINTSTRUCT paint; 2463 PAINTSTRUCT paint;
2464 BeginPaint(hWnd, &paint); 2464 BeginPaint(hWnd, &paint);
2465 2465
2466 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( 2466 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>(
2467 ui::GetWindowUserData(hWnd)); 2467 gfx::GetWindowUserData(hWnd));
2468 // Trigger composite to rerender window. 2468 // Trigger composite to rerender window.
2469 if (win) 2469 if (win)
2470 win->AcceleratedPaint(paint.hdc); 2470 win->AcceleratedPaint(paint.hdc);
2471 2471
2472 EndPaint(hWnd, &paint); 2472 EndPaint(hWnd, &paint);
2473 } 2473 }
2474 2474
2475 // WndProc for the compositor host window. We use this instead of Default so 2475 // WndProc for the compositor host window. We use this instead of Default so
2476 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor. 2476 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor.
2477 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, 2477 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 int width = std::max(1, 2556 int width = std::max(1,
2557 static_cast<int>(currentRect.right - currentRect.left)); 2557 static_cast<int>(currentRect.right - currentRect.left));
2558 int height = std::max(1, 2558 int height = std::max(1,
2559 static_cast<int>(currentRect.bottom - currentRect.top)); 2559 static_cast<int>(currentRect.bottom - currentRect.top));
2560 2560
2561 compositor_host_window_ = CreateWindowEx( 2561 compositor_host_window_ = CreateWindowEx(
2562 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, 2562 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
2563 MAKEINTATOM(atom), 0, 2563 MAKEINTATOM(atom), 0,
2564 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, 2564 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED,
2565 0, 0, width, height, m_hWnd, 0, instance, 0); 2565 0, 0, width, height, m_hWnd, 0, instance, 0);
2566 ui::CheckWindowCreated(compositor_host_window_); 2566 gfx::CheckWindowCreated(compositor_host_window_);
2567 2567
2568 ui::SetWindowUserData(compositor_host_window_, this); 2568 gfx::SetWindowUserData(compositor_host_window_, this);
2569 2569
2570 gfx::GLSurfaceHandle surface_handle(compositor_host_window_, 2570 gfx::GLSurfaceHandle surface_handle(compositor_host_window_,
2571 gfx::NATIVE_TRANSPORT); 2571 gfx::NATIVE_TRANSPORT);
2572 return surface_handle; 2572 return surface_handle;
2573 } 2573 }
2574 2574
2575 void RenderWidgetHostViewWin::OnAcceleratedCompositingStateChange() { 2575 void RenderWidgetHostViewWin::OnAcceleratedCompositingStateChange() {
2576 bool show = render_widget_host_->is_accelerated_compositing_active(); 2576 bool show = render_widget_host_->is_accelerated_compositing_active();
2577 // When we first create the compositor, we will get a show request from 2577 // When we first create the compositor, we will get a show request from
2578 // the renderer before we have gotten the create request from the GPU. In this 2578 // the renderer before we have gotten the create request from the GPU. In this
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
3199 return new RenderWidgetHostViewWin(widget); 3199 return new RenderWidgetHostViewWin(widget);
3200 } 3200 }
3201 3201
3202 // static 3202 // static
3203 void RenderWidgetHostViewPort::GetDefaultScreenInfo( 3203 void RenderWidgetHostViewPort::GetDefaultScreenInfo(
3204 WebKit::WebScreenInfo* results) { 3204 WebKit::WebScreenInfo* results) {
3205 GetScreenInfoForWindow(0, results); 3205 GetScreenInfoForWindow(0, results);
3206 } 3206 }
3207 3207
3208 } // namespace content 3208 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698