diff --git a/ui/aura/remote_root_window_host_win.cc b/ui/aura/remote_root_window_host_win.cc index 57f633c3a85da..8e548364bbdec 100644 --- a/ui/aura/remote_root_window_host_win.cc +++ b/ui/aura/remote_root_window_host_win.cc @@ -157,8 +157,8 @@ bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_Character, OnChar) - IPC_MESSAGE_HANDLER(MetroViewerHostMsg_VisibilityChanged, - OnVisibilityChanged) + IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated, + OnWindowActivated) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchDown, OnTouchDown) IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchUp, @@ -471,9 +471,8 @@ void RemoteRootWindowHostWin::OnChar(uint32 key_code, scan_code, flags, true); } -void RemoteRootWindowHostWin::OnVisibilityChanged(bool visible) { - if (visible) - delegate_->OnHostActivated(); +void RemoteRootWindowHostWin::OnWindowActivated() { + delegate_->OnHostActivated(); } void RemoteRootWindowHostWin::OnTouchDown(int32 x, diff --git a/ui/aura/remote_root_window_host_win.h b/ui/aura/remote_root_window_host_win.h index dc716b37a624f..c4e238a3ebff6 100644 --- a/ui/aura/remote_root_window_host_win.h +++ b/ui/aura/remote_root_window_host_win.h @@ -154,7 +154,7 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { uint32 repeat_count, uint32 scan_code, uint32 flags); - void OnVisibilityChanged(bool visible); + void OnWindowActivated(); void OnTouchDown(int32 x, int32 y, uint64 timestamp, uint32 pointer_id); void OnTouchUp(int32 x, int32 y, uint64 timestamp, uint32 pointer_id); void OnTouchMoved(int32 x, int32 y, uint64 timestamp, uint32 pointer_id); diff --git a/ui/metro_viewer/metro_viewer_messages.h b/ui/metro_viewer/metro_viewer_messages.h index 7d0bd14f368ab..069436cd875b0 100644 --- a/ui/metro_viewer/metro_viewer_messages.h +++ b/ui/metro_viewer/metro_viewer_messages.h @@ -50,9 +50,8 @@ IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_Character, uint32, /* repeat count */ uint32, /* scan code */ uint32 /* key state */); -// Informs the browser that the visibiliy of the viewer has changed. -IPC_MESSAGE_CONTROL1(MetroViewerHostMsg_VisibilityChanged, - bool /* visible */); +// Informs the browser that the Metro window has been activated. +IPC_MESSAGE_CONTROL0(MetroViewerHostMsg_WindowActivated); IPC_MESSAGE_CONTROL4(MetroViewerHostMsg_TouchDown, int32, /* x-coordinate */ diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc index cffb0432638f5..b795b928bc2cc 100644 --- a/win8/metro_driver/chrome_app_view_ash.cc +++ b/win8/metro_driver/chrome_app_view_ash.cc @@ -48,10 +48,6 @@ typedef winfoundtn::ITypedEventHandler< winui::Core::CoreWindow*, winui::Core::CharacterReceivedEventArgs*> CharEventHandler; -typedef winfoundtn::ITypedEventHandler< - winui::Core::CoreWindow*, - winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler; - typedef winfoundtn::ITypedEventHandler< winui::Core::CoreWindow*, winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler; @@ -422,11 +418,6 @@ ChromeAppViewAsh::SetWindow(winui::Core::ICoreWindow* window) { &character_received_token_); CheckHR(hr); - hr = window_->add_VisibilityChanged(mswr::Callback<VisibilityChangedHandler>( - this, &ChromeAppViewAsh::OnVisibilityChanged).Get(), - &visibility_changed_token_); - CheckHR(hr); - hr = window_->add_Activated(mswr::Callback<WindowActivatedHandler>( this, &ChromeAppViewAsh::OnWindowActivated).Get(), &window_activated_token_); @@ -880,18 +871,6 @@ HRESULT ChromeAppViewAsh::OnCharacterReceived( return S_OK; } -HRESULT ChromeAppViewAsh::OnVisibilityChanged( - winui::Core::ICoreWindow* sender, - winui::Core::IVisibilityChangedEventArgs* args) { - boolean visible = false; - HRESULT hr = args->get_Visible(&visible); - if (FAILED(hr)) - return hr; - - ui_channel_->Send(new MetroViewerHostMsg_VisibilityChanged(!!visible)); - return S_OK; -} - HRESULT ChromeAppViewAsh::OnWindowActivated( winui::Core::ICoreWindow* sender, winui::Core::IWindowActivatedEventArgs* args) { @@ -899,6 +878,14 @@ HRESULT ChromeAppViewAsh::OnWindowActivated( HRESULT hr = args->get_WindowActivationState(&state); if (FAILED(hr)) return hr; + + // Treat both full activation (Ash was reopened from the Start Screen or from + // any other Metro entry point in Windows) and pointer activation (user + // clicked back in Ash after using another app on another monitor) the same. + if (state == winui::Core::CoreWindowActivationState_CodeActivated || + state == winui::Core::CoreWindowActivationState_PointerActivated) { + ui_channel_->Send(new MetroViewerHostMsg_WindowActivated()); + } return S_OK; } diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h index c1b95331a054b..0f9a14a4c9355 100644 --- a/win8/metro_driver/chrome_app_view_ash.h +++ b/win8/metro_driver/chrome_app_view_ash.h @@ -110,9 +110,6 @@ class ChromeAppViewAsh HRESULT OnCharacterReceived(winui::Core::ICoreWindow* sender, winui::Core::ICharacterReceivedEventArgs* args); - HRESULT OnVisibilityChanged(winui::Core::ICoreWindow* sender, - winui::Core::IVisibilityChangedEventArgs* args); - HRESULT OnWindowActivated(winui::Core::ICoreWindow* sender, winui::Core::IWindowActivatedEventArgs* args); @@ -139,7 +136,6 @@ class ChromeAppViewAsh EventRegistrationToken keydown_token_; EventRegistrationToken keyup_token_; EventRegistrationToken character_received_token_; - EventRegistrationToken visibility_changed_token_; EventRegistrationToken accel_keydown_token_; EventRegistrationToken accel_keyup_token_; EventRegistrationToken window_activated_token_;