| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 delegate(NULL), | 102 delegate(NULL), |
| 103 child(false), | 103 child(false), |
| 104 transient(false), | 104 transient(false), |
| 105 transparent(false), | 105 transparent(false), |
| 106 accept_events(true), | 106 accept_events(true), |
| 107 can_activate(true), | 107 can_activate(true), |
| 108 keep_on_top(false), | 108 keep_on_top(false), |
| 109 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 109 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 110 mirror_origin_in_rtl(false), | 110 mirror_origin_in_rtl(false), |
| 111 has_dropshadow(false), | 111 has_dropshadow(false), |
| 112 show_state(ui::SHOW_STATE_DEFAULT), | 112 maximize(false), |
| 113 double_buffer(false), | 113 double_buffer(false), |
| 114 parent(NULL), | 114 parent(NULL), |
| 115 parent_widget(NULL), | 115 parent_widget(NULL), |
| 116 native_widget(NULL), | 116 native_widget(NULL), |
| 117 top_level(false) { | 117 top_level(false) { |
| 118 } | 118 } |
| 119 | 119 |
| 120 Widget::InitParams::InitParams(Type type) | 120 Widget::InitParams::InitParams(Type type) |
| 121 : type(type), | 121 : type(type), |
| 122 delegate(NULL), | 122 delegate(NULL), |
| 123 child(type == TYPE_CONTROL), | 123 child(type == TYPE_CONTROL), |
| 124 transient(type == TYPE_POPUP || type == TYPE_MENU), | 124 transient(type == TYPE_POPUP || type == TYPE_MENU), |
| 125 transparent(false), | 125 transparent(false), |
| 126 accept_events(true), | 126 accept_events(true), |
| 127 can_activate(type != TYPE_POPUP && type != TYPE_MENU), | 127 can_activate(type != TYPE_POPUP && type != TYPE_MENU), |
| 128 keep_on_top(type == TYPE_MENU), | 128 keep_on_top(type == TYPE_MENU), |
| 129 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 129 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 130 mirror_origin_in_rtl(false), | 130 mirror_origin_in_rtl(false), |
| 131 has_dropshadow(false), | 131 has_dropshadow(false), |
| 132 show_state(ui::SHOW_STATE_DEFAULT), | 132 maximize(false), |
| 133 double_buffer(false), | 133 double_buffer(false), |
| 134 parent(NULL), | 134 parent(NULL), |
| 135 parent_widget(NULL), | 135 parent_widget(NULL), |
| 136 native_widget(NULL), | 136 native_widget(NULL), |
| 137 top_level(false) { | 137 top_level(false) { |
| 138 } | 138 } |
| 139 | 139 |
| 140 //////////////////////////////////////////////////////////////////////////////// | 140 //////////////////////////////////////////////////////////////////////////////// |
| 141 // Widget, public: | 141 // Widget, public: |
| 142 | 142 |
| 143 // static | 143 // static |
| 144 Widget::InitParams Widget::WindowInitParams() { | 144 Widget::InitParams Widget::WindowInitParams() { |
| 145 return InitParams(InitParams::TYPE_WINDOW); | 145 return InitParams(InitParams::TYPE_WINDOW); |
| 146 } | 146 } |
| 147 | 147 |
| 148 Widget::Widget() | 148 Widget::Widget() |
| 149 : is_mouse_button_pressed_(false), | 149 : is_mouse_button_pressed_(false), |
| 150 last_mouse_event_was_move_(false), | 150 last_mouse_event_was_move_(false), |
| 151 native_widget_(NULL), | 151 native_widget_(NULL), |
| 152 widget_delegate_(NULL), | 152 widget_delegate_(NULL), |
| 153 non_client_view_(NULL), | 153 non_client_view_(NULL), |
| 154 dragged_view_(NULL), | 154 dragged_view_(NULL), |
| 155 event_stack_(), | 155 event_stack_(), |
| 156 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 156 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 157 is_secondary_widget_(true), | 157 is_secondary_widget_(true), |
| 158 frame_type_(FRAME_TYPE_DEFAULT), | 158 frame_type_(FRAME_TYPE_DEFAULT), |
| 159 disable_inactive_rendering_(false), | 159 disable_inactive_rendering_(false), |
| 160 widget_closed_(false), | 160 widget_closed_(false), |
| 161 saved_show_state_(ui::SHOW_STATE_DEFAULT), | 161 saved_maximized_state_(false), |
| 162 minimum_size_(100, 100), | 162 minimum_size_(100, 100), |
| 163 focus_on_creation_(true), | 163 focus_on_creation_(true), |
| 164 is_top_level_(false), | 164 is_top_level_(false) { |
| 165 native_widget_created_(false) { | |
| 166 } | 165 } |
| 167 | 166 |
| 168 Widget::~Widget() { | 167 Widget::~Widget() { |
| 169 while (!event_stack_.empty()) { | 168 while (!event_stack_.empty()) { |
| 170 event_stack_.top()->reset(); | 169 event_stack_.top()->reset(); |
| 171 event_stack_.pop(); | 170 event_stack_.pop(); |
| 172 } | 171 } |
| 173 | 172 |
| 174 DestroyRootView(); | 173 DestroyRootView(); |
| 175 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) | 174 if (ownership_ == InitParams::WIDGET_OWNS_NATIVE_WIDGET) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 304 } |
| 306 native_widget_->InitNativeWidget(params); | 305 native_widget_->InitNativeWidget(params); |
| 307 if (params.type == InitParams::TYPE_WINDOW) { | 306 if (params.type == InitParams::TYPE_WINDOW) { |
| 308 non_client_view_ = new NonClientView; | 307 non_client_view_ = new NonClientView; |
| 309 non_client_view_->SetFrameView(CreateNonClientFrameView()); | 308 non_client_view_->SetFrameView(CreateNonClientFrameView()); |
| 310 // Create the ClientView, add it to the NonClientView and add the | 309 // Create the ClientView, add it to the NonClientView and add the |
| 311 // NonClientView to the RootView. This will cause everything to be parented. | 310 // NonClientView to the RootView. This will cause everything to be parented. |
| 312 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); | 311 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); |
| 313 SetContentsView(non_client_view_); | 312 SetContentsView(non_client_view_); |
| 314 SetInitialBounds(params.bounds); | 313 SetInitialBounds(params.bounds); |
| 315 if (params.show_state == ui::SHOW_STATE_MAXIMIZED) | 314 if (params.maximize) |
| 316 Maximize(); | 315 Maximize(); |
| 317 else if (params.show_state == ui::SHOW_STATE_MINIMIZED) | |
| 318 Minimize(); | |
| 319 UpdateWindowTitle(); | 316 UpdateWindowTitle(); |
| 320 } | 317 } |
| 321 } | 318 } |
| 322 | 319 |
| 323 // Unconverted methods (see header) -------------------------------------------- | 320 // Unconverted methods (see header) -------------------------------------------- |
| 324 | 321 |
| 325 gfx::NativeView Widget::GetNativeView() const { | 322 gfx::NativeView Widget::GetNativeView() const { |
| 326 return native_widget_->GetNativeView(); | 323 return native_widget_->GetNativeView(); |
| 327 } | 324 } |
| 328 | 325 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // It appears we can hit this code path if you close a modal dialog then | 439 // It appears we can hit this code path if you close a modal dialog then |
| 443 // close the last browser before the destructor is hit, which triggers | 440 // close the last browser before the destructor is hit, which triggers |
| 444 // invoking Close again. | 441 // invoking Close again. |
| 445 return; | 442 return; |
| 446 } | 443 } |
| 447 | 444 |
| 448 bool can_close = true; | 445 bool can_close = true; |
| 449 if (non_client_view_) | 446 if (non_client_view_) |
| 450 can_close = non_client_view_->CanClose(); | 447 can_close = non_client_view_->CanClose(); |
| 451 if (can_close) { | 448 if (can_close) { |
| 452 SaveWindowPlacement(); | 449 SaveWindowPosition(); |
| 453 | 450 |
| 454 // During tear-down the top-level focus manager becomes unavailable to | 451 // During tear-down the top-level focus manager becomes unavailable to |
| 455 // GTK tabbed panes and their children, so normal deregistration via | 452 // GTK tabbed panes and their children, so normal deregistration via |
| 456 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here | 453 // |FormManager::ViewRemoved()| calls are fouled. We clear focus here |
| 457 // to avoid these redundant steps and to avoid accessing deleted views | 454 // to avoid these redundant steps and to avoid accessing deleted views |
| 458 // that may have been in focus. | 455 // that may have been in focus. |
| 459 if (is_top_level() && focus_manager_.get()) | 456 if (is_top_level() && focus_manager_.get()) |
| 460 focus_manager_->SetFocusedView(NULL); | 457 focus_manager_->SetFocusedView(NULL); |
| 461 | 458 |
| 462 native_widget_->Close(); | 459 native_widget_->Close(); |
| 463 widget_closed_ = true; | 460 widget_closed_ = true; |
| 464 } | 461 } |
| 465 } | 462 } |
| 466 | 463 |
| 467 void Widget::CloseNow() { | 464 void Widget::CloseNow() { |
| 468 native_widget_->CloseNow(); | 465 native_widget_->CloseNow(); |
| 469 } | 466 } |
| 470 | 467 |
| 471 void Widget::EnableClose(bool enable) { | 468 void Widget::EnableClose(bool enable) { |
| 472 if (non_client_view_) | 469 if (non_client_view_) |
| 473 non_client_view_->EnableClose(enable); | 470 non_client_view_->EnableClose(enable); |
| 474 native_widget_->EnableClose(enable); | 471 native_widget_->EnableClose(enable); |
| 475 } | 472 } |
| 476 | 473 |
| 477 void Widget::Show() { | 474 void Widget::Show() { |
| 478 if (non_client_view_) { | 475 if (non_client_view_) { |
| 479 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | 476 if (saved_maximized_state_ && !initial_restored_bounds_.IsEmpty()) { |
| 480 !initial_restored_bounds_.IsEmpty()) { | |
| 481 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); | 477 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); |
| 482 } else { | 478 } else { |
| 483 native_widget_->ShowWithWindowState(saved_show_state_); | 479 native_widget_->ShowWithState(saved_maximized_state_ ? |
| 480 internal::NativeWidgetPrivate::SHOW_MAXIMIZED : |
| 481 internal::NativeWidgetPrivate::SHOW_RESTORED); |
| 484 } | 482 } |
| 485 // |saved_show_state_| only applies the first time the window is shown. | 483 // |saved_maximized_state_| only applies the first time the window is shown. |
| 486 // If we don't reset the value the window may be shown maximized every time | 484 // If we don't reset the value the window will be shown maximized every time |
| 487 // it is subsequently shown after being hidden. | 485 // it is subsequently shown after being hidden. |
| 488 saved_show_state_ = ui::SHOW_STATE_NORMAL; | 486 saved_maximized_state_ = false; |
| 489 } else { | 487 } else { |
| 490 native_widget_->Show(); | 488 native_widget_->Show(); |
| 491 } | 489 } |
| 492 } | 490 } |
| 493 | 491 |
| 494 void Widget::Hide() { | 492 void Widget::Hide() { |
| 495 native_widget_->Hide(); | 493 native_widget_->Hide(); |
| 496 } | 494 } |
| 497 | 495 |
| 498 void Widget::ShowInactive() { | 496 void Widget::ShowInactive() { |
| 499 // If this gets called with saved_show_state_ == ui::SHOW_STATE_MAXIMIZED, | 497 // If this gets called with saved_maximized_state_ == true, call SetBounds() |
| 500 // call SetBounds()with the restored bounds to set the correct size. This | 498 // with the restored bounds to set the correct size. This normally should |
| 501 // normally should not happen, but if it does we should avoid showing unsized | 499 // not happen, but if it does we should avoid showing unsized windows. |
| 502 // windows. | 500 if (saved_maximized_state_ && !initial_restored_bounds_.IsEmpty()) { |
| 503 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | |
| 504 !initial_restored_bounds_.IsEmpty()) { | |
| 505 SetBounds(initial_restored_bounds_); | 501 SetBounds(initial_restored_bounds_); |
| 506 saved_show_state_ = ui::SHOW_STATE_NORMAL; | 502 saved_maximized_state_ = false; |
| 507 } | 503 } |
| 508 native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); | 504 native_widget_->ShowWithState(internal::NativeWidgetPrivate::SHOW_INACTIVE); |
| 509 } | 505 } |
| 510 | 506 |
| 511 void Widget::Activate() { | 507 void Widget::Activate() { |
| 512 native_widget_->Activate(); | 508 native_widget_->Activate(); |
| 513 } | 509 } |
| 514 | 510 |
| 515 void Widget::Deactivate() { | 511 void Widget::Deactivate() { |
| 516 native_widget_->Deactivate(); | 512 native_widget_->Deactivate(); |
| 517 } | 513 } |
| 518 | 514 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 818 } |
| 823 | 819 |
| 824 void Widget::EnableInactiveRendering() { | 820 void Widget::EnableInactiveRendering() { |
| 825 disable_inactive_rendering_ = false; | 821 disable_inactive_rendering_ = false; |
| 826 if (non_client_view_) | 822 if (non_client_view_) |
| 827 non_client_view_->DisableInactiveRendering(false); | 823 non_client_view_->DisableInactiveRendering(false); |
| 828 } | 824 } |
| 829 | 825 |
| 830 void Widget::OnNativeWidgetActivationChanged(bool active) { | 826 void Widget::OnNativeWidgetActivationChanged(bool active) { |
| 831 if (!active) { | 827 if (!active) { |
| 832 SaveWindowPlacement(); | 828 SaveWindowPosition(); |
| 833 | 829 |
| 834 // Close any open menus. | 830 // Close any open menus. |
| 835 MenuController* menu_controller = MenuController::GetActiveInstance(); | 831 MenuController* menu_controller = MenuController::GetActiveInstance(); |
| 836 if (menu_controller) | 832 if (menu_controller) |
| 837 menu_controller->OnWidgetActivationChanged(); | 833 menu_controller->OnWidgetActivationChanged(); |
| 838 } | 834 } |
| 839 | 835 |
| 840 FOR_EACH_OBSERVER(Observer, observers_, | 836 FOR_EACH_OBSERVER(Observer, observers_, |
| 841 OnWidgetActivationChanged(this, active)); | 837 OnWidgetActivationChanged(this, active)); |
| 842 } | 838 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 863 if (is_top_level()) | 859 if (is_top_level()) |
| 864 focus_manager_.reset(FocusManagerFactory::Create(this)); | 860 focus_manager_.reset(FocusManagerFactory::Create(this)); |
| 865 | 861 |
| 866 native_widget_->SetAccessibleRole( | 862 native_widget_->SetAccessibleRole( |
| 867 widget_delegate_->GetAccessibleWindowRole()); | 863 widget_delegate_->GetAccessibleWindowRole()); |
| 868 native_widget_->SetAccessibleState( | 864 native_widget_->SetAccessibleState( |
| 869 widget_delegate_->GetAccessibleWindowState()); | 865 widget_delegate_->GetAccessibleWindowState()); |
| 870 | 866 |
| 871 if (widget_delegate_->IsModal()) | 867 if (widget_delegate_->IsModal()) |
| 872 native_widget_->BecomeModal(); | 868 native_widget_->BecomeModal(); |
| 873 | |
| 874 native_widget_created_ = true; | |
| 875 } | 869 } |
| 876 | 870 |
| 877 void Widget::OnNativeWidgetDestroying() { | 871 void Widget::OnNativeWidgetDestroying() { |
| 878 FOR_EACH_OBSERVER(Observer, observers_, OnWidgetClosing(this)); | 872 FOR_EACH_OBSERVER(Observer, observers_, OnWidgetClosing(this)); |
| 879 if (non_client_view_) | 873 if (non_client_view_) |
| 880 non_client_view_->WindowClosing(); | 874 non_client_view_->WindowClosing(); |
| 881 widget_delegate_->WindowClosing(); | 875 widget_delegate_->WindowClosing(); |
| 882 } | 876 } |
| 883 | 877 |
| 884 void Widget::OnNativeWidgetDestroyed() { | 878 void Widget::OnNativeWidgetDestroyed() { |
| 885 widget_delegate_->DeleteDelegate(); | 879 widget_delegate_->DeleteDelegate(); |
| 886 widget_delegate_ = NULL; | 880 widget_delegate_ = NULL; |
| 887 } | 881 } |
| 888 | 882 |
| 889 gfx::Size Widget::GetMinimumSize() { | 883 gfx::Size Widget::GetMinimumSize() { |
| 890 return non_client_view_ ? non_client_view_->GetMinimumSize() : gfx::Size(); | 884 return non_client_view_ ? non_client_view_->GetMinimumSize() : gfx::Size(); |
| 891 } | 885 } |
| 892 | 886 |
| 893 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { | 887 void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) { |
| 894 root_view_->SetSize(new_size); | 888 root_view_->SetSize(new_size); |
| 895 | |
| 896 // Size changed notifications can fire prior to full initialization | |
| 897 // i.e. during session restore. Avoid saving session state during these | |
| 898 // startup procedures. | |
| 899 if (native_widget_created_) | |
| 900 SaveWindowPlacement(); | |
| 901 } | 889 } |
| 902 | 890 |
| 903 void Widget::OnNativeWidgetBeginUserBoundsChange() { | 891 void Widget::OnNativeWidgetBeginUserBoundsChange() { |
| 904 widget_delegate_->OnWindowBeginUserBoundsChange(); | 892 widget_delegate_->OnWindowBeginUserBoundsChange(); |
| 905 } | 893 } |
| 906 | 894 |
| 907 void Widget::OnNativeWidgetEndUserBoundsChange() { | 895 void Widget::OnNativeWidgetEndUserBoundsChange() { |
| 908 widget_delegate_->OnWindowEndUserBoundsChange(); | 896 widget_delegate_->OnWindowEndUserBoundsChange(); |
| 909 } | 897 } |
| 910 | 898 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 //////////////////////////////////////////////////////////////////////////////// | 1048 //////////////////////////////////////////////////////////////////////////////// |
| 1061 // Widget, private: | 1049 // Widget, private: |
| 1062 | 1050 |
| 1063 // static | 1051 // static |
| 1064 ui::Compositor*(*Widget::compositor_factory_)() = NULL; | 1052 ui::Compositor*(*Widget::compositor_factory_)() = NULL; |
| 1065 | 1053 |
| 1066 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { | 1054 bool Widget::ShouldReleaseCaptureOnMouseReleased() const { |
| 1067 return true; | 1055 return true; |
| 1068 } | 1056 } |
| 1069 | 1057 |
| 1070 void Widget::SaveWindowPlacement() { | 1058 void Widget::SaveWindowPosition() { |
| 1071 // The window delegate does the actual saving for us. It seems like (judging | 1059 // The window delegate does the actual saving for us. It seems like (judging |
| 1072 // by go/crash) that in some circumstances we can end up here after | 1060 // by go/crash) that in some circumstances we can end up here after |
| 1073 // WM_DESTROY, at which point the window delegate is likely gone. So just | 1061 // WM_DESTROY, at which point the window delegate is likely gone. So just |
| 1074 // bail. | 1062 // bail. |
| 1075 if (!widget_delegate_) | 1063 if (!widget_delegate_) |
| 1076 return; | 1064 return; |
| 1077 | 1065 |
| 1078 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; | 1066 bool maximized = false; |
| 1079 gfx::Rect bounds; | 1067 gfx::Rect bounds; |
| 1080 native_widget_->GetWindowPlacement(&bounds, &show_state); | 1068 native_widget_->GetWindowBoundsAndMaximizedState(&bounds, &maximized); |
| 1081 widget_delegate_->SaveWindowPlacement(bounds, show_state); | 1069 widget_delegate_->SaveWindowPlacement(bounds, maximized); |
| 1082 } | 1070 } |
| 1083 | 1071 |
| 1084 void Widget::SetInitialBounds(const gfx::Rect& bounds) { | 1072 void Widget::SetInitialBounds(const gfx::Rect& bounds) { |
| 1085 if (!non_client_view_) | 1073 if (!non_client_view_) |
| 1086 return; | 1074 return; |
| 1087 | 1075 |
| 1088 gfx::Rect saved_bounds; | 1076 gfx::Rect saved_bounds; |
| 1089 if (GetSavedWindowPlacement(&saved_bounds, &saved_show_state_)) { | 1077 if (GetSavedBounds(&saved_bounds, &saved_maximized_state_)) { |
| 1090 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { | 1078 if (saved_maximized_state_) { |
| 1091 // If we're going to maximize, wait until Show is invoked to set the | 1079 // If we're going to maximize, wait until Show is invoked to set the |
| 1092 // bounds. That way we avoid a noticable resize. | 1080 // bounds. That way we avoid a noticable resize. |
| 1093 initial_restored_bounds_ = saved_bounds; | 1081 initial_restored_bounds_ = saved_bounds; |
| 1094 } else { | 1082 } else { |
| 1095 SetBounds(saved_bounds); | 1083 SetBounds(saved_bounds); |
| 1096 } | 1084 } |
| 1097 } else { | 1085 } else { |
| 1098 if (bounds.IsEmpty()) { | 1086 if (bounds.IsEmpty()) { |
| 1099 // No initial bounds supplied, so size the window to its content and | 1087 // No initial bounds supplied, so size the window to its content and |
| 1100 // center over its parent. | 1088 // center over its parent. |
| 1101 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); | 1089 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); |
| 1102 } else { | 1090 } else { |
| 1103 // Use the supplied initial bounds. | 1091 // Use the supplied initial bounds. |
| 1104 SetBoundsConstrained(bounds, NULL); | 1092 SetBoundsConstrained(bounds, NULL); |
| 1105 } | 1093 } |
| 1106 } | 1094 } |
| 1107 } | 1095 } |
| 1108 | 1096 |
| 1109 bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds, | 1097 bool Widget::GetSavedBounds(gfx::Rect* bounds, bool* maximize) { |
| 1110 ui::WindowShowState* show_state) { | |
| 1111 // First we obtain the window's saved show-style and store it. We need to do | 1098 // First we obtain the window's saved show-style and store it. We need to do |
| 1112 // this here, rather than in Show() because by the time Show() is called, | 1099 // this here, rather than in Show() because by the time Show() is called, |
| 1113 // the window's size will have been reset (below) and the saved maximized | 1100 // the window's size will have been reset (below) and the saved maximized |
| 1114 // state will have been lost. Sadly there's no way to tell on Windows when | 1101 // state will have been lost. Sadly there's no way to tell on Windows when |
| 1115 // a window is restored from maximized state, so we can't more accurately | 1102 // a window is restored from maximized state, so we can't more accurately |
| 1116 // track maximized state independently of sizing information. | 1103 // track maximized state independently of sizing information. |
| 1104 widget_delegate_->GetSavedMaximizedState(maximize); |
| 1117 | 1105 |
| 1118 // Restore the window's placement from the controller. | 1106 // Restore the window's placement from the controller. |
| 1119 if (widget_delegate_->GetSavedWindowPlacement(bounds, show_state)) { | 1107 if (widget_delegate_->GetSavedWindowBounds(bounds)) { |
| 1120 if (!widget_delegate_->ShouldRestoreWindowSize()) { | 1108 if (!widget_delegate_->ShouldRestoreWindowSize()) { |
| 1121 bounds->set_size(non_client_view_->GetPreferredSize()); | 1109 bounds->set_size(non_client_view_->GetPreferredSize()); |
| 1122 } else { | 1110 } else { |
| 1123 // Make sure the bounds are at least the minimum size. | 1111 // Make sure the bounds are at least the minimum size. |
| 1124 if (bounds->width() < minimum_size_.width()) | 1112 if (bounds->width() < minimum_size_.width()) |
| 1125 bounds->set_width(minimum_size_.width()); | 1113 bounds->set_width(minimum_size_.width()); |
| 1126 | 1114 |
| 1127 if (bounds->height() < minimum_size_.height()) | 1115 if (bounds->height() < minimum_size_.height()) |
| 1128 bounds->set_height(minimum_size_.height()); | 1116 bounds->set_height(minimum_size_.height()); |
| 1129 } | 1117 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1146 | 1134 |
| 1147 //////////////////////////////////////////////////////////////////////////////// | 1135 //////////////////////////////////////////////////////////////////////////////// |
| 1148 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1136 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1149 | 1137 |
| 1150 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1138 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1151 return this; | 1139 return this; |
| 1152 } | 1140 } |
| 1153 | 1141 |
| 1154 } // namespace internal | 1142 } // namespace internal |
| 1155 } // namespace views | 1143 } // namespace views |
| OLD | NEW |