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

Side by Side Diff: views/controls/native/native_view_host_gtk.cc

Issue 231022: Reverting 27113. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "views/controls/native/native_view_host_gtk.h" 5 #include "views/controls/native/native_view_host_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 else 41 else
42 gtk_container_add(GTK_CONTAINER(fixed_), host_->native_view()); 42 gtk_container_add(GTK_CONTAINER(fixed_), host_->native_view());
43 43
44 if (!destroy_signal_id_) { 44 if (!destroy_signal_id_) {
45 destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()), 45 destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()),
46 "destroy", G_CALLBACK(CallDestroy), 46 "destroy", G_CALLBACK(CallDestroy),
47 this); 47 this);
48 } 48 }
49 49
50 if (!focus_signal_id_) { 50 if (!focus_signal_id_) {
51 focus_signal_id_ = g_signal_connect(G_OBJECT(host_->focus_native_view()), 51 focus_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()),
52 "focus-in-event", 52 "focus-in-event",
53 G_CALLBACK(CallFocusIn), this); 53 G_CALLBACK(CallFocusIn), this);
54 } 54 }
55 55
56 // Always layout though. 56 // Always layout though.
57 host_->Layout(); 57 host_->Layout();
58 58
59 // We own the native view as long as it's attached, so that we can safely 59 // We own the native view as long as it's attached, so that we can safely
60 // reparent it in multiple passes. 60 // reparent it in multiple passes.
61 gtk_widget_ref(host_->native_view()); 61 gtk_widget_ref(host_->native_view());
62 62
63 // TODO(port): figure out focus. 63 // TODO(port): figure out focus.
64 } 64 }
65 65
66 void NativeViewHostGtk::NativeViewDetaching() { 66 void NativeViewHostGtk::NativeViewDetaching() {
67 DCHECK(host_->native_view()); 67 DCHECK(host_->native_view());
68 68
69 g_signal_handler_disconnect(G_OBJECT(host_->native_view()), 69 g_signal_handler_disconnect(G_OBJECT(host_->native_view()),
70 destroy_signal_id_); 70 destroy_signal_id_);
71 destroy_signal_id_ = 0; 71 destroy_signal_id_ = 0;
72 72
73 g_signal_handler_disconnect(G_OBJECT(host_->focus_native_view()), 73 g_signal_handler_disconnect(G_OBJECT(host_->native_view()),
74 focus_signal_id_); 74 focus_signal_id_);
75 focus_signal_id_ = 0; 75 focus_signal_id_ = 0;
76 76
77 installed_clip_ = false; 77 installed_clip_ = false;
78 78
79 // Release ownership back to the caller. 79 // Release ownership back to the caller.
80 gtk_widget_unref(host_->native_view()); 80 gtk_widget_unref(host_->native_view());
81 } 81 }
82 82
83 void NativeViewHostGtk::AddedToWidget() { 83 void NativeViewHostGtk::AddedToWidget() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 gtk_fixed_move(GTK_FIXED(fixed_), host_->native_view(), child_x, child_y); 157 gtk_fixed_move(GTK_FIXED(fixed_), host_->native_view(), child_x, child_y);
158 158
159 gtk_widget_show(fixed_); 159 gtk_widget_show(fixed_);
160 gtk_widget_show(host_->native_view()); 160 gtk_widget_show(host_->native_view());
161 } 161 }
162 162
163 void NativeViewHostGtk::HideWidget() { 163 void NativeViewHostGtk::HideWidget() {
164 gtk_widget_hide(fixed_); 164 gtk_widget_hide(fixed_);
165 } 165 }
166 166
167 void NativeViewHostGtk::SetFocus() {
168 DCHECK(host_->native_view());
169 gtk_widget_grab_focus(host_->native_view());
170 }
171
167 //////////////////////////////////////////////////////////////////////////////// 172 ////////////////////////////////////////////////////////////////////////////////
168 // NativeViewHostGtk, private: 173 // NativeViewHostGtk, private:
169 174
170 void NativeViewHostGtk::CreateFixed(bool needs_window) { 175 void NativeViewHostGtk::CreateFixed(bool needs_window) {
171 DestroyFixed(); 176 DestroyFixed();
172 177
173 fixed_ = gtk_fixed_new(); 178 fixed_ = gtk_fixed_new();
174 gtk_fixed_set_has_window(GTK_FIXED(fixed_), needs_window); 179 gtk_fixed_set_has_window(GTK_FIXED(fixed_), needs_window);
175 // Defeat refcounting. We need to own the fixed. 180 // Defeat refcounting. We need to own the fixed.
176 gtk_widget_ref(fixed_); 181 gtk_widget_ref(fixed_);
(...skipping 26 matching lines...) Expand all
203 return static_cast<WidgetGtk*>(host_->GetWidget()); 208 return static_cast<WidgetGtk*>(host_->GetWidget());
204 } 209 }
205 210
206 // static 211 // static
207 void NativeViewHostGtk::CallDestroy(GtkObject* object, 212 void NativeViewHostGtk::CallDestroy(GtkObject* object,
208 NativeViewHostGtk* host) { 213 NativeViewHostGtk* host) {
209 host->host_->NativeViewDestroyed(); 214 host->host_->NativeViewDestroyed();
210 } 215 }
211 216
212 // static 217 // static
213 gboolean NativeViewHostGtk::CallFocusIn(GtkWidget* widget, 218 void NativeViewHostGtk::CallFocusIn(GtkWidget* widget,
214 GdkEventFocus* event, 219 GdkEventFocus* event,
215 NativeViewHostGtk* host) { 220 NativeViewHostGtk* host) {
216 host->host_->GotNativeFocus(); 221 FocusManager* focus_manager =
217 return false; 222 FocusManager::GetFocusManagerForNativeView(widget);
223 if (!focus_manager) {
224 // TODO(jcampan): http://crbug.com/21378 Reenable this NOTREACHED() when the
225 // options page is only based on views.
226 // NOTREACHED();
227 NOTIMPLEMENTED();
228 return;
229 }
230 focus_manager->SetFocusedView(host->host_->focus_view());
218 } 231 }
219 232
220 //////////////////////////////////////////////////////////////////////////////// 233 ////////////////////////////////////////////////////////////////////////////////
221 // NativeViewHostWrapper, public: 234 // NativeViewHostWrapper, public:
222 235
223 // static 236 // static
224 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( 237 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper(
225 NativeViewHost* host) { 238 NativeViewHost* host) {
226 return new NativeViewHostGtk(host); 239 return new NativeViewHostGtk(host);
227 } 240 }
228 241
229 } // namespace views 242 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/native/native_view_host_gtk.h ('k') | views/controls/native/native_view_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698