diff options
Diffstat (limited to 'ui/views/widget')
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 21 | ||||
-rw-r--r-- | ui/views/widget/native_widget_aura.h | 5 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/native_widget_win.h | 2 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/widget.h | 4 |
6 files changed, 29 insertions, 15 deletions
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index b169f74..76761ec 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -149,6 +149,7 @@ NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), can_activate_(true), + destroying_(false), cursor_(gfx::kNullCursor), saved_window_state_(ui::SHOW_STATE_DEFAULT) { } @@ -700,17 +701,26 @@ void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds, delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); } -void NativeWidgetAura::OnFocus() { +void NativeWidgetAura::OnFocus(aura::Window* old_focused_window) { // In aura, it is possible for child native widgets to take input and focus, // this differs from the behavior on windows. GetWidget()->GetInputMethod()->OnFocus(); - delegate_->OnNativeFocus(window_); + delegate_->OnNativeFocus(old_focused_window); } void NativeWidgetAura::OnBlur() { - // Not only top level native widget can take input and focus, child - // widgets are allowed also. - GetWidget()->GetInputMethod()->OnBlur(); + // GetInputMethod() recreates the input method if it's previously been + // destroyed. If we get called during destruction, the input method will be + // gone, and creating a new one and telling it that we lost the focus will + // trigger a DCHECK (the new input method doesn't think that we have the focus + // and doesn't expect a blur). OnBlur() shouldn't be called during + // destruction unless WIDGET_OWNS_NATIVE_WIDGET is set (which is just the case + // in tests). + if (!destroying_) + GetWidget()->GetInputMethod()->OnBlur(); + else + DCHECK_EQ(ownership_, Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET); + delegate_->OnNativeBlur(window_->GetFocusManager()->GetFocusedWindow()); } @@ -902,6 +912,7 @@ int NativeWidgetAura::OnPerformDrop(const aura::DropTargetEvent& event) { // NativeWidgetAura, protected: NativeWidgetAura::~NativeWidgetAura() { + destroying_ = true; if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) delete delegate_; else diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 57dbe27..f4c177f 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -131,7 +131,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, virtual gfx::Size GetMinimumSize() const OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE; - virtual void OnFocus() OVERRIDE; + virtual void OnFocus(aura::Window* old_focused_window) OVERRIDE; virtual void OnBlur() OVERRIDE; virtual bool OnKeyEvent(aura::KeyEvent* event) OVERRIDE; virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; @@ -189,6 +189,9 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, // Can we be made active? bool can_activate_; + // Are we in the destructor? + bool destroying_; + gfx::NativeCursor cursor_; // The saved window state for exiting full screen state. diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 402d53f..2fcf057 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -2022,8 +2022,8 @@ LRESULT NativeWidgetWin::OnSetCursor(UINT message, return 0; } -void NativeWidgetWin::OnSetFocus(HWND focused_window) { - delegate_->OnNativeFocus(focused_window); +void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { + delegate_->OnNativeFocus(old_focused_window); InputMethod* input_method = GetWidget()->GetInputMethodDirect(); if (input_method) input_method->OnFocus(); diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h index 868c24b..b02b3b2 100644 --- a/ui/views/widget/native_widget_win.h +++ b/ui/views/widget/native_widget_win.h @@ -427,7 +427,7 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param); virtual LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); - virtual void OnSetFocus(HWND focused_window); + virtual void OnSetFocus(HWND old_focused_window); virtual LRESULT OnSetText(const wchar_t* text); virtual void OnSettingChange(UINT flags, const wchar_t* section); virtual void OnSize(UINT param, const CSize& size); diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 0bc0906..31748ed 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -941,14 +941,14 @@ void Widget::OnNativeWidgetActivationChanged(bool active) { OnWidgetActivationChanged(this, active)); } -void Widget::OnNativeFocus(gfx::NativeView focused_view) { - WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(focused_view, +void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { + WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, GetNativeView()); } -void Widget::OnNativeBlur(gfx::NativeView focused_view) { +void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(GetNativeView(), - focused_view); + new_focused_view); } void Widget::OnNativeWidgetVisibilityChanged(bool visible) { diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 92d1b28..9ee8792 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -630,8 +630,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, virtual bool IsInactiveRenderingDisabled() const OVERRIDE; virtual void EnableInactiveRendering() OVERRIDE; virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; - virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE; - virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE; + virtual void OnNativeFocus(gfx::NativeView old_focused_view) OVERRIDE; + virtual void OnNativeBlur(gfx::NativeView new_focused_view) OVERRIDE; virtual void OnNativeWidgetVisibilityChanged(bool visible) OVERRIDE; virtual void OnNativeWidgetCreated() OVERRIDE; virtual void OnNativeWidgetDestroying() OVERRIDE; |