| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 layer_type(ui::LAYER_TEXTURED), | 135 layer_type(ui::LAYER_TEXTURED), |
| 136 context(nullptr), | 136 context(nullptr), |
| 137 force_show_in_taskbar(false), | 137 force_show_in_taskbar(false), |
| 138 force_software_compositing(false) {} | 138 force_software_compositing(false) {} |
| 139 | 139 |
| 140 Widget::InitParams::InitParams(const InitParams& other) = default; | 140 Widget::InitParams::InitParams(const InitParams& other) = default; |
| 141 | 141 |
| 142 Widget::InitParams::~InitParams() { | 142 Widget::InitParams::~InitParams() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool Widget::InitParams::CanActivate() const { |
| 146 if (activatable != InitParams::ACTIVATABLE_DEFAULT) |
| 147 return activatable == InitParams::ACTIVATABLE_YES; |
| 148 return type != InitParams::TYPE_CONTROL && type != InitParams::TYPE_POPUP && |
| 149 type != InitParams::TYPE_MENU && type != InitParams::TYPE_TOOLTIP && |
| 150 type != InitParams::TYPE_DRAG; |
| 151 } |
| 152 |
| 145 //////////////////////////////////////////////////////////////////////////////// | 153 //////////////////////////////////////////////////////////////////////////////// |
| 146 // Widget, public: | 154 // Widget, public: |
| 147 | 155 |
| 148 Widget::Widget() | 156 Widget::Widget() |
| 149 : native_widget_(nullptr), | 157 : native_widget_(nullptr), |
| 150 widget_delegate_(nullptr), | 158 widget_delegate_(nullptr), |
| 151 non_client_view_(nullptr), | 159 non_client_view_(nullptr), |
| 152 dragged_view_(nullptr), | 160 dragged_view_(nullptr), |
| 153 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 161 ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 154 is_secondary_widget_(true), | 162 is_secondary_widget_(true), |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 params.type != views::Widget::InitParams::TYPE_WINDOW && | 310 params.type != views::Widget::InitParams::TYPE_WINDOW && |
| 303 params.type != views::Widget::InitParams::TYPE_PANEL) | 311 params.type != views::Widget::InitParams::TYPE_PANEL) |
| 304 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 312 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| 305 | 313 |
| 306 if (ViewsDelegate::GetInstance()) | 314 if (ViewsDelegate::GetInstance()) |
| 307 ViewsDelegate::GetInstance()->OnBeforeWidgetInit(¶ms, this); | 315 ViewsDelegate::GetInstance()->OnBeforeWidgetInit(¶ms, this); |
| 308 | 316 |
| 309 if (params.opacity == views::Widget::InitParams::INFER_OPACITY) | 317 if (params.opacity == views::Widget::InitParams::INFER_OPACITY) |
| 310 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 318 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| 311 | 319 |
| 312 bool can_activate = false; | 320 bool can_activate = params.CanActivate(); |
| 313 if (params.activatable != InitParams::ACTIVATABLE_DEFAULT) { | 321 params.activatable = |
| 314 can_activate = (params.activatable == InitParams::ACTIVATABLE_YES); | 322 can_activate ? InitParams::ACTIVATABLE_YES : InitParams::ACTIVATABLE_NO; |
| 315 } else if (params.type != InitParams::TYPE_CONTROL && | |
| 316 params.type != InitParams::TYPE_POPUP && | |
| 317 params.type != InitParams::TYPE_MENU && | |
| 318 params.type != InitParams::TYPE_TOOLTIP && | |
| 319 params.type != InitParams::TYPE_DRAG) { | |
| 320 can_activate = true; | |
| 321 params.activatable = InitParams::ACTIVATABLE_YES; | |
| 322 } else { | |
| 323 can_activate = false; | |
| 324 params.activatable = InitParams::ACTIVATABLE_NO; | |
| 325 } | |
| 326 | 323 |
| 327 widget_delegate_ = params.delegate ? | 324 widget_delegate_ = params.delegate ? |
| 328 params.delegate : new DefaultWidgetDelegate(this); | 325 params.delegate : new DefaultWidgetDelegate(this); |
| 329 widget_delegate_->set_can_activate(can_activate); | 326 widget_delegate_->set_can_activate(can_activate); |
| 330 | 327 |
| 331 ownership_ = params.ownership; | 328 ownership_ = params.ownership; |
| 332 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate(); | 329 native_widget_ = CreateNativeWidget(params, this)->AsNativeWidgetPrivate(); |
| 333 root_view_.reset(CreateRootView()); | 330 root_view_.reset(CreateRootView()); |
| 334 default_theme_provider_.reset(new ui::DefaultThemeProvider); | 331 default_theme_provider_.reset(new ui::DefaultThemeProvider); |
| 335 if (params.type == InitParams::TYPE_MENU) { | 332 if (params.type == InitParams::TYPE_MENU) { |
| (...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 | 1542 |
| 1546 //////////////////////////////////////////////////////////////////////////////// | 1543 //////////////////////////////////////////////////////////////////////////////// |
| 1547 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1544 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1548 | 1545 |
| 1549 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1546 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1550 return this; | 1547 return this; |
| 1551 } | 1548 } |
| 1552 | 1549 |
| 1553 } // namespace internal | 1550 } // namespace internal |
| 1554 } // namespace views | 1551 } // namespace views |
| OLD | NEW |