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/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #endif | 24 #endif |
25 | 25 |
26 #if defined(HAVE_IBUS) | 26 #if defined(HAVE_IBUS) |
27 #include "views/ime/input_method_ibus.h" | 27 #include "views/ime/input_method_ibus.h" |
28 #else | 28 #else |
29 #include "views/ime/mock_input_method.h" | 29 #include "views/ime/mock_input_method.h" |
30 #endif | 30 #endif |
31 | 31 |
32 namespace views { | 32 namespace views { |
33 | 33 |
34 const char* const NativeWidgetAura::kWindowTypeKey = "WindowType"; | 34 namespace { |
| 35 |
| 36 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { |
| 37 switch (type) { |
| 38 case Widget::InitParams::TYPE_WINDOW: |
| 39 return aura::WINDOW_TYPE_NORMAL; |
| 40 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: |
| 41 case Widget::InitParams::TYPE_CONTROL: |
| 42 case Widget::InitParams::TYPE_POPUP: |
| 43 case Widget::InitParams::TYPE_BUBBLE: |
| 44 return aura::WINDOW_TYPE_POPUP; |
| 45 case Widget::InitParams::TYPE_MENU: |
| 46 return aura::WINDOW_TYPE_MENU; |
| 47 case Widget::InitParams::TYPE_TOOLTIP: |
| 48 return aura::WINDOW_TYPE_TOOLTIP; |
| 49 default: |
| 50 NOTREACHED() << "Unhandled widget type " << type; |
| 51 return aura::WINDOW_TYPE_UNKNOWN; |
| 52 } |
| 53 } |
| 54 |
| 55 } // namespace |
35 | 56 |
36 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
37 // NativeWidgetAura, public: | 58 // NativeWidgetAura, public: |
38 | 59 |
39 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) | 60 NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate) |
40 : delegate_(delegate), | 61 : delegate_(delegate), |
41 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), | 62 ALLOW_THIS_IN_INITIALIZER_LIST(window_(new aura::Window(this))), |
42 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 63 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
43 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 64 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
44 can_activate_(true), | 65 can_activate_(true), |
(...skipping 21 matching lines...) Expand all Loading... |
66 } | 87 } |
67 | 88 |
68 //////////////////////////////////////////////////////////////////////////////// | 89 //////////////////////////////////////////////////////////////////////////////// |
69 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: | 90 // NativeWidgetAura, internal::NativeWidgetPrivate implementation: |
70 | 91 |
71 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { | 92 void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) { |
72 ownership_ = params.ownership; | 93 ownership_ = params.ownership; |
73 window_->set_user_data(this); | 94 window_->set_user_data(this); |
74 Widget::InitParams::Type window_type = | 95 Widget::InitParams::Type window_type = |
75 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; | 96 params.child ? Widget::InitParams::TYPE_CONTROL : params.type; |
76 SetNativeWindowProperty(kWindowTypeKey, reinterpret_cast<void*>(window_type)); | 97 window_->SetType(GetAuraWindowTypeForWidgetType(window_type)); |
77 window_->SetType(window_type == Widget::InitParams::TYPE_CONTROL ? | |
78 aura::kWindowType_Control : aura::kWindowType_None); | |
79 window_->Init(params.create_texture_for_layer ? | 98 window_->Init(params.create_texture_for_layer ? |
80 ui::Layer::LAYER_HAS_TEXTURE : ui::Layer::LAYER_HAS_NO_TEXTURE); | 99 ui::Layer::LAYER_HAS_TEXTURE : |
| 100 ui::Layer::LAYER_HAS_NO_TEXTURE); |
| 101 if (window_type == Widget::InitParams::TYPE_CONTROL) |
| 102 window_->Show(); |
| 103 |
81 // TODO(beng): respect |params| authoritah wrt transparency. | 104 // TODO(beng): respect |params| authoritah wrt transparency. |
82 window_->layer()->SetFillsBoundsOpaquely(false); | 105 window_->layer()->SetFillsBoundsOpaquely(false); |
83 delegate_->OnNativeWidgetCreated(); | 106 delegate_->OnNativeWidgetCreated(); |
84 window_->set_minimum_size(delegate_->GetMinimumSize()); | 107 window_->set_minimum_size(delegate_->GetMinimumSize()); |
85 window_->SetBounds(params.bounds); | 108 window_->SetBounds(params.bounds); |
86 if (params.type == Widget::InitParams::TYPE_CONTROL) { | 109 if (params.type == Widget::InitParams::TYPE_CONTROL) { |
87 window_->SetParent(params.GetParent()); | 110 window_->SetParent(params.GetParent()); |
88 } else { | 111 } else { |
89 // Set up the transient child before the window is added. This way the | 112 // Set up the transient child before the window is added. This way the |
90 // LayoutManager knows the window has a transient parent. | 113 // LayoutManager knows the window has a transient parent. |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 } | 671 } |
649 | 672 |
650 // static | 673 // static |
651 bool NativeWidgetPrivate::IsMouseButtonDown() { | 674 bool NativeWidgetPrivate::IsMouseButtonDown() { |
652 NOTIMPLEMENTED(); | 675 NOTIMPLEMENTED(); |
653 return false; | 676 return false; |
654 } | 677 } |
655 | 678 |
656 } // namespace internal | 679 } // namespace internal |
657 } // namespace views | 680 } // namespace views |
OLD | NEW |