OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/widget/widget.h" | 5 #include "ui/views/widget/widget.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { | 1120 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { |
1121 View* root = GetRootView(); | 1121 View* root = GetRootView(); |
1122 if (root) { | 1122 if (root) { |
1123 root->SetSize(new_size); | 1123 root->SetSize(new_size); |
1124 if (root->GetFocusManager()) { | 1124 if (root->GetFocusManager()) { |
1125 View* focused_view = GetRootView()->GetFocusManager()->GetFocusedView(); | 1125 View* focused_view = GetRootView()->GetFocusManager()->GetFocusedView(); |
1126 if (focused_view && focused_view->GetInputMethod()) | 1126 if (focused_view && focused_view->GetInputMethod()) |
1127 focused_view->GetInputMethod()->OnCaretBoundsChanged(focused_view); | 1127 focused_view->GetInputMethod()->OnCaretBoundsChanged(focused_view); |
1128 } | 1128 } |
1129 } | 1129 } |
1130 // Size changed notifications can fire prior to full initialization | 1130 SaveWindowPlacementIfInitialized(); |
1131 // i.e. during session restore. Avoid saving session state during these | |
1132 // startup procedures. | |
1133 if (native_widget_initialized_) | |
1134 SaveWindowPlacement(); | |
1135 | 1131 |
1136 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged( | 1132 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged( |
1137 this, | 1133 this, |
1138 GetWindowBoundsInScreen())); | 1134 GetWindowBoundsInScreen())); |
1139 } | 1135 } |
1140 | 1136 |
| 1137 void Widget::OnNativeWidgetWindowShowStateChanged() { |
| 1138 SaveWindowPlacementIfInitialized(); |
| 1139 } |
| 1140 |
1141 void Widget::OnNativeWidgetBeginUserBoundsChange() { | 1141 void Widget::OnNativeWidgetBeginUserBoundsChange() { |
1142 widget_delegate_->OnWindowBeginUserBoundsChange(); | 1142 widget_delegate_->OnWindowBeginUserBoundsChange(); |
1143 } | 1143 } |
1144 | 1144 |
1145 void Widget::OnNativeWidgetEndUserBoundsChange() { | 1145 void Widget::OnNativeWidgetEndUserBoundsChange() { |
1146 widget_delegate_->OnWindowEndUserBoundsChange(); | 1146 widget_delegate_->OnWindowEndUserBoundsChange(); |
1147 } | 1147 } |
1148 | 1148 |
1149 bool Widget::HasFocusManager() const { | 1149 bool Widget::HasFocusManager() const { |
1150 return !!focus_manager_.get(); | 1150 return !!focus_manager_.get(); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 // bail. | 1419 // bail. |
1420 if (!widget_delegate_) | 1420 if (!widget_delegate_) |
1421 return; | 1421 return; |
1422 | 1422 |
1423 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; | 1423 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; |
1424 gfx::Rect bounds; | 1424 gfx::Rect bounds; |
1425 native_widget_->GetWindowPlacement(&bounds, &show_state); | 1425 native_widget_->GetWindowPlacement(&bounds, &show_state); |
1426 widget_delegate_->SaveWindowPlacement(bounds, show_state); | 1426 widget_delegate_->SaveWindowPlacement(bounds, show_state); |
1427 } | 1427 } |
1428 | 1428 |
| 1429 void Widget::SaveWindowPlacementIfInitialized() { |
| 1430 if (native_widget_initialized_) |
| 1431 SaveWindowPlacement(); |
| 1432 } |
| 1433 |
1429 void Widget::SetInitialBounds(const gfx::Rect& bounds) { | 1434 void Widget::SetInitialBounds(const gfx::Rect& bounds) { |
1430 if (!non_client_view_) | 1435 if (!non_client_view_) |
1431 return; | 1436 return; |
1432 | 1437 |
1433 gfx::Rect saved_bounds; | 1438 gfx::Rect saved_bounds; |
1434 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { | 1439 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { |
1435 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { | 1440 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { |
1436 // If we're going to maximize, wait until Show is invoked to set the | 1441 // If we're going to maximize, wait until Show is invoked to set the |
1437 // bounds. That way we avoid a noticeable resize. | 1442 // bounds. That way we avoid a noticeable resize. |
1438 initial_restored_bounds_ = saved_bounds; | 1443 initial_restored_bounds_ = saved_bounds; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 | 1516 |
1512 //////////////////////////////////////////////////////////////////////////////// | 1517 //////////////////////////////////////////////////////////////////////////////// |
1513 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1518 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1514 | 1519 |
1515 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1520 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1516 return this; | 1521 return this; |
1517 } | 1522 } |
1518 | 1523 |
1519 } // namespace internal | 1524 } // namespace internal |
1520 } // namespace views | 1525 } // namespace views |
OLD | NEW |