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

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

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

Powered by Google App Engine
This is Rietveld 408576698