OLD | NEW |
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/wm/overview/scoped_transform_overview_window.h" | 5 #include "ash/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/wm/overview/scoped_overview_animation_settings.h" | 10 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
11 #include "ash/wm/overview/window_selector_item.h" | 11 #include "ash/wm/overview/window_selector_item.h" |
| 12 #include "ash/wm/splitview/split_view_controller.h" |
12 #include "ash/wm/window_mirror_view.h" | 13 #include "ash/wm/window_mirror_view.h" |
13 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
14 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "ui/aura/client/aura_constants.h" | 20 #include "ui/aura/client/aura_constants.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
21 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 158 |
158 TransientDescendantIteratorRange GetTransientTreeIterator( | 159 TransientDescendantIteratorRange GetTransientTreeIterator( |
159 aura::Window* window) { | 160 aura::Window* window) { |
160 return TransientDescendantIteratorRange( | 161 return TransientDescendantIteratorRange( |
161 TransientDescendantIterator(GetTransientRoot(window))); | 162 TransientDescendantIterator(GetTransientRoot(window))); |
162 } | 163 } |
163 | 164 |
164 } // namespace | 165 } // namespace |
165 | 166 |
166 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow( | 167 ScopedTransformOverviewWindow::ScopedTransformOverviewWindow( |
| 168 WindowSelectorItem* selector_item, |
167 aura::Window* window) | 169 aura::Window* window) |
168 : window_(window), | 170 : selector_item_(selector_item), |
| 171 window_(window), |
169 determined_original_window_shape_(false), | 172 determined_original_window_shape_(false), |
170 ignored_by_shelf_(wm::GetWindowState(window)->ignored_by_shelf()), | 173 ignored_by_shelf_(wm::GetWindowState(window)->ignored_by_shelf()), |
171 overview_started_(false), | 174 overview_started_(false), |
172 original_transform_(window->layer()->GetTargetTransform()), | 175 original_transform_(window->layer()->GetTargetTransform()), |
173 original_opacity_(window->layer()->GetTargetOpacity()), | 176 original_opacity_(window->layer()->GetTargetOpacity()), |
174 weak_ptr_factory_(this) {} | 177 weak_ptr_factory_(this) {} |
175 | 178 |
176 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} | 179 ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {} |
177 | 180 |
178 void ScopedTransformOverviewWindow::RestoreWindow() { | 181 void ScopedTransformOverviewWindow::RestoreWindow() { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 if (minimized_widget_) | 449 if (minimized_widget_) |
447 return GetOverviewWindowForMinimizedState(); | 450 return GetOverviewWindowForMinimizedState(); |
448 return window_; | 451 return window_; |
449 } | 452 } |
450 | 453 |
451 void ScopedTransformOverviewWindow::EnsureVisible() { | 454 void ScopedTransformOverviewWindow::EnsureVisible() { |
452 original_opacity_ = 1.f; | 455 original_opacity_ = 1.f; |
453 } | 456 } |
454 | 457 |
455 void ScopedTransformOverviewWindow::OnGestureEvent(ui::GestureEvent* event) { | 458 void ScopedTransformOverviewWindow::OnGestureEvent(ui::GestureEvent* event) { |
456 if (event->type() == ui::ET_GESTURE_TAP) { | 459 if (minimized_widget_ && SplitViewController::ShouldAllowSplitView()) { |
| 460 gfx::Point location(event->location()); |
| 461 ::wm::ConvertPointToScreen(minimized_widget_->GetNativeWindow(), &location); |
| 462 switch (event->type()) { |
| 463 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 464 case ui::ET_GESTURE_TAP_DOWN: |
| 465 selector_item_->HandlePressEvent(location); |
| 466 break; |
| 467 case ui::ET_GESTURE_SCROLL_UPDATE: |
| 468 selector_item_->HandleDragEvent(location); |
| 469 break; |
| 470 case ui::ET_GESTURE_END: |
| 471 selector_item_->HandleReleaseEvent(location); |
| 472 break; |
| 473 default: |
| 474 break; |
| 475 } |
| 476 event->SetHandled(); |
| 477 } else if (event->type() == ui::ET_GESTURE_TAP) { |
457 EnsureVisible(); | 478 EnsureVisible(); |
458 window_->Show(); | 479 window_->Show(); |
459 wm::ActivateWindow(window_); | 480 wm::ActivateWindow(window_); |
460 } | 481 } |
461 } | 482 } |
462 | 483 |
463 void ScopedTransformOverviewWindow::OnMouseEvent(ui::MouseEvent* event) { | 484 void ScopedTransformOverviewWindow::OnMouseEvent(ui::MouseEvent* event) { |
464 if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton()) { | 485 if (minimized_widget_ && SplitViewController::ShouldAllowSplitView()) { |
| 486 gfx::Point location(event->location()); |
| 487 ::wm::ConvertPointToScreen(minimized_widget_->GetNativeWindow(), &location); |
| 488 switch (event->type()) { |
| 489 case ui::ET_MOUSE_PRESSED: |
| 490 selector_item_->HandlePressEvent(location); |
| 491 break; |
| 492 case ui::ET_MOUSE_DRAGGED: |
| 493 selector_item_->HandleDragEvent(location); |
| 494 break; |
| 495 case ui::ET_MOUSE_RELEASED: |
| 496 selector_item_->HandleReleaseEvent(location); |
| 497 break; |
| 498 default: |
| 499 break; |
| 500 } |
| 501 event->SetHandled(); |
| 502 } else if (event->type() == ui::ET_MOUSE_PRESSED && |
| 503 event->IsOnlyLeftMouseButton()) { |
465 EnsureVisible(); | 504 EnsureVisible(); |
466 window_->Show(); | 505 window_->Show(); |
467 wm::ActivateWindow(window_); | 506 wm::ActivateWindow(window_); |
468 } | 507 } |
469 } | 508 } |
470 | 509 |
471 aura::Window* | 510 aura::Window* |
472 ScopedTransformOverviewWindow::GetOverviewWindowForMinimizedState() const { | 511 ScopedTransformOverviewWindow::GetOverviewWindowForMinimizedState() const { |
473 return minimized_widget_ ? minimized_widget_->GetNativeWindow() : nullptr; | 512 return minimized_widget_ ? minimized_widget_->GetNativeWindow() : nullptr; |
474 } | 513 } |
(...skipping 21 matching lines...) Expand all Loading... |
496 // In unit tests, the content view can have empty size. | 535 // In unit tests, the content view can have empty size. |
497 if (!preferred.IsEmpty()) { | 536 if (!preferred.IsEmpty()) { |
498 int inset = bounds.height() - preferred.height(); | 537 int inset = bounds.height() - preferred.height(); |
499 bounds.Inset(0, 0, 0, inset); | 538 bounds.Inset(0, 0, 0, inset); |
500 } | 539 } |
501 minimized_widget_->SetBounds(bounds); | 540 minimized_widget_->SetBounds(bounds); |
502 minimized_widget_->Show(); | 541 minimized_widget_->Show(); |
503 } | 542 } |
504 | 543 |
505 } // namespace ash | 544 } // namespace ash |
OLD | NEW |