OLD | NEW |
---|---|
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 "views/widget/widget.h" | 5 #include "views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ui/base/l10n/l10n_font_util.h" | 10 #include "ui/base/l10n/l10n_font_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); | 67 DISALLOW_COPY_AND_ASSIGN(ScopedEvent); |
68 }; | 68 }; |
69 | 69 |
70 // A default implementation of WidgetDelegate, used by Widget when no | 70 // A default implementation of WidgetDelegate, used by Widget when no |
71 // WidgetDelegate is supplied. | 71 // WidgetDelegate is supplied. |
72 class DefaultWidgetDelegate : public WidgetDelegate { | 72 class DefaultWidgetDelegate : public WidgetDelegate { |
73 public: | 73 public: |
74 DefaultWidgetDelegate(Widget* widget, const Widget::InitParams& params) | 74 DefaultWidgetDelegate(Widget* widget, const Widget::InitParams& params) |
75 : widget_(widget), | 75 : widget_(widget), |
76 can_activate_(params.type != Widget::InitParams::TYPE_POPUP) { | 76 can_activate_(!params.child && |
77 params.type != Widget::InitParams::TYPE_POPUP) { | |
77 } | 78 } |
78 virtual ~DefaultWidgetDelegate() {} | 79 virtual ~DefaultWidgetDelegate() {} |
79 | 80 |
80 // Overridden from WidgetDelegate: | 81 // Overridden from WidgetDelegate: |
81 virtual void DeleteDelegate() OVERRIDE { | 82 virtual void DeleteDelegate() OVERRIDE { |
82 delete this; | 83 delete this; |
83 } | 84 } |
84 virtual Widget* GetWidget() { | 85 virtual Widget* GetWidget() { |
85 return widget_; | 86 return widget_; |
86 } | 87 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 // property is gone after gobject gets deleted. Short circuit here | 392 // property is gone after gobject gets deleted. Short circuit here |
392 // for toplevel so that InputMethod can remove itself from | 393 // for toplevel so that InputMethod can remove itself from |
393 // focus manager. | 394 // focus manager. |
394 if (is_top_level()) | 395 if (is_top_level()) |
395 return this; | 396 return this; |
396 return native_widget_->GetTopLevelWidget(); | 397 return native_widget_->GetTopLevelWidget(); |
397 } | 398 } |
398 | 399 |
399 void Widget::SetContentsView(View* view) { | 400 void Widget::SetContentsView(View* view) { |
400 root_view_->SetContentsView(view); | 401 root_view_->SetContentsView(view); |
402 if (non_client_view_ != view) | |
403 non_client_view_ = NULL; | |
sadrul
2011/09/22 22:12:04
If this is necessary only for tests, can there be
oshima
2011/09/22 22:27:05
This is a bug which has to be fixed in normal case
| |
401 } | 404 } |
402 | 405 |
403 View* Widget::GetContentsView() { | 406 View* Widget::GetContentsView() { |
404 return root_view_->GetContentsView(); | 407 return root_view_->GetContentsView(); |
405 } | 408 } |
406 | 409 |
407 gfx::Rect Widget::GetWindowScreenBounds() const { | 410 gfx::Rect Widget::GetWindowScreenBounds() const { |
408 return native_widget_->GetWindowScreenBounds(); | 411 return native_widget_->GetWindowScreenBounds(); |
409 } | 412 } |
410 | 413 |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 } | 1070 } |
1068 | 1071 |
1069 //////////////////////////////////////////////////////////////////////////////// | 1072 //////////////////////////////////////////////////////////////////////////////// |
1070 // Widget, protected: | 1073 // Widget, protected: |
1071 | 1074 |
1072 internal::RootView* Widget::CreateRootView() { | 1075 internal::RootView* Widget::CreateRootView() { |
1073 return new internal::RootView(this); | 1076 return new internal::RootView(this); |
1074 } | 1077 } |
1075 | 1078 |
1076 void Widget::DestroyRootView() { | 1079 void Widget::DestroyRootView() { |
1080 non_client_view_ = NULL; | |
1077 root_view_.reset(); | 1081 root_view_.reset(); |
1078 // Input method has to be destroyed before focus manager. | 1082 // Input method has to be destroyed before focus manager. |
1079 input_method_.reset(); | 1083 input_method_.reset(); |
1080 // Defer focus manager's destruction. This is for the case when the | 1084 // Defer focus manager's destruction. This is for the case when the |
1081 // focus manager is referenced by a child NativeWidgetGtk (e.g. TabbedPane in | 1085 // focus manager is referenced by a child NativeWidgetGtk (e.g. TabbedPane in |
1082 // a dialog). When gtk_widget_destroy is called on the parent, the destroy | 1086 // a dialog). When gtk_widget_destroy is called on the parent, the destroy |
1083 // signal reaches parent first and then the child. Thus causing the parent | 1087 // signal reaches parent first and then the child. Thus causing the parent |
1084 // NativeWidgetGtk's dtor executed before the child's. If child's view | 1088 // NativeWidgetGtk's dtor executed before the child's. If child's view |
1085 // hierarchy references this focus manager, it crashes. This will defer focus | 1089 // hierarchy references this focus manager, it crashes. This will defer focus |
1086 // manager's destruction after child NativeWidgetGtk's dtor. | 1090 // manager's destruction after child NativeWidgetGtk's dtor. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1178 | 1182 |
1179 //////////////////////////////////////////////////////////////////////////////// | 1183 //////////////////////////////////////////////////////////////////////////////// |
1180 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1184 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1181 | 1185 |
1182 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1186 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1183 return this; | 1187 return this; |
1184 } | 1188 } |
1185 | 1189 |
1186 } // namespace internal | 1190 } // namespace internal |
1187 } // namespace views | 1191 } // namespace views |
OLD | NEW |