diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 12:57:25 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 12:57:25 +0000 |
commit | 0a02eabbfbfdc4de544bfa861e0f639911e3e8c6 (patch) | |
tree | e89a689b72dc8a49a2846db768b7389a8715afb6 | |
parent | 95471194b8a58d9a9f0ea25160fa16f2b6b646aa (diff) | |
download | chromium_src-0a02eabbfbfdc4de544bfa861e0f639911e3e8c6.zip chromium_src-0a02eabbfbfdc4de544bfa861e0f639911e3e8c6.tar.gz chromium_src-0a02eabbfbfdc4de544bfa861e0f639911e3e8c6.tar.bz2 |
Fix Ash on Windows multi-monitor support and snap-view sizing.
Plumb through window size events to the remote root window host.
Also add an initial sizing message to get Ash's initial state to be correct.
BUG=236379
TEST=Move Ash from one monitor to another with a different size, observe that things resize themselves correctly. Also, snap Ash, observe similar goodness.
Review URL: https://chromiumcodereview.appspot.com/15599002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201771 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/aura/remote_root_window_host_win.cc | 6 | ||||
-rw-r--r-- | ui/aura/remote_root_window_host_win.h | 2 | ||||
-rw-r--r-- | ui/metro_viewer/metro_viewer_messages.h | 6 | ||||
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.cc | 36 | ||||
-rw-r--r-- | win8/metro_driver/chrome_app_view_ash.h | 4 |
5 files changed, 54 insertions, 0 deletions
diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc index d6b72df..3601ea2 100644 --- a/ui/aura/remote_root_window_host_win.cc +++ b/ui/aura/remote_root_window_host_win.cc @@ -161,6 +161,8 @@ bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) { OnWindowActivated) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_SetCursorPosAck, OnSetCursorPosAck) + IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowSizeChanged, + OnWindowSizeChanged) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -502,6 +504,10 @@ void RemoteRootWindowHostWin::OnSetCursorPosAck() { ignore_mouse_moves_until_set_cursor_ack_ = false; } +void RemoteRootWindowHostWin::OnWindowSizeChanged(uint32 width, uint32 height) { + SetBounds(gfx::Rect(0, 0, width, height)); +} + void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type, uint32 vkey, uint32 repeat_count, diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h index 0577ee7..bf30629 100644 --- a/ui/aura/remote_root_window_host_win.h +++ b/ui/aura/remote_root_window_host_win.h @@ -149,6 +149,8 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { void OnSelectFolderDone(bool success, const base::FilePath& folder); void OnWindowActivated(bool active); void OnSetCursorPosAck(); + void OnWindowSizeChanged(uint32 width, uint32 height); + // RootWindowHost overrides: virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; virtual RootWindow* GetRootWindow() OVERRIDE; diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h index f301618..8d0d452 100644 --- a/ui/metro_viewer/metro_viewer_messages.h +++ b/ui/metro_viewer/metro_viewer_messages.h @@ -145,3 +145,9 @@ IPC_MESSAGE_CONTROL2(MetroViewerHostMsg_SetCursorPos, // Ack sent by the viewer process indicating that the SetCursorPos operation // was completed. IPC_MESSAGE_CONTROL0(MetroViewerHostMsg_SetCursorPosAck) + +// Sent from the metro viewer process to the browser process to indicate that +// the viewer window size has changed. +IPC_MESSAGE_CONTROL2(MetroViewerHostMsg_WindowSizeChanged, + uint32, /* width */ + uint32) /* height */ diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index f3a3a88..1f81ed3 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); @@ -326,6 +330,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>( @@ -448,6 +457,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(); @@ -830,6 +847,25 @@ 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; + HRESULT hr = args->get_Size(&size); + if (FAILED(hr)) + return hr; + + uint32 cx = static_cast<uint32>(size.Width); + uint32 cy = static_cast<uint32>(size.Height); + + DVLOG(1) << "Window size changed: width=" << cx << ", height=" << cy; + ui_channel_->Send(new MetroViewerHostMsg_WindowSizeChanged(cx, cy)); + return S_OK; +} + /////////////////////////////////////////////////////////////////////////////// diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h index 0989cda..010f0d6 100644 --- a/win8/metro_driver/chrome_app_view_ash.h +++ b/win8/metro_driver/chrome_app_view_ash.h @@ -111,6 +111,9 @@ class ChromeAppViewAsh HRESULT OnWindowActivated(winui::Core::ICoreWindow* sender, winui::Core::IWindowActivatedEventArgs* args); + HRESULT OnSizeChanged(winui::Core::ICoreWindow* sender, + winui::Core::IWindowSizeChangedEventArgs* args); + mswr::ComPtr<winui::Core::ICoreWindow> window_; mswr::ComPtr<winapp::Core::ICoreApplicationView> view_; EventRegistrationToken activated_token_; @@ -125,6 +128,7 @@ class ChromeAppViewAsh EventRegistrationToken accel_keydown_token_; EventRegistrationToken accel_keyup_token_; EventRegistrationToken window_activated_token_; + EventRegistrationToken sizechange_token_; // Keep state about which button is currently down, if any, as PointerMoved // events do not contain that state, but Ash's MouseEvents need it. |