Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: components/exo/display.cc

Issue 2688483003: exo: Refactor ShellSurface and WaylandRemoteShell (Closed)
Patch Set: Revert unnecessary changes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/exo/pointer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) { 134 std::unique_ptr<ShellSurface> Display::CreateShellSurface(Surface* surface) {
135 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface", 135 TRACE_EVENT1("exo", "Display::CreateShellSurface", "surface",
136 surface->AsTracedValue()); 136 surface->AsTracedValue());
137 137
138 if (surface->HasSurfaceDelegate()) { 138 if (surface->HasSurfaceDelegate()) {
139 DLOG(ERROR) << "Surface has already been assigned a role"; 139 DLOG(ERROR) << "Surface has already been assigned a role";
140 return nullptr; 140 return nullptr;
141 } 141 }
142 142
143 return base::MakeUnique<ShellSurface>( 143 return base::MakeUnique<ShellSurface>(
144 surface, nullptr, gfx::Rect(), true /* activatable */, 144 surface, nullptr, ShellSurface::BoundsMode::SHELL, gfx::Point(),
145 false /* can_minimize */, ash::kShellWindowId_DefaultContainer); 145 true /* activatable */, false /* can_minimize */,
146 ash::kShellWindowId_DefaultContainer);
146 } 147 }
147 148
148 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface( 149 std::unique_ptr<ShellSurface> Display::CreatePopupShellSurface(
149 Surface* surface, 150 Surface* surface,
150 ShellSurface* parent, 151 ShellSurface* parent,
151 const gfx::Point& position) { 152 const gfx::Point& position) {
152 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface", 153 TRACE_EVENT2("exo", "Display::CreatePopupShellSurface", "surface",
153 surface->AsTracedValue(), "parent", parent->AsTracedValue()); 154 surface->AsTracedValue(), "parent", parent->AsTracedValue());
154 155
155 if (surface->window()->Contains(parent->GetWidget()->GetNativeWindow())) { 156 if (surface->window()->Contains(parent->GetWidget()->GetNativeWindow())) {
156 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; 157 DLOG(ERROR) << "Parent is contained within surface's hierarchy";
157 return nullptr; 158 return nullptr;
158 } 159 }
159 160
160 if (surface->HasSurfaceDelegate()) { 161 if (surface->HasSurfaceDelegate()) {
161 DLOG(ERROR) << "Surface has already been assigned a role"; 162 DLOG(ERROR) << "Surface has already been assigned a role";
162 return nullptr; 163 return nullptr;
163 } 164 }
164 165
165 // Determine the initial bounds for popup. |position| is relative to the 166 // |position| is relative to the parent's main surface origin, and |origin| is
166 // parent's main surface origin and initial bounds are in screen coordinates. 167 // in screen coordinates.
167 gfx::Point origin = position; 168 gfx::Point origin = position;
168 wm::ConvertPointToScreen( 169 wm::ConvertPointToScreen(
169 ShellSurface::GetMainSurface(parent->GetWidget()->GetNativeWindow()) 170 ShellSurface::GetMainSurface(parent->GetWidget()->GetNativeWindow())
170 ->window(), 171 ->window(),
171 &origin); 172 &origin);
172 gfx::Rect initial_bounds(origin, gfx::Size(1, 1));
173 173
174 return base::MakeUnique<ShellSurface>( 174 return base::MakeUnique<ShellSurface>(
175 surface, parent, initial_bounds, false /* activatable */, 175 surface, parent, ShellSurface::BoundsMode::FIXED, origin,
176 false /* can_minimize */, ash::kShellWindowId_DefaultContainer); 176 false /* activatable */, false /* can_minimize */,
177 ash::kShellWindowId_DefaultContainer);
177 } 178 }
178 179
179 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface( 180 std::unique_ptr<ShellSurface> Display::CreateRemoteShellSurface(
180 Surface* surface, 181 Surface* surface,
181 int container) { 182 int container) {
182 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface", 183 TRACE_EVENT2("exo", "Display::CreateRemoteShellSurface", "surface",
183 surface->AsTracedValue(), "container", container); 184 surface->AsTracedValue(), "container", container);
184 185
185 if (surface->HasSurfaceDelegate()) { 186 if (surface->HasSurfaceDelegate()) {
186 DLOG(ERROR) << "Surface has already been assigned a role"; 187 DLOG(ERROR) << "Surface has already been assigned a role";
187 return nullptr; 188 return nullptr;
188 } 189 }
189 190
190 // Remote shell surfaces in system modal container cannot be minimized. 191 // Remote shell surfaces in system modal container cannot be minimized.
191 bool can_minimize = container != ash::kShellWindowId_SystemModalContainer; 192 bool can_minimize = container != ash::kShellWindowId_SystemModalContainer;
192 193
193 return base::MakeUnique<ShellSurface>(surface, nullptr, gfx::Rect(1, 1), 194 return base::MakeUnique<ShellSurface>(
194 true /* activatable */, can_minimize, 195 surface, nullptr, ShellSurface::BoundsMode::CLIENT, gfx::Point(),
195 container); 196 true /* activatable */, can_minimize, container);
196 } 197 }
197 198
198 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface, 199 std::unique_ptr<SubSurface> Display::CreateSubSurface(Surface* surface,
199 Surface* parent) { 200 Surface* parent) {
200 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface", 201 TRACE_EVENT2("exo", "Display::CreateSubSurface", "surface",
201 surface->AsTracedValue(), "parent", parent->AsTracedValue()); 202 surface->AsTracedValue(), "parent", parent->AsTracedValue());
202 203
203 if (surface->window()->Contains(parent->window())) { 204 if (surface->window()->Contains(parent->window())) {
204 DLOG(ERROR) << "Parent is contained within surface's hierarchy"; 205 DLOG(ERROR) << "Parent is contained within surface's hierarchy";
205 return nullptr; 206 return nullptr;
(...skipping 17 matching lines...) Expand all
223 notification_surface_manager_->GetSurface(notification_id)) { 224 notification_surface_manager_->GetSurface(notification_id)) {
224 DLOG(ERROR) << "Invalid notification id, id=" << notification_id; 225 DLOG(ERROR) << "Invalid notification id, id=" << notification_id;
225 return nullptr; 226 return nullptr;
226 } 227 }
227 228
228 return base::MakeUnique<NotificationSurface>(notification_surface_manager_, 229 return base::MakeUnique<NotificationSurface>(notification_surface_manager_,
229 surface, notification_id); 230 surface, notification_id);
230 } 231 }
231 232
232 } // namespace exo 233 } // namespace exo
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698