OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/aura/window_tree_host_mojo.h" | 5 #include "mandoline/ui/aura/window_tree_host_mojo.h" |
6 | 6 |
7 #include "components/view_manager/public/cpp/view_manager.h" | 7 #include "components/view_manager/public/cpp/view_manager.h" |
8 #include "mandoline/ui/aura/input_method_mandoline.h" | |
8 #include "mandoline/ui/aura/surface_context_factory.h" | 9 #include "mandoline/ui/aura/surface_context_factory.h" |
9 #include "mojo/application/public/interfaces/shell.mojom.h" | 10 #include "mojo/application/public/interfaces/shell.mojom.h" |
10 #include "mojo/converters/geometry/geometry_type_converters.h" | 11 #include "mojo/converters/geometry/geometry_type_converters.h" |
11 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
15 #include "ui/events/event_constants.h" | 16 #include "ui/events/event_constants.h" |
16 | 17 |
17 namespace mandoline { | 18 namespace mandoline { |
18 | 19 |
19 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
20 // WindowTreeHostMojo, public: | 21 // WindowTreeHostMojo, public: |
21 | 22 |
22 WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mojo::View* view) | 23 WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mojo::View* view) |
23 : view_(view), bounds_(view->bounds().To<gfx::Rect>()) { | 24 : view_(view), bounds_(view->bounds().To<gfx::Rect>()) { |
24 view_->AddObserver(this); | 25 view_->AddObserver(this); |
25 | 26 |
26 context_factory_.reset(new SurfaceContextFactory(shell, view_)); | 27 context_factory_.reset(new SurfaceContextFactory(shell, view_)); |
27 // WindowTreeHost creates the compositor using the ContextFactory from | 28 // WindowTreeHost creates the compositor using the ContextFactory from |
28 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 29 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
29 // picked up. | 30 // picked up. |
30 ui::ContextFactory* default_context_factory = | 31 ui::ContextFactory* default_context_factory = |
31 aura::Env::GetInstance()->context_factory(); | 32 aura::Env::GetInstance()->context_factory(); |
32 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 33 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
33 CreateCompositor(GetAcceleratedWidget()); | 34 CreateCompositor(GetAcceleratedWidget()); |
34 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 35 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
35 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); | 36 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); |
37 | |
38 #if defined(OS_LINUX) && !defined(OS_ANDROID) | |
39 // We override the input method on Linux. InputMethodAuraLinux was designed | |
40 // to work on a stream of raw X11 events. However, we're now standardizing on | |
41 // the Windows event model here. Trying to use InputMethodAuraLinux on a | |
42 // Windows-like event stream leads to double character events. | |
43 input_method_.reset(new InputMethodMandoline(this)); | |
44 SetSharedInputMethod(input_method_.get()); | |
Shu Chen
2015/07/17 01:54:08
Please notice that my refactoring cl https://coder
| |
45 #endif | |
36 } | 46 } |
37 | 47 |
38 WindowTreeHostMojo::~WindowTreeHostMojo() { | 48 WindowTreeHostMojo::~WindowTreeHostMojo() { |
39 view_->RemoveObserver(this); | 49 view_->RemoveObserver(this); |
40 DestroyCompositor(); | 50 DestroyCompositor(); |
41 DestroyDispatcher(); | 51 DestroyDispatcher(); |
42 } | 52 } |
43 | 53 |
44 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
45 // WindowTreeHostMojo, aura::WindowTreeHost implementation: | 55 // WindowTreeHostMojo, aura::WindowTreeHost implementation: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>(); | 111 gfx::Rect old_bounds2 = old_bounds.To<gfx::Rect>(); |
102 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>(); | 112 gfx::Rect new_bounds2 = new_bounds.To<gfx::Rect>(); |
103 bounds_ = new_bounds2; | 113 bounds_ = new_bounds2; |
104 if (old_bounds2.origin() != new_bounds2.origin()) | 114 if (old_bounds2.origin() != new_bounds2.origin()) |
105 OnHostMoved(bounds_.origin()); | 115 OnHostMoved(bounds_.origin()); |
106 if (old_bounds2.size() != new_bounds2.size()) | 116 if (old_bounds2.size() != new_bounds2.size()) |
107 OnHostResized(bounds_.size()); | 117 OnHostResized(bounds_.size()); |
108 } | 118 } |
109 | 119 |
110 } // namespace mandoline | 120 } // namespace mandoline |
OLD | NEW |