Chromium Code Reviews| Index: win8/metro_driver/chrome_app_view_ash.cc |
| diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc |
| index d007a86d5e0384934bfbb9c42be7d4f2b38056ec..46aea7a3c081ec9b7e0b435b39acf00f2fce302b 100644 |
| --- a/win8/metro_driver/chrome_app_view_ash.cc |
| +++ b/win8/metro_driver/chrome_app_view_ash.cc |
| @@ -54,6 +54,10 @@ typedef winfoundtn::ITypedEventHandler< |
| winui::Core::CoreWindow*, |
| winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; |
| +typedef winfoundtn::ITypedEventHandler< |
| + winui::Core::CoreWindow*, |
| + winui::Core::WindowSizeChangedEventArgs*> SizeChangedHandler; |
| + |
| // This function is exported by chrome.exe. |
| typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info); |
| @@ -317,6 +321,11 @@ ChromeAppViewAsh::SetWindow(winui::Core::ICoreWindow* window) { |
| hr = interop->get_WindowHandle(&core_window_hwnd_); |
| CheckHR(hr); |
| + hr = window_->add_SizeChanged(mswr::Callback<SizeChangedHandler>( |
| + this, &ChromeAppViewAsh::OnSizeChanged).Get(), |
| + &sizechange_token_); |
| + CheckHR(hr); |
| + |
| // Register for pointer and keyboard notifications. We forward |
| // them to the browser process via IPC. |
| hr = window_->add_PointerMoved(mswr::Callback<PointerEventHandler>( |
| @@ -439,6 +448,14 @@ ChromeAppViewAsh::Run() { |
| gfx::NativeViewId(core_window_hwnd_))); |
| DVLOG(1) << "ICoreWindow sent " << core_window_hwnd_; |
| + // Send an initial size message so that the Ash root window host gets sized |
| + // correctly. |
| + RECT rect = {0}; |
| + ::GetWindowRect(core_window_hwnd_, &rect); |
| + ui_channel_->Send( |
| + new MetroViewerHostMsg_WindowSizeChanged(rect.right - rect.left, |
| + rect.bottom - rect.top)); |
| + |
| // And post the task that'll do the inner Metro message pumping to it. |
| msg_loop.PostTask(FROM_HERE, base::Bind(&RunMessageLoop, dispatcher.Get())); |
| msg_loop.Run(); |
| @@ -808,6 +825,23 @@ HRESULT ChromeAppViewAsh::OnWindowActivated( |
| return S_OK; |
| } |
| +HRESULT ChromeAppViewAsh::OnSizeChanged(winui::Core::ICoreWindow* sender, |
| + winui::Core::IWindowSizeChangedEventArgs* args) { |
| + if (!window_) { |
| + return S_OK; |
| + } |
| + |
| + winfoundtn::Size size; |
| + args->get_Size(&size); |
|
cpu_(ooo_6.6-7.5)
2013/05/21 20:36:12
check the error code of get_Size. I guess don't se
robertshield
2013/05/22 17:31:20
Done.
|
| + |
| + int32 cx = static_cast<int32>(size.Width); |
| + int32 cy = static_cast<int32>(size.Height); |
| + |
| + DVLOG(1) << "Window size changed: width=" << cx << ", height=" << cy; |
| + ui_channel_->Send(new MetroViewerHostMsg_WindowSizeChanged(cx, cy)); |
| + return S_OK; |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |