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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 non_client_view_->WindowClosing(); | 897 non_client_view_->WindowClosing(); |
898 widget_delegate_->WindowClosing(); | 898 widget_delegate_->WindowClosing(); |
899 } | 899 } |
900 | 900 |
901 void Widget::OnNativeWidgetDestroyed() { | 901 void Widget::OnNativeWidgetDestroyed() { |
902 widget_delegate_->DeleteDelegate(); | 902 widget_delegate_->DeleteDelegate(); |
903 widget_delegate_ = NULL; | 903 widget_delegate_ = NULL; |
904 } | 904 } |
905 | 905 |
906 gfx::Size Widget::GetMinimumSize() { | 906 gfx::Size Widget::GetMinimumSize() { |
907 return non_client_view_ ? non_client_view_->GetMinimumSize() : gfx::Size(); | 907 return non_client_view_ ? non_client_view_->GetMinimumSize() : minimum_size_; |
908 } | 908 } |
909 | 909 |
910 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { | 910 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { |
911 root_view_->SetSize(new_size); | 911 root_view_->SetSize(new_size); |
912 | 912 |
913 // Size changed notifications can fire prior to full initialization | 913 // Size changed notifications can fire prior to full initialization |
914 // i.e. during session restore. Avoid saving session state during these | 914 // i.e. during session restore. Avoid saving session state during these |
915 // startup procedures. | 915 // startup procedures. |
916 if (native_widget_initialized_) | 916 if (native_widget_initialized_) |
917 SaveWindowPlacement(); | 917 SaveWindowPlacement(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 // the window's size will have been reset (below) and the saved maximized | 1153 // the window's size will have been reset (below) and the saved maximized |
1154 // state will have been lost. Sadly there's no way to tell on Windows when | 1154 // state will have been lost. Sadly there's no way to tell on Windows when |
1155 // a window is restored from maximized state, so we can't more accurately | 1155 // a window is restored from maximized state, so we can't more accurately |
1156 // track maximized state independently of sizing information. | 1156 // track maximized state independently of sizing information. |
1157 | 1157 |
1158 // Restore the window's placement from the controller. | 1158 // Restore the window's placement from the controller. |
1159 if (widget_delegate_->GetSavedWindowPlacement(bounds, show_state)) { | 1159 if (widget_delegate_->GetSavedWindowPlacement(bounds, show_state)) { |
1160 if (!widget_delegate_->ShouldRestoreWindowSize()) { | 1160 if (!widget_delegate_->ShouldRestoreWindowSize()) { |
1161 bounds->set_size(non_client_view_->GetPreferredSize()); | 1161 bounds->set_size(non_client_view_->GetPreferredSize()); |
1162 } else { | 1162 } else { |
| 1163 gfx::Size minimum_size = GetMinimumSize(); |
1163 // Make sure the bounds are at least the minimum size. | 1164 // Make sure the bounds are at least the minimum size. |
1164 if (bounds->width() < minimum_size_.width()) | 1165 if (bounds->width() < minimum_size.width()) |
1165 bounds->set_width(minimum_size_.width()); | 1166 bounds->set_width(minimum_size.width()); |
1166 | 1167 |
1167 if (bounds->height() < minimum_size_.height()) | 1168 if (bounds->height() < minimum_size.height()) |
1168 bounds->set_height(minimum_size_.height()); | 1169 bounds->set_height(minimum_size.height()); |
1169 } | 1170 } |
1170 return true; | 1171 return true; |
1171 } | 1172 } |
1172 return false; | 1173 return false; |
1173 } | 1174 } |
1174 | 1175 |
1175 void Widget::ReplaceInputMethod(InputMethod* input_method) { | 1176 void Widget::ReplaceInputMethod(InputMethod* input_method) { |
1176 input_method_.reset(input_method); | 1177 input_method_.reset(input_method); |
1177 // TODO(oshima): Gtk's textfield doesn't need views InputMethod. | 1178 // TODO(oshima): Gtk's textfield doesn't need views InputMethod. |
1178 // Remove this check once gtk is removed. | 1179 // Remove this check once gtk is removed. |
1179 if (input_method) { | 1180 if (input_method) { |
1180 input_method->set_delegate(native_widget_); | 1181 input_method->set_delegate(native_widget_); |
1181 input_method->Init(this); | 1182 input_method->Init(this); |
1182 } | 1183 } |
1183 } | 1184 } |
1184 | 1185 |
1185 namespace internal { | 1186 namespace internal { |
1186 | 1187 |
1187 //////////////////////////////////////////////////////////////////////////////// | 1188 //////////////////////////////////////////////////////////////////////////////// |
1188 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1189 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1189 | 1190 |
1190 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1191 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1191 return this; | 1192 return this; |
1192 } | 1193 } |
1193 | 1194 |
1194 } // namespace internal | 1195 } // namespace internal |
1195 } // namespace views | 1196 } // namespace views |
OLD | NEW |