OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/mus/bridge/wm_window_mus.h" | 5 #include "ash/mus/bridge/wm_window_mus.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_item_types.h" | 7 #include "ash/common/shelf/shelf_item_types.h" |
8 #include "ash/common/wm/container_finder.h" | 8 #include "ash/common/wm/container_finder.h" |
9 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 WmRootWindowController* WmWindowMus::GetRootWindowController() { | 69 WmRootWindowController* WmWindowMus::GetRootWindowController() { |
70 return GetRootWindowControllerMus(); | 70 return GetRootWindowControllerMus(); |
71 } | 71 } |
72 | 72 |
73 WmShell* WmWindowMus::GetShell() const { | 73 WmShell* WmWindowMus::GetShell() const { |
74 return WmShellMus::Get(); | 74 return WmShellMus::Get(); |
75 } | 75 } |
76 | 76 |
77 int WmWindowMus::GetIntProperty(WmWindowProperty key) { | |
78 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | |
79 if (aura_window()->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) | |
80 return aura_window()->GetProperty(kShelfItemTypeKey); | |
81 | |
82 // Mash provides a default shelf item type for non-ignored windows. | |
83 return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP; | |
84 } | |
85 | |
86 return WmWindowAura::GetIntProperty(key); | |
87 } | |
88 | |
89 // TODO(sky): investigate if needed. | |
90 bool WmWindowMus::MoveToEventRoot(const ui::Event& event) { | |
91 views::View* target = static_cast<views::View*>(event.target()); | |
92 if (!target) | |
93 return false; | |
94 WmWindow* target_root = | |
95 WmLookup::Get()->GetWindowForWidget(target->GetWidget())->GetRootWindow(); | |
96 if (!target_root || target_root == GetRootWindow()) | |
97 return false; | |
98 WmWindow* window_container = | |
99 target_root->GetChildByShellWindowId(GetParent()->GetShellWindowId()); | |
100 window_container->AddChild(this); | |
101 return true; | |
102 } | |
103 | |
104 // TODO(sky): investigate if needed. | |
105 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | |
106 const display::Display& dst_display) { | |
107 DCHECK(GetParent()); // Aura code assumed a parent, so this does too. | |
108 if (static_cast<const WmWindowMus*>(GetParent()) | |
109 ->child_bounds_in_screen_behavior_ == | |
110 BoundsInScreenBehavior::USE_LOCAL_COORDINATES) { | |
111 SetBounds(bounds_in_screen); | |
112 return; | |
113 } | |
114 wm::SetBoundsInScreen(this, bounds_in_screen, dst_display); | |
115 } | |
116 | |
117 // TODO(sky): remove this override. | |
118 void WmWindowMus::SetPinned(bool trusted) { | |
119 // http://crbug.com/622486. | |
120 NOTIMPLEMENTED(); | |
121 } | |
122 | |
123 void WmWindowMus::CloseWidget() { | 77 void WmWindowMus::CloseWidget() { |
124 views::Widget* widget = views::Widget::GetWidgetForNativeView(aura_window()); | 78 views::Widget* widget = views::Widget::GetWidgetForNativeView(aura_window()); |
125 DCHECK(widget); | 79 DCHECK(widget); |
126 // Allow the client to service the close request for remote widgets. | 80 // Allow the client to service the close request for remote widgets. |
127 if (aura_window()->GetProperty(kWidgetCreationTypeKey) == | 81 if (aura_window()->GetProperty(kWidgetCreationTypeKey) == |
128 WidgetCreationType::FOR_CLIENT) { | 82 WidgetCreationType::FOR_CLIENT) { |
129 WmShellMus::Get()->window_manager()->window_manager_client()->RequestClose( | 83 WmShellMus::Get()->window_manager()->window_manager_client()->RequestClose( |
130 aura_window()); | 84 aura_window()); |
131 } else { | 85 } else { |
132 widget->Close(); | 86 widget->Close(); |
133 } | 87 } |
134 } | 88 } |
135 | 89 |
136 // TODO(sky): investigate if needed. | |
137 bool WmWindowMus::CanActivate() const { | |
138 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not | |
139 // replicated. | |
140 // TODO(sky): fix const cast (most likely remove this override entirely). | |
141 return WmWindowAura::CanActivate() && | |
142 views::Widget::GetWidgetForNativeView( | |
143 const_cast<aura::Window*>(aura_window())) != nullptr; | |
144 } | |
145 | |
146 void WmWindowMus::ShowResizeShadow(int component) { | |
147 // TODO: http://crbug.com/640773. | |
148 NOTIMPLEMENTED(); | |
149 } | |
150 | |
151 void WmWindowMus::HideResizeShadow() { | |
152 // TODO: http://crbug.com/640773. | |
153 NOTIMPLEMENTED(); | |
154 } | |
155 | |
156 void WmWindowMus::InstallResizeHandleWindowTargeter( | |
157 ImmersiveFullscreenController* immersive_fullscreen_controller) { | |
158 // TODO(sky): I believe once ImmersiveFullscreenController is ported this | |
159 // won't be necessary in mash, but I need to verify that: | |
160 // http://crbug.com/548435. | |
161 } | |
162 | |
163 // TODO: nuke this once SetBoundsInScreen() is updated. | |
164 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( | |
165 WmWindow::BoundsInScreenBehavior behavior) { | |
166 child_bounds_in_screen_behavior_ = behavior; | |
167 } | |
168 | |
169 void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) { | 90 void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) { |
170 DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient( | 91 DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient( |
171 aura::WindowMus::Get(aura_window()))); | 92 aura::WindowMus::Get(aura_window()))); |
172 WmWindowAura::AddLimitedPreTargetHandler(handler); | 93 WmWindowAura::AddLimitedPreTargetHandler(handler); |
173 } | 94 } |
174 | 95 |
175 } // namespace mus | 96 } // namespace mus |
176 } // namespace ash | 97 } // namespace ash |
OLD | NEW |