| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), | 122 keep_on_top(type == TYPE_MENU || type == TYPE_DRAG), |
| 123 visible_on_all_workspaces(false), | 123 visible_on_all_workspaces(false), |
| 124 ownership(NATIVE_WIDGET_OWNS_WIDGET), | 124 ownership(NATIVE_WIDGET_OWNS_WIDGET), |
| 125 mirror_origin_in_rtl(false), | 125 mirror_origin_in_rtl(false), |
| 126 shadow_type(SHADOW_TYPE_DEFAULT), | 126 shadow_type(SHADOW_TYPE_DEFAULT), |
| 127 remove_standard_frame(false), | 127 remove_standard_frame(false), |
| 128 use_system_default_icon(false), | 128 use_system_default_icon(false), |
| 129 show_state(ui::SHOW_STATE_DEFAULT), | 129 show_state(ui::SHOW_STATE_DEFAULT), |
| 130 parent(nullptr), | 130 parent(nullptr), |
| 131 native_widget(nullptr), | 131 native_widget(nullptr), |
| 132 native_theme(nullptr), | |
| 133 desktop_window_tree_host(nullptr), | 132 desktop_window_tree_host(nullptr), |
| 134 layer_type(ui::LAYER_TEXTURED), | 133 layer_type(ui::LAYER_TEXTURED), |
| 135 context(nullptr), | 134 context(nullptr), |
| 136 force_show_in_taskbar(false), | 135 force_show_in_taskbar(false), |
| 137 force_software_compositing(false) { | 136 force_software_compositing(false) { |
| 138 } | 137 } |
| 139 | 138 |
| 140 Widget::InitParams::~InitParams() { | 139 Widget::InitParams::~InitParams() { |
| 141 } | 140 } |
| 142 | 141 |
| 143 //////////////////////////////////////////////////////////////////////////////// | 142 //////////////////////////////////////////////////////////////////////////////// |
| 144 // Widget, public: | 143 // Widget, public: |
| 145 | 144 |
| 146 Widget::Widget() | 145 Widget::Widget() |
| 147 : native_widget_(nullptr), | 146 : native_widget_(nullptr), |
| 148 native_theme_(nullptr), | |
| 149 widget_delegate_(nullptr), | 147 widget_delegate_(nullptr), |
| 150 non_client_view_(nullptr), | 148 non_client_view_(nullptr), |
| 151 dragged_view_(nullptr), | 149 dragged_view_(nullptr), |
| 152 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 150 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 153 is_secondary_widget_(true), | 151 is_secondary_widget_(true), |
| 154 frame_type_(FRAME_TYPE_DEFAULT), | 152 frame_type_(FRAME_TYPE_DEFAULT), |
| 155 disable_inactive_rendering_(false), | 153 disable_inactive_rendering_(false), |
| 156 widget_closed_(false), | 154 widget_closed_(false), |
| 157 saved_show_state_(ui::SHOW_STATE_DEFAULT), | 155 saved_show_state_(ui::SHOW_STATE_DEFAULT), |
| 158 focus_on_creation_(true), | 156 focus_on_creation_(true), |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 337 |
| 340 ownership_ = params.ownership; | 338 ownership_ = params.ownership; |
| 341 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate(); | 339 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate(); |
| 342 root_view_.reset(CreateRootView()); | 340 root_view_.reset(CreateRootView()); |
| 343 default_theme_provider_.reset(new ui::DefaultThemeProvider); | 341 default_theme_provider_.reset(new ui::DefaultThemeProvider); |
| 344 if (params.type == InitParams::TYPE_MENU) { | 342 if (params.type == InitParams::TYPE_MENU) { |
| 345 is_mouse_button_pressed_ = | 343 is_mouse_button_pressed_ = |
| 346 internal::NativeWidgetPrivate::IsMouseButtonDown(); | 344 internal::NativeWidgetPrivate::IsMouseButtonDown(); |
| 347 } | 345 } |
| 348 native_widget_->InitNativeWidget(params); | 346 native_widget_->InitNativeWidget(params); |
| 349 native_theme_ = params.native_theme; | |
| 350 if (RequiresNonClientView(params.type)) { | 347 if (RequiresNonClientView(params.type)) { |
| 351 non_client_view_ = new NonClientView; | 348 non_client_view_ = new NonClientView; |
| 352 non_client_view_->SetFrameView(CreateNonClientFrameView()); | 349 non_client_view_->SetFrameView(CreateNonClientFrameView()); |
| 353 // Create the ClientView, add it to the NonClientView and add the | 350 // Create the ClientView, add it to the NonClientView and add the |
| 354 // NonClientView to the RootView. This will cause everything to be parented. | 351 // NonClientView to the RootView. This will cause everything to be parented. |
| 355 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); | 352 non_client_view_->set_client_view(widget_delegate_->CreateClientView(this)); |
| 356 non_client_view_->SetOverlayView(widget_delegate_->CreateOverlayView()); | 353 non_client_view_->SetOverlayView(widget_delegate_->CreateOverlayView()); |
| 357 SetContentsView(non_client_view_); | 354 SetContentsView(non_client_view_); |
| 358 // Initialize the window's icon and title before setting the window's | 355 // Initialize the window's icon and title before setting the window's |
| 359 // initial bounds; the frame view's preferred height may depend on the | 356 // initial bounds; the frame view's preferred height may depend on the |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 return provider; | 741 return provider; |
| 745 | 742 |
| 746 provider = root_widget->default_theme_provider_.get(); | 743 provider = root_widget->default_theme_provider_.get(); |
| 747 if (provider) | 744 if (provider) |
| 748 return provider; | 745 return provider; |
| 749 } | 746 } |
| 750 return default_theme_provider_.get(); | 747 return default_theme_provider_.get(); |
| 751 } | 748 } |
| 752 | 749 |
| 753 const ui::NativeTheme* Widget::GetNativeTheme() const { | 750 const ui::NativeTheme* Widget::GetNativeTheme() const { |
| 754 return native_theme_? native_theme_ : native_widget_->GetNativeTheme(); | 751 return native_widget_->GetNativeTheme(); |
| 755 } | 752 } |
| 756 | 753 |
| 757 FocusManager* Widget::GetFocusManager() { | 754 FocusManager* Widget::GetFocusManager() { |
| 758 Widget* toplevel_widget = GetTopLevelWidget(); | 755 Widget* toplevel_widget = GetTopLevelWidget(); |
| 759 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; | 756 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; |
| 760 } | 757 } |
| 761 | 758 |
| 762 const FocusManager* Widget::GetFocusManager() const { | 759 const FocusManager* Widget::GetFocusManager() const { |
| 763 const Widget* toplevel_widget = GetTopLevelWidget(); | 760 const Widget* toplevel_widget = GetTopLevelWidget(); |
| 764 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; | 761 return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 | 1487 |
| 1491 //////////////////////////////////////////////////////////////////////////////// | 1488 //////////////////////////////////////////////////////////////////////////////// |
| 1492 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1489 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1493 | 1490 |
| 1494 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1491 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1495 return this; | 1492 return this; |
| 1496 } | 1493 } |
| 1497 | 1494 |
| 1498 } // namespace internal | 1495 } // namespace internal |
| 1499 } // namespace views | 1496 } // namespace views |
| OLD | NEW |