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/shell_surface.h" | 5 #include "components/exo/shell_surface.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 void ShellSurface::Move() { | 174 void ShellSurface::Move() { |
175 TRACE_EVENT0("exo", "ShellSurface::Move"); | 175 TRACE_EVENT0("exo", "ShellSurface::Move"); |
176 | 176 |
177 if (widget_) { | 177 if (widget_) { |
178 widget_->RunMoveLoop(gfx::Vector2d(), views::Widget::MOVE_LOOP_SOURCE_MOUSE, | 178 widget_->RunMoveLoop(gfx::Vector2d(), views::Widget::MOVE_LOOP_SOURCE_MOUSE, |
179 views::Widget::MOVE_LOOP_ESCAPE_BEHAVIOR_DONT_HIDE); | 179 views::Widget::MOVE_LOOP_ESCAPE_BEHAVIOR_DONT_HIDE); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
| 183 void ShellSurface::SetGeometry(const gfx::Rect& geometry) { |
| 184 TRACE_EVENT1("exo", "ShellSurface::SetGeometry", "geometry", |
| 185 geometry.ToString()); |
| 186 |
| 187 if (geometry.IsEmpty()) { |
| 188 DLOG(WARNING) << "Surface geometry must be non-empty"; |
| 189 return; |
| 190 } |
| 191 |
| 192 geometry_ = geometry; |
| 193 } |
| 194 |
183 scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() | 195 scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue() |
184 const { | 196 const { |
185 scoped_refptr<base::trace_event::TracedValue> value = | 197 scoped_refptr<base::trace_event::TracedValue> value = |
186 new base::trace_event::TracedValue; | 198 new base::trace_event::TracedValue; |
187 value->SetString("title", base::UTF16ToUTF8(title_)); | 199 value->SetString("title", base::UTF16ToUTF8(title_)); |
188 value->SetString("application_id", application_id_); | 200 value->SetString("application_id", application_id_); |
189 return value; | 201 return value; |
190 } | 202 } |
191 | 203 |
192 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
193 // SurfaceDelegate overrides: | 205 // SurfaceDelegate overrides: |
194 | 206 |
195 void ShellSurface::OnSurfaceCommit() { | 207 void ShellSurface::OnSurfaceCommit() { |
196 surface_->CommitSurfaceHierarchy(); | 208 surface_->CommitSurfaceHierarchy(); |
197 if (widget_) { | 209 if (widget_) { |
198 // Update surface bounds and widget size. | 210 // Update surface bounds and widget size. |
199 gfx::Point origin; | 211 gfx::Point origin; |
200 views::View::ConvertPointToWidget(this, &origin); | 212 views::View::ConvertPointToWidget(this, &origin); |
201 surface_->SetBounds(gfx::Rect(origin, surface_->layer()->size())); | 213 surface_->SetBounds(gfx::Rect(origin - geometry_.OffsetFromOrigin(), |
| 214 surface_->layer()->size())); |
202 widget_->SetSize(widget_->non_client_view()->GetPreferredSize()); | 215 widget_->SetSize(widget_->non_client_view()->GetPreferredSize()); |
203 | 216 |
204 // Show widget if not already visible. | 217 // Show widget if not already visible. |
205 if (!widget_->IsClosed() && !widget_->IsVisible()) | 218 if (!widget_->IsClosed() && !widget_->IsVisible()) |
206 widget_->Show(); | 219 widget_->Show(); |
207 } | 220 } |
208 } | 221 } |
209 | 222 |
210 bool ShellSurface::IsSurfaceSynchronized() const { | 223 bool ShellSurface::IsSurfaceSynchronized() const { |
211 // A shell surface is always desynchronized. | 224 // A shell surface is always desynchronized. |
(...skipping 29 matching lines...) Expand all Loading... |
241 | 254 |
242 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView( | 255 views::NonClientFrameView* ShellSurface::CreateNonClientFrameView( |
243 views::Widget* widget) { | 256 views::Widget* widget) { |
244 return new CustomFrameView(widget); | 257 return new CustomFrameView(widget); |
245 } | 258 } |
246 | 259 |
247 //////////////////////////////////////////////////////////////////////////////// | 260 //////////////////////////////////////////////////////////////////////////////// |
248 // views::Views overrides: | 261 // views::Views overrides: |
249 | 262 |
250 gfx::Size ShellSurface::GetPreferredSize() const { | 263 gfx::Size ShellSurface::GetPreferredSize() const { |
| 264 if (!geometry_.IsEmpty()) |
| 265 return geometry_.size(); |
| 266 |
251 return surface_ ? surface_->GetPreferredSize() : gfx::Size(); | 267 return surface_ ? surface_->GetPreferredSize() : gfx::Size(); |
252 } | 268 } |
253 | 269 |
254 } // namespace exo | 270 } // namespace exo |
OLD | NEW |