summaryrefslogtreecommitdiffstats
path: root/win8/metro_driver
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 15:08:11 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-18 15:08:11 +0000
commitd3834bb7bfd48ba176c179dd95b57f9998caadbc (patch)
tree136f7fbda69b8b29b0e07ca8e67671daa181b564 /win8/metro_driver
parent2e31ca2b895e86cd568b4dc7b32c68ea156e449e (diff)
downloadchromium_src-d3834bb7bfd48ba176c179dd95b57f9998caadbc.zip
chromium_src-d3834bb7bfd48ba176c179dd95b57f9998caadbc.tar.gz
chromium_src-d3834bb7bfd48ba176c179dd95b57f9998caadbc.tar.bz2
Use WindowActivated message instead of VisibilityChanged message to determine that Ash is the active desktop on Win8.
This is better than the VisibilityChanged event as it also handles the dual monitor case where Ash isn't hidden yet is no longer active (and Chrome desktop window can thus steal the "active desktop" state which was then not given back to the Ash desktop when re-focusing it. The WindowActivated event gets a CoreWindowActivationState_PointerActivated state for this specific case; which we treat the same as CoreWindowActivationState_CodeActivated for now. Also remove the hooks for VisibilityChanged as they were only used for this purpose, i.e.: https://code.google.com/p/chromium/codesearch#search/&q=OnRootWindowActivated&sq=package:chromium&type=cs Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/env.cc&l=83 Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/root_window.cc&l=988 Called from: https://code.google.com/p/chromium/codesearch#chromium/src/ui/aura/remote_root_window_host_win.cc&l=463 BUG=177489 TEST= The most reliable test I could find that would repro this is to: 1) Open Ash 2) Open Chrome on desktop on a 2nd monitor 3) Refocus Ash on first monitor 4) Signin with an account which will sync extensions (at least one of which opens a tab on install, e.g., https://chrome.google.com/webstore/detail/reload-all-tabs/midkcinmplflbiflboepnahkboeonkam). Without this CL, this will result in the extension's tab opening on the desktop Chrome's window. With this CL, the tab correctly opens in Ash as it was the last desktop focused. Also make sure the regular use cases still work using the same test under: A) Only Ash open B) Ash open, but active desktop is native desktop. Also confirmed using Sawbuck and some logging that the following is how OnWindowActivated() reports its state: CoreWindowActivationState_CodeActivated == 0 - First activation - Activated when hidden (either from Start Screen or Windows app switcher while viewing another app). CoreWindowActivationState_Deactivated == 1 - All deactivations (including focusing a desktop app on the 2nd monitor while Ash remains open on 1st monitor) CoreWindowActivationState_PointerActivated - Ash is focused again after a window on another monitor had been focused while Ash stayed visible on its monitor. R=cdn@chromium.org, grt@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/27058004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8/metro_driver')
-rw-r--r--win8/metro_driver/chrome_app_view_ash.cc29
-rw-r--r--win8/metro_driver/chrome_app_view_ash.h4
2 files changed, 8 insertions, 25 deletions
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc
index cffb043..b795b92 100644
--- a/win8/metro_driver/chrome_app_view_ash.cc
+++ b/win8/metro_driver/chrome_app_view_ash.cc
@@ -50,10 +50,6 @@ typedef winfoundtn::ITypedEventHandler<
typedef winfoundtn::ITypedEventHandler<
winui::Core::CoreWindow*,
- winui::Core::VisibilityChangedEventArgs*> VisibilityChangedHandler;
-
-typedef winfoundtn::ITypedEventHandler<
- winui::Core::CoreWindow*,
winui::Core::WindowActivatedEventArgs*> WindowActivatedHandler;
typedef winfoundtn::ITypedEventHandler<
@@ -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 c1b9533..0f9a14a 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_;