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

Side by Side Diff: ash/common/wm/overview/scoped_transform_overview_window.cc

Issue 2470343003: Use mirror layer for minimized windows in overview mode (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/wm/overview/scoped_transform_overview_window.h" 5 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" 10 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
11 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" 11 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
12 #include "ash/common/wm/overview/window_selector_item.h" 12 #include "ash/common/wm/overview/window_selector_item.h"
13 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm_lookup.h"
15 #include "ash/common/wm_root_window_controller.h"
16 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 17 #include "ash/common/wm_window.h"
15 #include "ash/common/wm_window_property.h" 18 #include "ash/common/wm_window_property.h"
16 #include "base/macros.h" 19 #include "base/macros.h"
17 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
18 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
19 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
20 #include "ui/gfx/geometry/rect.h" 23 #include "ui/gfx/geometry/rect.h"
21 #include "ui/gfx/geometry/safe_integer_conversions.h" 24 #include "ui/gfx/geometry/safe_integer_conversions.h"
22 #include "ui/gfx/transform_util.h" 25 #include "ui/gfx/transform_util.h"
26 #include "ui/views/widget/widget.h"
23 27
24 using WmWindows = std::vector<ash::WmWindow*>; 28 using WmWindows = std::vector<ash::WmWindow*>;
25 29
26 namespace ash { 30 namespace ash {
27 31
28 namespace { 32 namespace {
29 33
30 // When set to true by tests makes closing the widget synchronous. 34 // When set to true by tests makes closing the widget synchronous.
31 bool immediate_close_for_tests = false; 35 bool immediate_close_for_tests = false;
32 36
33 // The opacity level that windows will be set to when they are restored.
34 const float kRestoreWindowOpacity = 1.0f;
35
36 // Delay closing window to allow it to shrink and fade out. 37 // Delay closing window to allow it to shrink and fade out.
37 const int kCloseWindowDelayInMilliseconds = 150; 38 const int kCloseWindowDelayInMilliseconds = 150;
38 39
39 WmWindow* GetTransientRoot(WmWindow* window) { 40 WmWindow* GetTransientRoot(WmWindow* window) {
40 while (window && window->GetTransientParent()) 41 while (window && window->GetTransientParent())
41 window = window->GetTransientParent(); 42 window = window->GetTransientParent();
42 return window; 43 return window;
43 } 44 }
44 45
45 std::unique_ptr<ScopedOverviewAnimationSettings> 46 std::unique_ptr<ScopedOverviewAnimationSettings>
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 TransientDescendantIteratorRange GetTransientTreeIterator(WmWindow* window) { 163 TransientDescendantIteratorRange GetTransientTreeIterator(WmWindow* window) {
163 return TransientDescendantIteratorRange( 164 return TransientDescendantIteratorRange(
164 TransientDescendantIterator(GetTransientRoot(window))); 165 TransientDescendantIterator(GetTransientRoot(window)));
165 } 166 }
166 167
167 } // namespace 168 } // namespace
168 169
169 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(WmWindow* window) 170 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(WmWindow* window)
170 : window_(window), 171 : window_(window),
171 determined_original_window_shape_(false), 172 determined_original_window_shape_(false),
172 original_visibility_(
173 window->GetWindowState()->GetStateType() ==
174 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED
175 ? ORIGINALLY_DOCKED_MINIMIZED
176 : (window->GetShowState() == ui::SHOW_STATE_MINIMIZED
177 ? ORIGINALLY_MINIMIZED
178 : ORIGINALLY_VISIBLE)),
179 ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()), 173 ignored_by_shelf_(window->GetWindowState()->ignored_by_shelf()),
180 overview_started_(false), 174 overview_started_(false),
181 original_transform_(window->GetTargetTransform()), 175 original_transform_(window->GetTargetTransform()),
182 original_opacity_(window->GetTargetOpacity()),
183 weak_ptr_factory_(this) {} 176 weak_ptr_factory_(this) {}
184 177
185 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} 178 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {}
186 179
187 void ScopedTransformOverviewWindow::RestoreWindow() { 180 void ScopedTransformOverviewWindow::RestoreWindow() {
181 if (minimized_) {
182 // TODO(oshima): Use unminimize animation instead of hiding animation.
183 minimized_->CloseNow();
184 minimized_.reset();
185 return;
186 }
188 ScopedAnimationSettings animation_settings_list; 187 ScopedAnimationSettings animation_settings_list;
189 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW, 188 BeginScopedAnimation(OverviewAnimationType::OVERVIEW_ANIMATION_RESTORE_WINDOW,
190 &animation_settings_list); 189 &animation_settings_list);
191 SetTransform(window()->GetRootWindow(), original_transform_); 190 SetTransform(window()->GetRootWindow(), original_transform_);
192
193 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 191 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
194 CreateScopedOverviewAnimationSettings( 192 CreateScopedOverviewAnimationSettings(
195 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS, 193 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS,
196 window_); 194 window_);
197 gfx::Transform transform;
198 if ((original_visibility_ == ORIGINALLY_MINIMIZED &&
199 window_->GetShowState() != ui::SHOW_STATE_MINIMIZED) ||
200 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED &&
201 window_->GetWindowState()->GetStateType() !=
202 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) {
203 // Setting opacity 0 and visible false ensures that the property change
204 // to SHOW_STATE_MINIMIZED will not animate the window from its original
205 // bounds to the minimized position.
206 // Hiding the window needs to be done before the target opacity is 0,
207 // otherwise the layer's visibility will not be updated
208 // (See VisibilityController::UpdateLayerVisibility).
209 window_->Hide();
210 window_->SetOpacity(0);
211 window_->SetShowState(ui::SHOW_STATE_MINIMIZED);
212 }
213 window_->GetWindowState()->set_ignored_by_shelf(ignored_by_shelf_); 195 window_->GetWindowState()->set_ignored_by_shelf(ignored_by_shelf_);
214 SetOpacity(original_opacity_);
215 ShowHeader(); 196 ShowHeader();
216 } 197 }
217 198
218 void ScopedTransformOverviewWindow::BeginScopedAnimation( 199 void ScopedTransformOverviewWindow::BeginScopedAnimation(
219 OverviewAnimationType animation_type, 200 OverviewAnimationType animation_type,
220 ScopedAnimationSettings* animation_settings) { 201 ScopedAnimationSettings* animation_settings) {
221 for (auto* window : GetTransientTreeIterator(window_)) { 202 for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) {
222 animation_settings->push_back( 203 animation_settings->push_back(
223 CreateScopedOverviewAnimationSettings(animation_type, window)); 204 CreateScopedOverviewAnimationSettings(animation_type, window));
224 } 205 }
225 } 206 }
226 207
227 bool ScopedTransformOverviewWindow::Contains(const WmWindow* target) const { 208 bool ScopedTransformOverviewWindow::Contains(const WmWindow* target) const {
228 for (auto* window : GetTransientTreeIterator(window_)) { 209 for (auto* window : GetTransientTreeIterator(window_)) {
229 if (window->Contains(target)) 210 if (window->Contains(target))
230 return true; 211 return true;
231 } 212 }
232 return false; 213 WmWindow* mirror = GetOverviewWindowForMinimizedState();
214 return mirror && mirror->Contains(target);
233 } 215 }
234 216
235 gfx::Rect ScopedTransformOverviewWindow::GetTargetBoundsInScreen() const { 217 gfx::Rect ScopedTransformOverviewWindow::GetTargetBoundsInScreen() const {
236 gfx::Rect bounds; 218 gfx::Rect bounds;
237 for (auto* window : GetTransientTreeIterator(window_)) { 219 WmWindow* overview_window = GetOverviewWindow();
220 for (auto* window : GetTransientTreeIterator(overview_window)) {
238 // Ignore other window types when computing bounding box of window 221 // Ignore other window types when computing bounding box of window
239 // selector target item. 222 // selector target item.
240 if (window != window_ && window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && 223 if (window != overview_window &&
224 window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
241 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) { 225 window->GetType() != ui::wm::WINDOW_TYPE_PANEL) {
242 continue; 226 continue;
243 } 227 }
244 bounds.Union( 228 bounds.Union(
245 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds())); 229 window->GetParent()->ConvertRectToScreen(window->GetTargetBounds()));
246 } 230 }
247 return bounds; 231 return bounds;
248 } 232 }
249 233
250 gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds() const { 234 gfx::Rect ScopedTransformOverviewWindow::GetTransformedBounds() const {
251 if (window_->GetWindowState()->IsMinimized())
252 return window_->GetMinimizeAnimationTargetBoundsInScreen();
253
254 const int top_inset = GetTopInset(); 235 const int top_inset = GetTopInset();
255 gfx::Rect bounds; 236 gfx::Rect bounds;
256 for (auto* window : GetTransientTreeIterator(window_)) { 237 WmWindow* overview_window = GetOverviewWindow();
238 for (auto* window : GetTransientTreeIterator(overview_window)) {
257 // Ignore other window types when computing bounding box of window 239 // Ignore other window types when computing bounding box of window
258 // selector target item. 240 // selector target item.
259 if (window != window_ && (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL && 241 if (window != overview_window &&
260 window->GetType() != ui::wm::WINDOW_TYPE_PANEL)) { 242 (window->GetType() != ui::wm::WINDOW_TYPE_NORMAL &&
243 window->GetType() != ui::wm::WINDOW_TYPE_PANEL)) {
261 continue; 244 continue;
262 } 245 }
263 gfx::RectF window_bounds(window->GetTargetBounds()); 246 gfx::RectF window_bounds(window->GetTargetBounds());
264 gfx::Transform new_transform = 247 gfx::Transform new_transform =
265 TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()), 248 TransformAboutPivot(gfx::Point(window_bounds.x(), window_bounds.y()),
266 window->GetTargetTransform()); 249 window->GetTargetTransform());
267 new_transform.TransformRect(&window_bounds); 250 new_transform.TransformRect(&window_bounds);
268 251
269 // The preview title is shown above the preview window. Hide the window 252 // The preview title is shown above the preview window. Hide the window
270 // header for apps or browser windows with no tabs (web apps) to avoid 253 // header for apps or browser windows with no tabs (web apps) to avoid
(...skipping 16 matching lines...) Expand all
287 // windows are shown in the same overview item and the header is not masked. 270 // windows are shown in the same overview item and the header is not masked.
288 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL || 271 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
289 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) { 272 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
290 return SK_ColorTRANSPARENT; 273 return SK_ColorTRANSPARENT;
291 } 274 }
292 } 275 }
293 return window_->GetColorProperty(WmWindowProperty::TOP_VIEW_COLOR); 276 return window_->GetColorProperty(WmWindowProperty::TOP_VIEW_COLOR);
294 } 277 }
295 278
296 int ScopedTransformOverviewWindow::GetTopInset() const { 279 int ScopedTransformOverviewWindow::GetTopInset() const {
280 // Mirror window doesn't have insets.
281 if (minimized_)
282 return 0;
varkha 2016/11/08 00:02:56 I don't think this is right. I tried it with the w
oshima 2016/11/10 23:58:47 Updated the mirror window to do the right thing an
297 for (auto* window : GetTransientTreeIterator(window_)) { 283 for (auto* window : GetTransientTreeIterator(window_)) {
298 // If there are regular windows in the transient ancestor tree, all those 284 // If there are regular windows in the transient ancestor tree, all those
299 // windows are shown in the same overview item and the header is not masked. 285 // windows are shown in the same overview item and the header is not masked.
300 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL || 286 if (window != window_ && (window->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
301 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) { 287 window->GetType() == ui::wm::WINDOW_TYPE_PANEL)) {
302 return 0; 288 return 0;
303 } 289 }
304 } 290 }
305 return window_->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET); 291 return window_->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET);
306 } 292 }
307 293
308 void ScopedTransformOverviewWindow::ShowWindowIfMinimized() {
309 if ((original_visibility_ == ORIGINALLY_MINIMIZED &&
310 window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) ||
311 (original_visibility_ == ORIGINALLY_DOCKED_MINIMIZED &&
312 window_->GetWindowState()->GetStateType() ==
313 wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED)) {
314 window_->Show();
315 }
316 }
317
318 void ScopedTransformOverviewWindow::ShowWindowOnExit() {
319 if (original_visibility_ != ORIGINALLY_VISIBLE) {
320 original_visibility_ = ORIGINALLY_VISIBLE;
321 original_transform_ = gfx::Transform();
322 original_opacity_ = kRestoreWindowOpacity;
323 }
324 }
325
326 void ScopedTransformOverviewWindow::OnWindowDestroyed() { 294 void ScopedTransformOverviewWindow::OnWindowDestroyed() {
327 window_ = nullptr; 295 window_ = nullptr;
328 } 296 }
329 297
330 float ScopedTransformOverviewWindow::GetItemScale(const gfx::Size& source, 298 float ScopedTransformOverviewWindow::GetItemScale(const gfx::Size& source,
331 const gfx::Size& target, 299 const gfx::Size& target,
332 int top_view_inset, 300 int top_view_inset,
333 int title_height) { 301 int title_height) {
334 return std::min(2.0f, static_cast<float>((target.height() - title_height)) / 302 return std::min(2.0f, static_cast<float>((target.height() - title_height)) /
335 (source.height() - top_view_inset)); 303 (source.height() - top_view_inset));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 341
374 if (&transform != &original_transform_ && 342 if (&transform != &original_transform_ &&
375 !determined_original_window_shape_) { 343 !determined_original_window_shape_) {
376 determined_original_window_shape_ = true; 344 determined_original_window_shape_ = true;
377 SkRegion* window_shape = window()->GetLayer()->alpha_shape(); 345 SkRegion* window_shape = window()->GetLayer()->alpha_shape();
378 if (!original_window_shape_ && window_shape) 346 if (!original_window_shape_ && window_shape)
379 original_window_shape_.reset(new SkRegion(*window_shape)); 347 original_window_shape_.reset(new SkRegion(*window_shape));
380 } 348 }
381 349
382 gfx::Point target_origin(GetTargetBoundsInScreen().origin()); 350 gfx::Point target_origin(GetTargetBoundsInScreen().origin());
383 351 for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) {
384 for (auto* window : GetTransientTreeIterator(window_)) {
385 WmWindow* parent_window = window->GetParent(); 352 WmWindow* parent_window = window->GetParent();
386 gfx::Point original_origin = 353 gfx::Point original_origin =
387 parent_window->ConvertRectToScreen(window->GetTargetBounds()).origin(); 354 parent_window->ConvertRectToScreen(window->GetTargetBounds()).origin();
388 gfx::Transform new_transform = 355 gfx::Transform new_transform =
389 TransformAboutPivot(gfx::Point(target_origin.x() - original_origin.x(), 356 TransformAboutPivot(gfx::Point(target_origin.x() - original_origin.x(),
390 target_origin.y() - original_origin.y()), 357 target_origin.y() - original_origin.y()),
391 transform); 358 transform);
392 window->SetTransform(new_transform); 359 window->SetTransform(new_transform);
393 } 360 }
394 } 361 }
395 362
396 void ScopedTransformOverviewWindow::SetOpacity(float opacity) { 363 void ScopedTransformOverviewWindow::SetOpacity(float opacity) {
397 for (auto* window : GetTransientTreeIterator(window_)) { 364 for (auto* window : GetTransientTreeIterator(GetOverviewWindow())) {
398 window->SetOpacity(opacity); 365 window->SetOpacity(opacity);
399 } 366 }
400 } 367 }
401 368
402 void ScopedTransformOverviewWindow::HideHeader() { 369 void ScopedTransformOverviewWindow::HideHeader() {
370 // Mirrored Window does not have a header.
371 if (minimized_)
372 return;
varkha 2016/11/08 00:02:56 Ditto.
403 gfx::Rect bounds(GetTargetBoundsInScreen().size()); 373 gfx::Rect bounds(GetTargetBoundsInScreen().size());
404 const int inset = GetTopInset(); 374 const int inset = GetTopInset();
405 if (inset > 0) { 375 if (inset > 0) {
406 // Use alpha shape to hide the window header. 376 // Use alpha shape to hide the window header.
407 bounds.Inset(0, inset, 0, 0); 377 bounds.Inset(0, inset, 0, 0);
408 std::unique_ptr<SkRegion> region(new SkRegion); 378 std::unique_ptr<SkRegion> region(new SkRegion);
409 region->setRect(RectToSkIRect(bounds)); 379 region->setRect(RectToSkIRect(bounds));
410 if (original_window_shape_) 380 if (original_window_shape_)
411 region->op(*original_window_shape_, SkRegion::kIntersect_Op); 381 region->op(*original_window_shape_, SkRegion::kIntersect_Op);
412 window()->GetLayer()->SetAlphaShape(std::move(region)); 382 WmWindow* window = GetOverviewWindow();
413 window()->SetMasksToBounds(true); 383 window->GetLayer()->SetAlphaShape(std::move(region));
384 window->SetMasksToBounds(true);
414 } 385 }
415 } 386 }
416 387
417 void ScopedTransformOverviewWindow::ShowHeader() { 388 void ScopedTransformOverviewWindow::ShowHeader() {
418 ui::Layer* layer = window()->GetLayer(); 389 ui::Layer* layer = window()->GetLayer();
419 if (original_window_shape_) { 390 if (original_window_shape_) {
420 layer->SetAlphaShape( 391 layer->SetAlphaShape(
421 base::MakeUnique<SkRegion>(*original_window_shape_.get())); 392 base::MakeUnique<SkRegion>(*original_window_shape_.get()));
422 } else { 393 } else {
423 layer->SetAlphaShape(nullptr); 394 layer->SetAlphaShape(nullptr);
424 } 395 }
425 window()->SetMasksToBounds(false); 396 window()->SetMasksToBounds(false);
426 } 397 }
427 398
399 void ScopedTransformOverviewWindow::UpdateMirrorWindowForMinimizedState() {
400 // TODO(oshima): Disable animation.
401 if (window_->GetShowState() == ui::SHOW_STATE_MINIMIZED) {
402 if (!minimized_.get())
403 CreateMirrorWindowForMinimizedState();
404 } else {
405 minimized_->CloseNow();
406 minimized_.reset();
407 }
408 }
409
428 void ScopedTransformOverviewWindow::Close() { 410 void ScopedTransformOverviewWindow::Close() {
429 if (immediate_close_for_tests) { 411 if (immediate_close_for_tests) {
430 CloseWidget(); 412 CloseWidget();
431 return; 413 return;
432 } 414 }
433 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 415 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
434 FROM_HERE, base::Bind(&ScopedTransformOverviewWindow::CloseWidget, 416 FROM_HERE, base::Bind(&ScopedTransformOverviewWindow::CloseWidget,
435 weak_ptr_factory_.GetWeakPtr()), 417 weak_ptr_factory_.GetWeakPtr()),
436 base::TimeDelta::FromMilliseconds(kCloseWindowDelayInMilliseconds)); 418 base::TimeDelta::FromMilliseconds(kCloseWindowDelayInMilliseconds));
437 } 419 }
438 420
439 void ScopedTransformOverviewWindow::PrepareForOverview() { 421 void ScopedTransformOverviewWindow::PrepareForOverview() {
440 DCHECK(!overview_started_); 422 DCHECK(!overview_started_);
441 overview_started_ = true; 423 overview_started_ = true;
442 window_->GetWindowState()->set_ignored_by_shelf(true); 424 window_->GetWindowState()->set_ignored_by_shelf(true);
443 ShowWindowIfMinimized(); 425 if (window_->GetShowState() == ui::SHOW_STATE_MINIMIZED)
426 CreateMirrorWindowForMinimizedState();
444 } 427 }
445 428
446 void ScopedTransformOverviewWindow::CloseWidget() { 429 void ScopedTransformOverviewWindow::CloseWidget() {
447 WmWindow* parent_window = GetTransientRoot(window_); 430 WmWindow* parent_window = GetTransientRoot(window_);
448 if (parent_window) 431 if (parent_window)
449 parent_window->CloseWidget(); 432 parent_window->CloseWidget();
450 } 433 }
451 434
452 // static 435 // static
453 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() { 436 void ScopedTransformOverviewWindow::SetImmediateCloseForTests() {
454 immediate_close_for_tests = true; 437 immediate_close_for_tests = true;
455 } 438 }
456 439
440 WmWindow* ScopedTransformOverviewWindow::GetOverviewWindow() const {
441 if (minimized_)
442 return GetOverviewWindowForMinimizedState();
443 return window_;
444 }
445
446 void ScopedTransformOverviewWindow::OnGestureEvent(ui::GestureEvent* event) {
447 if (event->type() == ui::ET_GESTURE_TAP) {
448 window_->Show();
449 window_->Activate();
450 }
451 }
452
453 void ScopedTransformOverviewWindow::OnMouseEvent(ui::MouseEvent* event) {
454 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton()) {
455 window_->Show();
456 window_->Activate();
457 }
458 }
459
460 WmWindow* ScopedTransformOverviewWindow::GetOverviewWindowForMinimizedState()
461 const {
462 return minimized_ ? WmLookup::Get()->GetWindowForWidget(minimized_.get())
463 : nullptr;
464 }
465
466 void ScopedTransformOverviewWindow::CreateMirrorWindowForMinimizedState() {
467 DCHECK(!minimized_.get());
468 views::Widget::InitParams params;
469 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
470 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
471 params.visible_on_all_workspaces = true;
472 params.name = "OverviewModeMinmized";
varkha 2016/11/08 00:02:56 nit: s/OverviewModeMinmized/OverviewModeMinimized
oshima 2016/11/10 23:58:47 Done.
473 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO;
474 params.accept_events = true;
475 minimized_.reset(new views::Widget);
476 window_->GetRootWindow()
477 ->GetRootWindowController()
478 ->ConfigureWidgetInitParamsForContainer(
479 minimized_.get(), window_->GetParent()->GetShellWindowId(), &params);
480 minimized_->set_focus_on_creation(false);
481 minimized_->Init(params);
482
483 views::View* mirror_view = window_->CreateViewWithRecreatedLayers().release();
484 mirror_view->SetVisible(true);
485 mirror_view->SetTargetHandler(this);
486 minimized_->SetContentsView(mirror_view);
487 gfx::Rect bounds(window_->GetBoundsInScreen());
488 gfx::Size preferred = mirror_view->GetPreferredSize();
489 // In unit tests, the content view can have empty size.
490 if (!preferred.IsEmpty()) {
491 int inset = bounds.height() - preferred.height();
492 bounds.Inset(0, 0, 0, inset);
493 }
494 minimized_->SetBounds(bounds);
495 minimized_->Show();
496 }
497
457 } // namespace ash 498 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698