OLD | NEW |
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/widget/widget_gtk.h" | 5 #include "views/widget/widget_gtk.h" |
6 | 6 |
7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
9 #include "app/os_exchange_data.h" | 9 #include "app/os_exchange_data.h" |
10 #include "app/os_exchange_data_provider_gtk.h" | 10 #include "app/os_exchange_data_provider_gtk.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 tooltip_manager_.reset(new TooltipManagerGtk(this)); | 288 tooltip_manager_.reset(new TooltipManagerGtk(this)); |
289 | 289 |
290 // Register for tooltips. | 290 // Register for tooltips. |
291 g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL); | 291 g_object_set(G_OBJECT(window_contents_), "has-tooltip", TRUE, NULL); |
292 g_signal_connect(G_OBJECT(window_contents_), "query_tooltip", | 292 g_signal_connect(G_OBJECT(window_contents_), "query_tooltip", |
293 G_CALLBACK(CallQueryTooltip), this); | 293 G_CALLBACK(CallQueryTooltip), this); |
294 | 294 |
295 if (type_ == TYPE_CHILD) { | 295 if (type_ == TYPE_CHILD) { |
296 if (parent) { | 296 if (parent) { |
297 WidgetGtk* parent_widget = GetViewForNative(parent); | 297 WidgetGtk* parent_widget = GetViewForNative(parent); |
298 parent_widget->AddChild(widget_); | |
299 parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), | 298 parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), |
300 bounds.width(), bounds.height()); | 299 bounds.width(), bounds.height()); |
301 } | 300 } |
302 } else { | 301 } else { |
303 if (bounds.width() > 0 && bounds.height() > 0) | 302 if (bounds.width() > 0 && bounds.height() > 0) |
304 gtk_window_resize(GTK_WINDOW(widget_), bounds.width(), bounds.height()); | 303 gtk_window_resize(GTK_WINDOW(widget_), bounds.width(), bounds.height()); |
305 gtk_window_move(GTK_WINDOW(widget_), bounds.x(), bounds.y()); | 304 gtk_window_move(GTK_WINDOW(widget_), bounds.x(), bounds.y()); |
306 } | 305 } |
307 } | 306 } |
308 | 307 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 451 |
453 const Window* WidgetGtk::GetWindow() const { | 452 const Window* WidgetGtk::GetWindow() const { |
454 return GetWindowImpl(widget_); | 453 return GetWindowImpl(widget_); |
455 } | 454 } |
456 | 455 |
457 ThemeProvider* WidgetGtk::GetThemeProvider() const { | 456 ThemeProvider* WidgetGtk::GetThemeProvider() const { |
458 return default_theme_provider_.get(); | 457 return default_theme_provider_.get(); |
459 } | 458 } |
460 | 459 |
461 FocusManager* WidgetGtk::GetFocusManager() { | 460 FocusManager* WidgetGtk::GetFocusManager() { |
462 return focus_manager_.get(); | 461 if (focus_manager_.get()) |
| 462 return focus_manager_.get(); |
| 463 |
| 464 Widget* root = GetRootWidget(); |
| 465 if (root && root != this) { |
| 466 // Widget subclasses may override GetFocusManager(), for example for |
| 467 // dealing with cases where the widget has been unparented. |
| 468 return root->GetFocusManager(); |
| 469 } |
| 470 return NULL; |
463 } | 471 } |
464 | 472 |
465 void WidgetGtk::ViewHierarchyChanged(bool is_add, View *parent, | 473 void WidgetGtk::ViewHierarchyChanged(bool is_add, View *parent, |
466 View *child) { | 474 View *child) { |
467 if (drop_target_.get()) | 475 if (drop_target_.get()) |
468 drop_target_->ResetTargetViewIfEquals(child); | 476 drop_target_->ResetTargetViewIfEquals(child); |
469 } | 477 } |
470 | 478 |
471 //////////////////////////////////////////////////////////////////////////////// | 479 //////////////////////////////////////////////////////////////////////////////// |
472 // WidgetGtk, MessageLoopForUI::Observer implementation: | 480 // WidgetGtk, MessageLoopForUI::Observer implementation: |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1109 |
1102 // static | 1110 // static |
1103 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { | 1111 Widget* Widget::CreateTransparentPopupWidget(bool delete_on_destroy) { |
1104 WidgetGtk* popup = new WidgetGtk(WidgetGtk::TYPE_POPUP); | 1112 WidgetGtk* popup = new WidgetGtk(WidgetGtk::TYPE_POPUP); |
1105 popup->set_delete_on_destroy(delete_on_destroy); | 1113 popup->set_delete_on_destroy(delete_on_destroy); |
1106 popup->MakeTransparent(); | 1114 popup->MakeTransparent(); |
1107 return popup; | 1115 return popup; |
1108 } | 1116 } |
1109 | 1117 |
1110 } // namespace views | 1118 } // namespace views |
OLD | NEW |