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 |
24 private: | 25 private: |
25 // AshWindowTreeHost: | 26 // AshWindowTreeHost: |
26 virtual void ToggleFullScreen() override; | 27 virtual void ToggleFullScreen() override; |
27 virtual bool ConfineCursorToRootWindow() override; | 28 virtual bool ConfineCursorToRootWindow() override; |
28 virtual void UnConfineCursor() override; | 29 virtual void UnConfineCursor() override; |
29 virtual void SetRootWindowTransformer( | 30 virtual void SetRootWindowTransformer( |
30 scoped_ptr<RootWindowTransformer> transformer) override; | 31 scoped_ptr<RootWindowTransformer> transformer) override; |
31 virtual gfx::Insets GetHostInsets() const override; | 32 virtual gfx::Insets GetHostInsets() const override; |
32 virtual aura::WindowTreeHost* AsWindowTreeHost() override; | 33 virtual aura::WindowTreeHost* AsWindowTreeHost() override; |
33 virtual void SetRootTransform(const gfx::Transform& transform) override; | 34 virtual void SetRootTransform(const gfx::Transform& transform) override; |
34 virtual gfx::Transform GetRootTransform() const override; | 35 virtual gfx::Transform GetRootTransform() const override; |
35 virtual gfx::Transform GetInverseRootTransform() const override; | 36 virtual gfx::Transform GetInverseRootTransform() const override; |
36 virtual void UpdateRootWindowSize(const gfx::Size& host_size) override; | 37 virtual void UpdateRootWindowSize(const gfx::Size& host_size) override; |
38 virtual void DispatchEvent(ui::Event* event) override; | |
39 | |
40 void TranslateMouseEvent(ui::LocatedEvent* event); | |
sadrul
2014/11/11 14:41:14
non-override before overrides
llandwerlin-old
2014/11/11 18:29:17
Done.
| |
37 | 41 |
38 TransformerHelper transformer_helper_; | 42 TransformerHelper transformer_helper_; |
39 | 43 |
40 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostOzone); | 44 DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostOzone); |
41 }; | 45 }; |
42 | 46 |
43 AshWindowTreeHostOzone::AshWindowTreeHostOzone(const gfx::Rect& initial_bounds) | 47 AshWindowTreeHostOzone::AshWindowTreeHostOzone(const gfx::Rect& initial_bounds) |
44 : aura::WindowTreeHostOzone(initial_bounds), | 48 : aura::WindowTreeHostOzone(initial_bounds), |
45 transformer_helper_(this) {} | 49 transformer_helper_(this) {} |
46 | 50 |
(...skipping 33 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::DispatchEvent(ui::Event* event) { | |
95 if (event->IsMouseEvent() || event->IsScrollEvent()) | |
96 TranslateMouseEvent(static_cast<ui::LocatedEvent*>(event)); | |
97 SendEventToProcessor(event); | |
98 } | |
99 | |
100 void AshWindowTreeHostOzone::TranslateMouseEvent(ui::LocatedEvent* event) { | |
101 aura::Window* root_window = window(); | |
102 aura::client::ScreenPositionClient* screen_position_client = | |
103 aura::client::GetScreenPositionClient(root_window); | |
104 gfx::Rect local(GetBounds().size()); | |
105 | |
106 local.Inset(transformer_helper_.GetHostInsets()); | |
107 | |
108 if (screen_position_client && !local.Contains(event->location())) { | |
109 gfx::Point location(event->location()); | |
110 // In order to get the correct point in screen coordinates during | |
111 // passive grab, we first need to find on which host window the | |
112 // mouse is on, and find out the screen coordinates on that host | |
113 // window, then convert it back to this host window's coordinate. | |
114 screen_position_client->ConvertHostPointToScreen(root_window, &location); | |
115 screen_position_client->ConvertPointFromScreen(root_window, &location); | |
116 ConvertPointToHost(&location); | |
117 event->set_location(location); | |
118 event->set_root_location(location); | |
119 } | |
120 } | |
121 | |
90 } // namespace | 122 } // namespace |
91 | 123 |
92 AshWindowTreeHost* AshWindowTreeHost::Create( | 124 AshWindowTreeHost* AshWindowTreeHost::Create( |
93 const AshWindowTreeHostInitParams& init_params) { | 125 const AshWindowTreeHostInitParams& init_params) { |
94 return new AshWindowTreeHostOzone(init_params.initial_bounds); | 126 return new AshWindowTreeHostOzone(init_params.initial_bounds); |
95 } | 127 } |
96 | 128 |
97 } // namespace ash | 129 } // namespace ash |
OLD | NEW |