OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/exo/display.h" | 5 #include "components/exo/display.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { | 103 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { |
104 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", | 104 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", |
105 surface->AsTracedValue()); | 105 surface->AsTracedValue()); |
106 | 106 |
107 if (surface->HasSurfaceDelegate()) { | 107 if (surface->HasSurfaceDelegate()) { |
108 DLOG(ERROR) << "Surface has already been assigned a role"; | 108 DLOG(ERROR) << "Surface has already been assigned a role"; |
109 return nullptr; | 109 return nullptr; |
110 } | 110 } |
111 | 111 |
112 return base::WrapUnique(new ShellSurface( | 112 return base::WrapUnique( |
113 surface, nullptr, gfx::Rect(), true /* activatable */, | 113 new ShellSurface(surface, nullptr, gfx::Rect(), true /* activatable */, |
114 true /* resizeable */, ash::kShellWindowId_DefaultContainer)); | 114 ash::kShellWindowId_DefaultContainer)); |
115 } | 115 } |
116 | 116 |
117 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface( | 117 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface( |
118 Surface* surface, | 118 Surface* surface, |
119 ShellSurface* parent, | 119 ShellSurface* parent, |
120 const gfx::Point& position) { | 120 const gfx::Point& position) { |
121 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface", | 121 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface", |
122 surface->AsTracedValue(), "parent", parent->AsTracedValue()); | 122 surface->AsTracedValue(), "parent", parent->AsTracedValue()); |
123 | 123 |
124 if (surface->Contains(parent->GetWidget()->GetNativeWindow())) { | 124 if (surface->Contains(parent->GetWidget()->GetNativeWindow())) { |
125 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; | 125 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; |
126 return nullptr; | 126 return nullptr; |
127 } | 127 } |
128 | 128 |
129 if (surface->HasSurfaceDelegate()) { | 129 if (surface->HasSurfaceDelegate()) { |
130 DLOG(ERROR) << "Surface has already been assigned a role"; | 130 DLOG(ERROR) << "Surface has already been assigned a role"; |
131 return nullptr; | 131 return nullptr; |
132 } | 132 } |
133 | 133 |
| 134 // Determine the initial bounds for popup. |position| is relative to the |
| 135 // parent's main surface origin and initial bounds are relative to the |
| 136 // container origin. |
| 137 gfx::Rect initial_bounds(position, gfx::Size(1, 1)); |
| 138 aura::Window::ConvertRectToTarget( |
| 139 ShellSurface::GetMainSurface(parent->GetWidget()->GetNativeWindow()), |
| 140 parent->GetWidget()->GetNativeWindow()->parent(), &initial_bounds); |
| 141 |
134 return base::WrapUnique( | 142 return base::WrapUnique( |
135 new ShellSurface(surface, parent, gfx::Rect(position, gfx::Size(1, 1)), | 143 new ShellSurface(surface, parent, initial_bounds, false /* activatable */, |
136 false /* activatable */, true /* resizeable */, | |
137 ash::kShellWindowId_DefaultContainer)); | 144 ash::kShellWindowId_DefaultContainer)); |
138 } | 145 } |
139 | 146 |
140 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface( | 147 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface( |
141 Surface* surface, | 148 Surface* surface, |
142 int container) { | 149 int container) { |
143 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface", | 150 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface", |
144 surface->AsTracedValue(), "container", container); | 151 surface->AsTracedValue(), "container", container); |
145 | 152 |
146 if (surface->HasSurfaceDelegate()) { | 153 if (surface->HasSurfaceDelegate()) { |
147 DLOG(ERROR) << "Surface has already been assigned a role"; | 154 DLOG(ERROR) << "Surface has already been assigned a role"; |
148 return nullptr; | 155 return nullptr; |
149 } | 156 } |
150 | 157 |
151 return base::WrapUnique(new ShellSurface(surface, nullptr, gfx::Rect(1, 1), | 158 return base::WrapUnique(new ShellSurface(surface, nullptr, gfx::Rect(1, 1), |
152 true /* activatable */, | 159 true /* activatable */, container)); |
153 false /* resizeable */, container)); | |
154 } | 160 } |
155 | 161 |
156 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, | 162 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, |
157 Surface* parent) { | 163 Surface* parent) { |
158 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", | 164 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", |
159 surface->AsTracedValue(), "parent", parent->AsTracedValue()); | 165 surface->AsTracedValue(), "parent", parent->AsTracedValue()); |
160 | 166 |
161 if (surface->Contains(parent)) { | 167 if (surface->Contains(parent)) { |
162 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; | 168 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; |
163 return nullptr; | 169 return nullptr; |
164 } | 170 } |
165 | 171 |
166 if (surface->HasSurfaceDelegate()) { | 172 if (surface->HasSurfaceDelegate()) { |
167 DLOG(ERROR) << "Surface has already been assigned a role"; | 173 DLOG(ERROR) << "Surface has already been assigned a role"; |
168 return nullptr; | 174 return nullptr; |
169 } | 175 } |
170 | 176 |
171 return base::WrapUnique(new SubSurface(surface, parent)); | 177 return base::WrapUnique(new SubSurface(surface, parent)); |
172 } | 178 } |
173 | 179 |
174 } // namespace exo | 180 } // namespace exo |
OLD | NEW |