| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/host/ash_window_tree_host.h" | 5 #include "ash/host/ash_window_tree_host.h" |
| 6 | 6 |
| 7 #include "ash/host/ash_window_tree_host_init_params.h" | 7 #include "ash/host/ash_window_tree_host_init_params.h" |
| 8 #include "ash/host/root_window_transformer.h" | 8 #include "ash/host/root_window_transformer.h" |
| 9 #include "ash/host/transformer_helper.h" | 9 #include "ash/host/transformer_helper.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "ui/aura/window_tree_host_ozone.h" | 11 #include "ui/aura/window_tree_host_ozone.h" |
| 12 #include "ui/gfx/geometry/insets.h" | 12 #include "ui/gfx/geometry/insets.h" |
| 13 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
| 14 #include "ui/ozone/public/input_controller.h" | 14 #include "ui/ozone/public/input_controller.h" |
| 15 #include "ui/ozone/public/ozone_platform.h" | 15 #include "ui/ozone/public/ozone_platform.h" |
| 16 #include "ui/platform_window/platform_window.h" |
| 16 | 17 |
| 17 namespace ash { | 18 namespace ash { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class AshWindowTreeHostOzone : public AshWindowTreeHost, | 21 class AshWindowTreeHostOzone : public AshWindowTreeHost, |
| 21 public aura::WindowTreeHostOzone { | 22 public aura::WindowTreeHostOzone { |
| 22 public: | 23 public: |
| 23 explicit AshWindowTreeHostOzone(const gfx::Rect& initial_bounds); | 24 explicit AshWindowTreeHostOzone(const gfx::Rect& initial_bounds); |
| 24 ~AshWindowTreeHostOzone() override; | 25 ~AshWindowTreeHostOzone() override; |
| 25 | 26 |
| 26 private: | 27 private: |
| 27 // AshWindowTreeHost: | 28 // AshWindowTreeHost: |
| 28 void ToggleFullScreen() override; | 29 void ToggleFullScreen() override; |
| 29 bool ConfineCursorToRootWindow() override; | 30 bool ConfineCursorToRootWindow() override; |
| 30 void UnConfineCursor() override; | 31 void UnConfineCursor() override; |
| 31 void SetRootWindowTransformer( | 32 void SetRootWindowTransformer( |
| 32 scoped_ptr<RootWindowTransformer> transformer) override; | 33 scoped_ptr<RootWindowTransformer> transformer) override; |
| 33 gfx::Insets GetHostInsets() const override; | 34 gfx::Insets GetHostInsets() const override; |
| 34 aura::WindowTreeHost* AsWindowTreeHost() override; | 35 aura::WindowTreeHost* AsWindowTreeHost() override; |
| 35 void SetRootTransform(const gfx::Transform& transform) override; | 36 void SetRootTransform(const gfx::Transform& transform) override; |
| 36 gfx::Transform GetRootTransform() const override; | 37 gfx::Transform GetRootTransform() const override; |
| 37 gfx::Transform GetInverseRootTransform() const override; | 38 gfx::Transform GetInverseRootTransform() const override; |
| 38 void UpdateRootWindowSize(const gfx::Size& host_size) override; | 39 void UpdateRootWindowSize(const gfx::Size& host_size) override; |
| 39 void OnCursorVisibilityChangedNative(bool show) override; | 40 void OnCursorVisibilityChangedNative(bool show) override; |
| 41 void SetBounds(const gfx::Rect& bounds) override; |
| 40 void DispatchEvent(ui::Event* event) override; | 42 void DispatchEvent(ui::Event* event) override; |
| 41 | 43 |
| 42 // Temporarily disable the tap-to-click feature. Used on CrOS. | 44 // Temporarily disable the tap-to-click feature. Used on CrOS. |
| 43 void SetTapToClickPaused(bool state); | 45 void SetTapToClickPaused(bool state); |
| 44 | 46 |
| 45 TransformerHelper transformer_helper_; | 47 TransformerHelper transformer_helper_; |
| 46 | 48 |
| 47 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostOzone); | 49 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostOzone); |
| 48 }; | 50 }; |
| 49 | 51 |
| 50 AshWindowTreeHostOzone::AshWindowTreeHostOzone(const gfx::Rect& initial_bounds) | 52 AshWindowTreeHostOzone::AshWindowTreeHostOzone(const gfx::Rect& initial_bounds) |
| 51 : aura::WindowTreeHostOzone(initial_bounds), transformer_helper_(this) { | 53 : aura::WindowTreeHostOzone(initial_bounds), transformer_helper_(this) { |
| 52 } | 54 } |
| 53 | 55 |
| 54 AshWindowTreeHostOzone::~AshWindowTreeHostOzone() { | 56 AshWindowTreeHostOzone::~AshWindowTreeHostOzone() { |
| 55 } | 57 } |
| 56 | 58 |
| 57 void AshWindowTreeHostOzone::ToggleFullScreen() { | 59 void AshWindowTreeHostOzone::ToggleFullScreen() { |
| 58 NOTIMPLEMENTED(); | 60 NOTIMPLEMENTED(); |
| 59 } | 61 } |
| 60 | 62 |
| 61 bool AshWindowTreeHostOzone::ConfineCursorToRootWindow() { | 63 bool AshWindowTreeHostOzone::ConfineCursorToRootWindow() { |
| 62 return false; | 64 gfx::Rect confined_bounds(GetBounds().size()); |
| 65 confined_bounds.Inset(transformer_helper_.GetHostInsets()); |
| 66 platform_window()->ConfineCursorToBounds(confined_bounds); |
| 67 return true; |
| 63 } | 68 } |
| 64 | 69 |
| 65 void AshWindowTreeHostOzone::UnConfineCursor() { | 70 void AshWindowTreeHostOzone::UnConfineCursor() { |
| 66 NOTIMPLEMENTED(); | 71 NOTIMPLEMENTED(); |
| 67 } | 72 } |
| 68 | 73 |
| 69 void AshWindowTreeHostOzone::SetRootWindowTransformer( | 74 void AshWindowTreeHostOzone::SetRootWindowTransformer( |
| 70 scoped_ptr<RootWindowTransformer> transformer) { | 75 scoped_ptr<RootWindowTransformer> transformer) { |
| 71 transformer_helper_.SetRootWindowTransformer(transformer.Pass()); | 76 transformer_helper_.SetRootWindowTransformer(transformer.Pass()); |
| 77 ConfineCursorToRootWindow(); |
| 72 } | 78 } |
| 73 | 79 |
| 74 gfx::Insets AshWindowTreeHostOzone::GetHostInsets() const { | 80 gfx::Insets AshWindowTreeHostOzone::GetHostInsets() const { |
| 75 return transformer_helper_.GetHostInsets(); | 81 return transformer_helper_.GetHostInsets(); |
| 76 } | 82 } |
| 77 | 83 |
| 78 aura::WindowTreeHost* AshWindowTreeHostOzone::AsWindowTreeHost() { | 84 aura::WindowTreeHost* AshWindowTreeHostOzone::AsWindowTreeHost() { |
| 79 return this; | 85 return this; |
| 80 } | 86 } |
| 81 | 87 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 } | 98 } |
| 93 | 99 |
| 94 void AshWindowTreeHostOzone::UpdateRootWindowSize(const gfx::Size& host_size) { | 100 void AshWindowTreeHostOzone::UpdateRootWindowSize(const gfx::Size& host_size) { |
| 95 transformer_helper_.UpdateWindowSize(host_size); | 101 transformer_helper_.UpdateWindowSize(host_size); |
| 96 } | 102 } |
| 97 | 103 |
| 98 void AshWindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) { | 104 void AshWindowTreeHostOzone::OnCursorVisibilityChangedNative(bool show) { |
| 99 SetTapToClickPaused(!show); | 105 SetTapToClickPaused(!show); |
| 100 } | 106 } |
| 101 | 107 |
| 108 void AshWindowTreeHostOzone::SetBounds(const gfx::Rect& bounds) { |
| 109 WindowTreeHostOzone::SetBounds(bounds); |
| 110 ConfineCursorToRootWindow(); |
| 111 } |
| 112 |
| 102 void AshWindowTreeHostOzone::DispatchEvent(ui::Event* event) { | 113 void AshWindowTreeHostOzone::DispatchEvent(ui::Event* event) { |
| 103 if (event->IsLocatedEvent()) | 114 if (event->IsLocatedEvent()) |
| 104 TranslateLocatedEvent(static_cast<ui::LocatedEvent*>(event)); | 115 TranslateLocatedEvent(static_cast<ui::LocatedEvent*>(event)); |
| 105 SendEventToProcessor(event); | 116 SendEventToProcessor(event); |
| 106 } | 117 } |
| 107 | 118 |
| 108 void AshWindowTreeHostOzone::SetTapToClickPaused(bool state) { | 119 void AshWindowTreeHostOzone::SetTapToClickPaused(bool state) { |
| 109 #if defined(OS_CHROMEOS) | 120 #if defined(OS_CHROMEOS) |
| 110 DCHECK(ui::OzonePlatform::GetInstance()->GetInputController()); | 121 DCHECK(ui::OzonePlatform::GetInstance()->GetInputController()); |
| 111 | 122 |
| 112 // Temporarily pause tap-to-click when the cursor is hidden. | 123 // Temporarily pause tap-to-click when the cursor is hidden. |
| 113 ui::OzonePlatform::GetInstance()->GetInputController()->SetTapToClickPaused( | 124 ui::OzonePlatform::GetInstance()->GetInputController()->SetTapToClickPaused( |
| 114 state); | 125 state); |
| 115 #endif | 126 #endif |
| 116 } | 127 } |
| 117 | 128 |
| 118 } // namespace | 129 } // namespace |
| 119 | 130 |
| 120 AshWindowTreeHost* AshWindowTreeHost::Create( | 131 AshWindowTreeHost* AshWindowTreeHost::Create( |
| 121 const AshWindowTreeHostInitParams& init_params) { | 132 const AshWindowTreeHostInitParams& init_params) { |
| 122 return new AshWindowTreeHostOzone(init_params.initial_bounds); | 133 return new AshWindowTreeHostOzone(init_params.initial_bounds); |
| 123 } | 134 } |
| 124 | 135 |
| 125 } // namespace ash | 136 } // namespace ash |
| OLD | NEW |