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

Side by Side Diff: ui/views/mus/window_tree_host_mus.cc

Issue 1410193009: WindowTreeHostMojo -> WindowTreeHostMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « ui/views/mus/window_tree_host_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/mus/window_tree_host_mus.h" 5 #include "ui/views/mus/window_tree_host_mus.h"
6 6
7 #include "components/mus/public/cpp/property_type_converters.h" 7 #include "components/mus/public/cpp/property_type_converters.h"
8 #include "components/mus/public/cpp/window_property.h" 8 #include "components/mus/public/cpp/window_property.h"
9 #include "components/mus/public/cpp/window_tree_connection.h" 9 #include "components/mus/public/cpp/window_tree_connection.h"
10 #include "mojo/application/public/interfaces/shell.mojom.h" 10 #include "mojo/application/public/interfaces/shell.mojom.h"
11 #include "mojo/converters/geometry/geometry_type_converters.h" 11 #include "mojo/converters/geometry/geometry_type_converters.h"
12 #include "mojo/converters/input_events/input_events_type_converters.h" 12 #include "mojo/converters/input_events/input_events_type_converters.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/events/event.h" 16 #include "ui/events/event.h"
17 #include "ui/events/event_constants.h" 17 #include "ui/events/event_constants.h"
18 #include "ui/views/mus/input_method_mus.h" 18 #include "ui/views/mus/input_method_mus.h"
19 #include "ui/views/mus/surface_context_factory.h" 19 #include "ui/views/mus/surface_context_factory.h"
20 #include "ui/views/mus/window_manager_connection.h" 20 #include "ui/views/mus/window_manager_connection.h"
21 21
22 namespace views { 22 namespace views {
23 namespace { 23 namespace {
24 24
25 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {} 25 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {}
26 26
27 } // namespace 27 } // namespace
28 28
29 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
30 // WindowTreeHostMojo, public: 30 // WindowTreeHostMus, public:
31 31
32 WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mus::Window* window) 32 WindowTreeHostMus::WindowTreeHostMus(mojo::Shell* shell, mus::Window* window)
33 : mus_window_(window) { 33 : mus_window_(window) {
34 mus_window_->AddObserver(this); 34 mus_window_->AddObserver(this);
35 35
36 context_factory_.reset(new SurfaceContextFactory(shell, mus_window_)); 36 context_factory_.reset(new SurfaceContextFactory(shell, mus_window_));
37 // WindowTreeHost creates the compositor using the ContextFactory from 37 // WindowTreeHost creates the compositor using the ContextFactory from
38 // aura::Env. Install |context_factory_| there so that |context_factory_| is 38 // aura::Env. Install |context_factory_| there so that |context_factory_| is
39 // picked up. 39 // picked up.
40 ui::ContextFactory* default_context_factory = 40 ui::ContextFactory* default_context_factory =
41 aura::Env::GetInstance()->context_factory(); 41 aura::Env::GetInstance()->context_factory();
42 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); 42 aura::Env::GetInstance()->set_context_factory(context_factory_.get());
43 CreateCompositor(); 43 CreateCompositor();
44 OnAcceleratedWidgetAvailable(); 44 OnAcceleratedWidgetAvailable();
45 aura::Env::GetInstance()->set_context_factory(default_context_factory); 45 aura::Env::GetInstance()->set_context_factory(default_context_factory);
46 DCHECK_EQ(context_factory_.get(), compositor()->context_factory()); 46 DCHECK_EQ(context_factory_.get(), compositor()->context_factory());
47 47
48 input_method_.reset(new InputMethodMUS(this, mus_window_)); 48 input_method_.reset(new InputMethodMUS(this, mus_window_));
49 SetSharedInputMethod(input_method_.get()); 49 SetSharedInputMethod(input_method_.get());
50 } 50 }
51 51
52 WindowTreeHostMojo::~WindowTreeHostMojo() { 52 WindowTreeHostMus::~WindowTreeHostMus() {
53 mus_window_->RemoveObserver(this); 53 mus_window_->RemoveObserver(this);
54 DestroyCompositor(); 54 DestroyCompositor();
55 DestroyDispatcher(); 55 DestroyDispatcher();
56 } 56 }
57 57
58 void WindowTreeHostMojo::SetShowState(mus::mojom::ShowState show_state) { 58 void WindowTreeHostMus::SetShowState(mus::mojom::ShowState show_state) {
59 show_state_ = show_state; 59 show_state_ = show_state;
60 WindowManagerConnection::Get()->window_manager()->SetShowState( 60 WindowManagerConnection::Get()->window_manager()->SetShowState(
61 mus_window_->id(), show_state_, base::Bind(&WindowManagerCallback)); 61 mus_window_->id(), show_state_, base::Bind(&WindowManagerCallback));
62 } 62 }
63 63
64 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
65 // WindowTreeHostMojo, aura::WindowTreeHost implementation: 65 // WindowTreeHostMus, aura::WindowTreeHost implementation:
66 66
67 ui::EventSource* WindowTreeHostMojo::GetEventSource() { 67 ui::EventSource* WindowTreeHostMus::GetEventSource() {
68 return this; 68 return this;
69 } 69 }
70 70
71 gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() { 71 gfx::AcceleratedWidget WindowTreeHostMus::GetAcceleratedWidget() {
72 return gfx::kNullAcceleratedWidget; 72 return gfx::kNullAcceleratedWidget;
73 } 73 }
74 74
75 void WindowTreeHostMojo::ShowImpl() { 75 void WindowTreeHostMus::ShowImpl() {
76 mus_window_->SetVisible(true); 76 mus_window_->SetVisible(true);
77 window()->Show(); 77 window()->Show();
78 } 78 }
79 79
80 void WindowTreeHostMojo::HideImpl() { 80 void WindowTreeHostMus::HideImpl() {
81 mus_window_->SetVisible(false); 81 mus_window_->SetVisible(false);
82 window()->Hide(); 82 window()->Hide();
83 } 83 }
84 84
85 gfx::Rect WindowTreeHostMojo::GetBounds() const { 85 gfx::Rect WindowTreeHostMus::GetBounds() const {
86 return mus_window_->bounds(); 86 return mus_window_->bounds();
87 } 87 }
88 88
89 void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) { 89 void WindowTreeHostMus::SetBounds(const gfx::Rect& bounds) {
90 window()->SetBounds(gfx::Rect(bounds.size())); 90 window()->SetBounds(gfx::Rect(bounds.size()));
91 } 91 }
92 92
93 gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const { 93 gfx::Point WindowTreeHostMus::GetLocationOnNativeScreen() const {
94 return gfx::Point(0, 0); 94 return gfx::Point(0, 0);
95 } 95 }
96 96
97 void WindowTreeHostMojo::SetCapture() { 97 void WindowTreeHostMus::SetCapture() {
98 NOTIMPLEMENTED(); 98 NOTIMPLEMENTED();
99 } 99 }
100 100
101 void WindowTreeHostMojo::ReleaseCapture() { 101 void WindowTreeHostMus::ReleaseCapture() {
102 NOTIMPLEMENTED(); 102 NOTIMPLEMENTED();
103 } 103 }
104 104
105 void WindowTreeHostMojo::SetCursorNative(gfx::NativeCursor cursor) { 105 void WindowTreeHostMus::SetCursorNative(gfx::NativeCursor cursor) {
106 NOTIMPLEMENTED(); 106 NOTIMPLEMENTED();
107 } 107 }
108 108
109 void WindowTreeHostMojo::MoveCursorToNative(const gfx::Point& location) { 109 void WindowTreeHostMus::MoveCursorToNative(const gfx::Point& location) {
110 NOTIMPLEMENTED(); 110 NOTIMPLEMENTED();
111 } 111 }
112 112
113 void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) { 113 void WindowTreeHostMus::OnCursorVisibilityChangedNative(bool show) {
114 NOTIMPLEMENTED(); 114 NOTIMPLEMENTED();
115 } 115 }
116 116
117 //////////////////////////////////////////////////////////////////////////////// 117 ////////////////////////////////////////////////////////////////////////////////
118 // WindowTreeHostMojo, WindowObserver implementation: 118 // WindowTreeHostMus, WindowObserver implementation:
119 119
120 void WindowTreeHostMojo::OnWindowBoundsChanged(mus::Window* window, 120 void WindowTreeHostMus::OnWindowBoundsChanged(mus::Window* window,
121 const gfx::Rect& old_bounds, 121 const gfx::Rect& old_bounds,
122 const gfx::Rect& new_bounds) { 122 const gfx::Rect& new_bounds) {
123 if (old_bounds.origin() != new_bounds.origin()) 123 if (old_bounds.origin() != new_bounds.origin())
124 OnHostMoved(new_bounds.origin()); 124 OnHostMoved(new_bounds.origin());
125 if (old_bounds.size() != new_bounds.size()) 125 if (old_bounds.size() != new_bounds.size())
126 OnHostResized(new_bounds.size()); 126 OnHostResized(new_bounds.size());
127 } 127 }
128 128
129 void WindowTreeHostMojo::OnWindowFocusChanged(mus::Window* gained_focus, 129 void WindowTreeHostMus::OnWindowFocusChanged(mus::Window* gained_focus,
130 mus::Window* lost_focus) { 130 mus::Window* lost_focus) {
131 if (gained_focus == mus_window_) 131 if (gained_focus == mus_window_)
132 GetInputMethod()->OnFocus(); 132 GetInputMethod()->OnFocus();
133 else if (lost_focus == mus_window_) 133 else if (lost_focus == mus_window_)
134 GetInputMethod()->OnBlur(); 134 GetInputMethod()->OnBlur();
135 } 135 }
136 136
137 void WindowTreeHostMojo::OnWindowInputEvent(mus::Window* view, 137 void WindowTreeHostMus::OnWindowInputEvent(mus::Window* view,
138 const mus::mojom::EventPtr& event) { 138 const mus::mojom::EventPtr& event) {
139 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); 139 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
140 if (!ui_event) 140 if (!ui_event)
141 return; 141 return;
142 142
143 if (ui_event->IsKeyEvent()) { 143 if (ui_event->IsKeyEvent()) {
144 GetInputMethod()->DispatchKeyEvent( 144 GetInputMethod()->DispatchKeyEvent(
145 static_cast<ui::KeyEvent*>(ui_event.get())); 145 static_cast<ui::KeyEvent*>(ui_event.get()));
146 } else { 146 } else {
147 SendEventToProcessor(ui_event.get()); 147 SendEventToProcessor(ui_event.get());
148 } 148 }
149 } 149 }
150 150
151 void WindowTreeHostMojo::OnWindowSharedPropertyChanged( 151 void WindowTreeHostMus::OnWindowSharedPropertyChanged(
152 mus::Window* window, 152 mus::Window* window,
153 const std::string& name, 153 const std::string& name,
154 const std::vector<uint8_t>* old_data, 154 const std::vector<uint8_t>* old_data,
155 const std::vector<uint8_t>* new_data) { 155 const std::vector<uint8_t>* new_data) {
156 if (name == mus::mojom::WindowManager::kShowState_Property) { 156 if (name == mus::mojom::WindowManager::kShowState_Property) {
157 show_state_ = static_cast<mus::mojom::ShowState>( 157 show_state_ = static_cast<mus::mojom::ShowState>(
158 window->GetSharedProperty<int32_t>( 158 window->GetSharedProperty<int32_t>(
159 mus::mojom::WindowManager::kShowState_Property)); 159 mus::mojom::WindowManager::kShowState_Property));
160 } 160 }
161 } 161 }
162 162
163 } // namespace views 163 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_tree_host_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698