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

Side by Side Diff: ui/views/controls/native/native_view_host_win.cc

Issue 10832011: Makes NativeViewHostWin change the parent of the hwnd when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix focus issues Created 8 years, 4 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 | « ui/views/controls/native/native_view_host_win.h ('k') | ui/views/focus/focus_manager.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/controls/native/native_view_host_win.h" 5 #include "ui/views/controls/native/native_view_host_win.h"
6 6
7 #include <oleacc.h> 7 #include <oleacc.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/base/win/hidden_window.h"
11 #include "ui/base/win/window_impl.h"
10 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
11 #include "ui/views/controls/native/native_view_host.h" 13 #include "ui/views/controls/native/native_view_host.h"
12 #include "ui/views/focus/focus_manager.h" 14 #include "ui/views/focus/focus_manager.h"
13 #include "ui/views/widget/native_widget.h" 15 #include "ui/views/widget/native_widget.h"
14 #include "ui/views/widget/root_view.h" 16 #include "ui/views/widget/root_view.h"
15 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
16 18
17 namespace views { 19 namespace views {
18 20
19 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
(...skipping 16 matching lines...) Expand all
36 // First hide the new window. We don't want anything to draw (like sub-hwnd 38 // First hide the new window. We don't want anything to draw (like sub-hwnd
37 // borders), when we change the parent below. 39 // borders), when we change the parent below.
38 ShowWindow(host_->native_view(), SW_HIDE); 40 ShowWindow(host_->native_view(), SW_HIDE);
39 41
40 Widget::ReparentNativeView(host_->native_view(), 42 Widget::ReparentNativeView(host_->native_view(),
41 host_->GetWidget()->GetNativeView()); 43 host_->GetWidget()->GetNativeView());
42 host_->Layout(); 44 host_->Layout();
43 } 45 }
44 46
45 void NativeViewHostWin::NativeViewDetaching(bool destroyed) { 47 void NativeViewHostWin::NativeViewDetaching(bool destroyed) {
46 if (!destroyed && installed_clip_) 48 if (!destroyed) {
47 UninstallClip(); 49 if (installed_clip_)
50 UninstallClip();
51 ClearFocus();
52 SetParent(host_->native_view(), ui::GetHiddenWindow());
53 }
48 installed_clip_ = false; 54 installed_clip_ = false;
49 } 55 }
50 56
51 void NativeViewHostWin::AddedToWidget() { 57 void NativeViewHostWin::AddedToWidget() {
52 if (!IsWindow(host_->native_view())) 58 if (!IsWindow(host_->native_view()))
53 return; 59 return;
54 HWND parent_hwnd = GetParent(host_->native_view()); 60 HWND parent_hwnd = GetParent(host_->native_view());
55 HWND widget_hwnd = host_->GetWidget()->GetNativeView(); 61 HWND widget_hwnd = host_->GetWidget()->GetNativeView();
56 if (parent_hwnd != widget_hwnd) 62 if (parent_hwnd != widget_hwnd)
57 SetParent(host_->native_view(), widget_hwnd); 63 SetParent(host_->native_view(), widget_hwnd);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 hwnd, OBJID_CLIENT, IID_IAccessible, 141 hwnd, OBJID_CLIENT, IID_IAccessible,
136 reinterpret_cast<void**>(&accessible)); 142 reinterpret_cast<void**>(&accessible));
137 143
138 if (success == S_OK) { 144 if (success == S_OK) {
139 return accessible; 145 return accessible;
140 } else { 146 } else {
141 return NULL; 147 return NULL;
142 } 148 }
143 } 149 }
144 150
151 void NativeViewHostWin::ClearFocus() {
152 FocusManager* focus_manager = host_->GetFocusManager();
153 if (!focus_manager || !focus_manager->GetFocusedView())
154 return;
155
156 Widget::Widgets widgets;
157 Widget::GetAllChildWidgets(host_->native_view(), &widgets);
158 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) {
159 focus_manager->ViewRemoved((*i)->GetRootView());
160 if (!focus_manager->GetFocusedView())
161 return;
162 }
163 }
164
145 //////////////////////////////////////////////////////////////////////////////// 165 ////////////////////////////////////////////////////////////////////////////////
146 // NativeViewHostWrapper, public: 166 // NativeViewHostWrapper, public:
147 167
148 // static 168 // static
149 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( 169 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
150 NativeViewHost* host) { 170 NativeViewHost* host) {
151 return new NativeViewHostWin(host); 171 return new NativeViewHostWin(host);
152 } 172 }
153 173
154 } // namespace views 174 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host_win.h ('k') | ui/views/focus/focus_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698