Commit da309492 authored by ckocagil@chromium.org's avatar ckocagil@chromium.org

Revert of Store and restore view focus in OnWindowFocused....

Revert of Store and restore view focus in OnWindowFocused. (https://codereview.chromium.org/282223002/)

Reason for revert:
ConstrainedWindowViewTest.ClosesOnEscape introduced in this patch fails on XP: http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%281%29/builds/31239/steps/interactive_ui_tests/logs/stdio

Original issue's description:
> Store and restore view focus in OnWindowFocused.
> 
> Mimic [Desktop]NativeWidgetAura::OnWindowActivated.
> Simplify OnNativeBlur calls and OnNative[Blur|Focus] impls.
> (View focus changes update the TextInputClient as needed)
> Rewrite and enable related ConstrainedWindowViewTests.
> 
> Print GetLastError() in SendInput() error case for tests.
> (key presses get 5/ERROR_ACCESS_DENIED on locked desktops?)
> 
> BUG=368691,170331,177482,163931
> TEST=Automated tests; the focused Views change as expected between the browser, web contents, and web content modal dialogs (print preview, collected cookies, etc.).
> R=sky@chromium.org
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=271249

TBR=sky@chromium.org,msw@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=368691,170331,177482,163931

Review URL: https://codereview.chromium.org/289283003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271281 0039d316-1c4b-4281-b951-d872f2087c98
parent 46ac5d19
......@@ -43,7 +43,7 @@ HRESULT ForegroundHelper::ForegroundHotKey(HWND window) {
hotkey.type = INPUT_KEYBOARD;
hotkey.ki.wVk = VK_F22;
if (1 != SendInput(1, &hotkey, sizeof(hotkey))) {
LOG(WARNING) << "Failed to send input; GetLastError(): " << GetLastError();
LOG(WARNING) << "Failed to send input";
return E_FAIL;
}
......
......@@ -258,7 +258,6 @@ DesktopNativeWidgetAura::DesktopNativeWidgetAura(
native_widget_delegate_(delegate),
last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
restore_focus_on_activate_(false),
restore_focus_on_window_focus_(false),
cursor_(gfx::kNullCursor),
widget_type_(Widget::InitParams::TYPE_WINDOW) {
aura::client::SetFocusChangeObserver(content_window_, this);
......@@ -1083,23 +1082,15 @@ void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
native_widget_delegate_->OnNativeFocus(lost_focus);
// If focus is moving from a descendant Window to |content_window_| then
// native activation hasn't changed. Still, the InputMethod and FocusManager
// must be informed of the Window focus change.
// native activation hasn't changed. We still need to inform the InputMethod
// we've been focused though.
InputMethod* input_method = GetWidget()->GetInputMethod();
if (input_method)
input_method->OnFocus();
if (restore_focus_on_window_focus_) {
restore_focus_on_window_focus_ = false;
GetWidget()->GetFocusManager()->RestoreFocusedView();
}
} else if (content_window_ == lost_focus) {
desktop_window_tree_host_->OnNativeWidgetBlur();
native_widget_delegate_->OnNativeBlur(gained_focus);
DCHECK(!restore_focus_on_window_focus_);
restore_focus_on_window_focus_ = true;
GetWidget()->GetFocusManager()->StoreFocusedView(false);
native_widget_delegate_->OnNativeBlur(
aura::client::GetFocusClient(content_window_)->GetFocusedWindow());
}
}
......
......@@ -294,7 +294,6 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
window_modality_controller_;
bool restore_focus_on_activate_;
bool restore_focus_on_window_focus_;
gfx::NativeCursor cursor_;
// We must manually reference count the number of users of |cursor_manager_|
......
......@@ -895,7 +895,6 @@ void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
if (GetWidget()->GetInputMethod()) // Null in tests.
GetWidget()->GetInputMethod()->OnFocus();
delegate_->OnNativeFocus(lost_focus);
GetWidget()->GetFocusManager()->RestoreFocusedView();
} else if (window_ == lost_focus) {
// GetInputMethod() recreates the input method if it's previously been
// destroyed. If we get called during destruction, the input method will be
......@@ -911,8 +910,9 @@ void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET);
}
delegate_->OnNativeBlur(gained_focus);
GetWidget()->GetFocusManager()->StoreFocusedView(true);
aura::client::FocusClient* client = aura::client::GetFocusClient(window_);
if (client) // NULL during destruction of aura::Window.
delegate_->OnNativeBlur(client->GetFocusedWindow());
}
}
......
......@@ -1045,11 +1045,19 @@ void Widget::OnNativeWidgetActivationChanged(bool active) {
}
void Widget::OnNativeFocus(gfx::NativeView old_focused_view) {
// Ensure the focused view's TextInputClient is used for text input.
views::FocusManager* focus_manager = GetFocusManager();
focus_manager->FocusTextInputClient(focus_manager->GetFocusedView());
WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view,
GetNativeView());
}
void Widget::OnNativeBlur(gfx::NativeView new_focused_view) {
// Ensure the focused view's TextInputClient is not used for text input.
views::FocusManager* focus_manager = GetFocusManager();
focus_manager->BlurTextInputClient(focus_manager->GetFocusedView());
WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(GetNativeView(),
new_focused_view);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment