Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: ui/views/widget/widget.cc

Issue 294023002: aura: Updates the text input client when native activation changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 void Widget::OnNativeWidgetActivationChanged(bool active) { 1033 void Widget::OnNativeWidgetActivationChanged(bool active) {
1034 // On windows we may end up here before we've completed initialization (from 1034 // On windows we may end up here before we've completed initialization (from
1035 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know 1035 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know
1036 // the Widget and will crash attempting to access it. 1036 // the Widget and will crash attempting to access it.
1037 if (!active && native_widget_initialized_) 1037 if (!active && native_widget_initialized_)
1038 SaveWindowPlacement(); 1038 SaveWindowPlacement();
1039 1039
1040 FOR_EACH_OBSERVER(WidgetObserver, observers_, 1040 FOR_EACH_OBSERVER(WidgetObserver, observers_,
1041 OnWidgetActivationChanged(this, active)); 1041 OnWidgetActivationChanged(this, active));
1042 1042
1043 // With typical windowing systems, the order of activate/deactivate,
1044 // focus/blur is the following.
1045 // 1. Activate
1046 // 2. Focus
1047 // 3. Blur
1048 // 4. Deactivate
1049 //
1050 // For Aura, the order of calls to OnNativeFocus, OnNativeBlur and
1051 // OnNativeWidgetActivationChanged is a little confusing. At the time of
msw 2014/05/20 17:08:07 NativeWidgetAura::OnWindowActivated calls this fun
Yuki 2014/05/21 14:36:51 The issue is happening on Win, Linux and CrOS as I
msw 2014/05/22 04:53:01 Okay, then you can ignore my question, but the lon
Yuki 2014/05/26 14:26:43 Done.
1052 // window creation, the order is as follows.
1053 // 1. DesktopNativeWidgetAura::InitNativeWidget()
1054 // 2. FocusClient::FocusWindow()
1055 // This call is made during the window initialization so that the focused
1056 // window never be null.
1057 // 3. Widget::OnNativeFocus()
1058 // Note that OnNativeFocus() is called at step 3 before
1059 // OnNativeWidgetActivationChanged(true) is called. OnNativeFocus() is called
1060 // before it gets activated.
1061 //
1062 // Once the window creation finished and the native widget gets activated,
1063 // the following methods are called.
1064 // 4. DesktopNativeWidgetAura::HandleActivationChanged()
1065 // 5. Widget::OnNativeWidgetActivationChanged(true)
1066 // Note that OnNativeFocus() is not called this time because it's already been
1067 // focused.
1068 //
1069 // For this reason, thre is a case that the active focused view has just
1070 // changed but OnNativeFocus() will not be called later. So we update the
1071 // focused text input here in addition to OnNativeFocus and OnNativeBlur.
msw 2014/05/20 17:08:07 nit: This comment is no longer accurate. I removed
Yuki 2014/05/26 14:26:43 Done.
1072 views::FocusManager* focus_manager = GetFocusManager();
sky 2014/05/20 13:47:15 Your comments make me thing it would be better to
Yuki 2014/05/20 13:54:55 FocusTextInputClient() requires the widget to be a
1073 if (focus_manager) {
1074 if (active)
1075 focus_manager->FocusTextInputClient(focus_manager->GetFocusedView());
1076 else
1077 focus_manager->BlurTextInputClient(focus_manager->GetFocusedView());
msw 2014/05/22 04:53:01 Is this actually needed to fix the issue? Perhaps
Yuki 2014/05/22 14:02:11 This is just for parity and completeness.
1078 }
1079
1043 if (IsVisible() && non_client_view()) 1080 if (IsVisible() && non_client_view())
1044 non_client_view()->frame_view()->SchedulePaint(); 1081 non_client_view()->frame_view()->SchedulePaint();
1045 } 1082 }
1046 1083
1047 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { 1084 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) {
1048 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, 1085 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view,
1049 GetNativeView()); 1086 GetNativeView());
1050 } 1087 }
1051 1088
1052 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { 1089 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 1551
1515 //////////////////////////////////////////////////////////////////////////////// 1552 ////////////////////////////////////////////////////////////////////////////////
1516 // internal::NativeWidgetPrivate, NativeWidget implementation: 1553 // internal::NativeWidgetPrivate, NativeWidget implementation:
1517 1554
1518 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1555 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1519 return this; 1556 return this;
1520 } 1557 }
1521 1558
1522 } // namespace internal 1559 } // namespace internal
1523 } // namespace views 1560 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698