| 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/client/screen_position_client.h" |
| 11 #include "ui/aura/window_tree_host_ozone.h" | 12 #include "ui/aura/window_tree_host_ozone.h" |
| 12 #include "ui/gfx/geometry/insets.h" | 13 #include "ui/gfx/geometry/insets.h" |
| 13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class AshWindowTreeHostOzone : public AshWindowTreeHost, | 19 class AshWindowTreeHostOzone : public AshWindowTreeHost, |
| 19 public aura::WindowTreeHostOzone { | 20 public aura::WindowTreeHostOzone { |
| 20 public: | 21 public: |
| 21 explicit AshWindowTreeHostOzone(const gfx::Rect& initial_bounds); | 22 explicit AshWindowTreeHostOzone(const gfx::Rect& initial_bounds); |
| 22 virtual ~AshWindowTreeHostOzone(); | 23 virtual ~AshWindowTreeHostOzone(); |
| 23 | 24 |
| 25 protected: |
| 26 void TranslateLocatedEvent(ui::LocatedEvent* event) OVERRIDE; |
| 27 |
| 24 private: | 28 private: |
| 25 // AshWindowTreeHost: | 29 // AshWindowTreeHost: |
| 26 virtual void ToggleFullScreen() OVERRIDE; | 30 virtual void ToggleFullScreen() OVERRIDE; |
| 27 virtual bool ConfineCursorToRootWindow() OVERRIDE; | 31 virtual bool ConfineCursorToRootWindow() OVERRIDE; |
| 28 virtual void UnConfineCursor() OVERRIDE; | 32 virtual void UnConfineCursor() OVERRIDE; |
| 29 virtual void SetRootWindowTransformer( | 33 virtual void SetRootWindowTransformer( |
| 30 scoped_ptr<RootWindowTransformer> transformer) OVERRIDE; | 34 scoped_ptr<RootWindowTransformer> transformer) OVERRIDE; |
| 31 virtual gfx::Insets GetHostInsets() const OVERRIDE; | 35 virtual gfx::Insets GetHostInsets() const OVERRIDE; |
| 32 virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; | 36 virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE; |
| 33 virtual void SetRootTransform(const gfx::Transform& transform) OVERRIDE; | 37 virtual void SetRootTransform(const gfx::Transform& transform) OVERRIDE; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 84 } |
| 81 | 85 |
| 82 gfx::Transform AshWindowTreeHostOzone::GetInverseRootTransform() const { | 86 gfx::Transform AshWindowTreeHostOzone::GetInverseRootTransform() const { |
| 83 return transformer_helper_.GetInverseTransform(); | 87 return transformer_helper_.GetInverseTransform(); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void AshWindowTreeHostOzone::UpdateRootWindowSize(const gfx::Size& host_size) { | 90 void AshWindowTreeHostOzone::UpdateRootWindowSize(const gfx::Size& host_size) { |
| 87 transformer_helper_.UpdateWindowSize(host_size); | 91 transformer_helper_.UpdateWindowSize(host_size); |
| 88 } | 92 } |
| 89 | 93 |
| 94 void AshWindowTreeHostOzone::TranslateLocatedEvent(ui::LocatedEvent* event) { |
| 95 if (!event->IsTouchEvent()) { |
| 96 aura::Window* root_window = window(); |
| 97 aura::client::ScreenPositionClient* screen_position_client = |
| 98 aura::client::GetScreenPositionClient(root_window); |
| 99 gfx::Rect local(bounds().size()); |
| 100 |
| 101 local.Inset(transformer_helper_.GetHostInsets()); |
| 102 |
| 103 if (screen_position_client && !local.Contains(event->location())) { |
| 104 gfx::Point location(event->location()); |
| 105 // In order to get the correct point in screen coordinates |
| 106 // during passive grab, we first need to find on which host window |
| 107 // the mouse is on, and find out the screen coordinates on that |
| 108 // host window, then convert it back to this host window's coordinate. |
| 109 screen_position_client->ConvertHostPointToScreen(root_window, &location); |
| 110 screen_position_client->ConvertPointFromScreen(root_window, &location); |
| 111 ConvertPointToHost(&location); |
| 112 event->set_location(location); |
| 113 event->set_root_location(location); |
| 114 } |
| 115 } |
| 116 } |
| 117 |
| 90 } // namespace | 118 } // namespace |
| 91 | 119 |
| 92 AshWindowTreeHost* AshWindowTreeHost::Create( | 120 AshWindowTreeHost* AshWindowTreeHost::Create( |
| 93 const AshWindowTreeHostInitParams& init_params) { | 121 const AshWindowTreeHostInitParams& init_params) { |
| 94 return new AshWindowTreeHostOzone(init_params.initial_bounds); | 122 return new AshWindowTreeHostOzone(init_params.initial_bounds); |
| 95 } | 123 } |
| 96 | 124 |
| 97 } // namespace ash | 125 } // namespace ash |
| OLD | NEW |