Chromium Code Reviews| 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 // Size changed notifications can fire prior to full initialization |
|
sky
2014/08/12 13:21:28
1130-1131 and 1140-1141 can now be nuked since cov
jackhou1
2014/08/13 01:57:51
Done.
| |
| 1131 // i.e. during session restore. Avoid saving session state during these | 1131 // i.e. during session restore. |
| 1132 // startup procedures. | 1132 SaveWindowPlacementIfInitialized(); |
| 1133 if (native_widget_initialized_) | |
| 1134 SaveWindowPlacement(); | |
| 1135 | 1133 |
| 1136 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged( | 1134 FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged( |
| 1137 this, | 1135 this, |
| 1138 GetWindowBoundsInScreen())); | 1136 GetWindowBoundsInScreen())); |
| 1139 } | 1137 } |
| 1140 | 1138 |
| 1139 void Widget::OnNativeWidgetWindowShowStateChanged() { | |
| 1140 // Size changed notifications can fire prior to full initialization | |
| 1141 // i.e. during session restore. | |
| 1142 SaveWindowPlacementIfInitialized(); | |
| 1143 } | |
| 1144 | |
| 1141 void Widget::OnNativeWidgetBeginUserBoundsChange() { | 1145 void Widget::OnNativeWidgetBeginUserBoundsChange() { |
| 1142 widget_delegate_->OnWindowBeginUserBoundsChange(); | 1146 widget_delegate_->OnWindowBeginUserBoundsChange(); |
| 1143 } | 1147 } |
| 1144 | 1148 |
| 1145 void Widget::OnNativeWidgetEndUserBoundsChange() { | 1149 void Widget::OnNativeWidgetEndUserBoundsChange() { |
| 1146 widget_delegate_->OnWindowEndUserBoundsChange(); | 1150 widget_delegate_->OnWindowEndUserBoundsChange(); |
| 1147 } | 1151 } |
| 1148 | 1152 |
| 1149 bool Widget::HasFocusManager() const { | 1153 bool Widget::HasFocusManager() const { |
| 1150 return !!focus_manager_.get(); | 1154 return !!focus_manager_.get(); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1419 // bail. | 1423 // bail. |
| 1420 if (!widget_delegate_) | 1424 if (!widget_delegate_) |
| 1421 return; | 1425 return; |
| 1422 | 1426 |
| 1423 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; | 1427 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; |
| 1424 gfx::Rect bounds; | 1428 gfx::Rect bounds; |
| 1425 native_widget_->GetWindowPlacement(&bounds, &show_state); | 1429 native_widget_->GetWindowPlacement(&bounds, &show_state); |
| 1426 widget_delegate_->SaveWindowPlacement(bounds, show_state); | 1430 widget_delegate_->SaveWindowPlacement(bounds, show_state); |
| 1427 } | 1431 } |
| 1428 | 1432 |
| 1433 void Widget::SaveWindowPlacementIfInitialized() { | |
| 1434 if (native_widget_initialized_) | |
| 1435 SaveWindowPlacement(); | |
| 1436 } | |
| 1437 | |
| 1429 void Widget::SetInitialBounds(const gfx::Rect& bounds) { | 1438 void Widget::SetInitialBounds(const gfx::Rect& bounds) { |
| 1430 if (!non_client_view_) | 1439 if (!non_client_view_) |
| 1431 return; | 1440 return; |
| 1432 | 1441 |
| 1433 gfx::Rect saved_bounds; | 1442 gfx::Rect saved_bounds; |
| 1434 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { | 1443 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { |
| 1435 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { | 1444 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { |
| 1436 // If we're going to maximize, wait until Show is invoked to set the | 1445 // If we're going to maximize, wait until Show is invoked to set the |
| 1437 // bounds. That way we avoid a noticeable resize. | 1446 // bounds. That way we avoid a noticeable resize. |
| 1438 initial_restored_bounds_ = saved_bounds; | 1447 initial_restored_bounds_ = saved_bounds; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1511 | 1520 |
| 1512 //////////////////////////////////////////////////////////////////////////////// | 1521 //////////////////////////////////////////////////////////////////////////////// |
| 1513 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1522 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1514 | 1523 |
| 1515 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1524 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1516 return this; | 1525 return this; |
| 1517 } | 1526 } |
| 1518 | 1527 |
| 1519 } // namespace internal | 1528 } // namespace internal |
| 1520 } // namespace views | 1529 } // namespace views |
| OLD | NEW |