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

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

Issue 1967543002: Move ShowState-related code from PlatformWindowMus to NativeWidgetMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor show_state checks Created 4 years, 7 months 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/platform_window_mus.h ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | 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/platform_window_mus.h" 5 #include "ui/views/mus/platform_window_mus.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "components/bitmap_uploader/bitmap_uploader.h" 9 #include "components/bitmap_uploader/bitmap_uploader.h"
10 #include "components/mus/public/cpp/property_type_converters.h" 10 #include "components/mus/public/cpp/property_type_converters.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); 61 DISALLOW_COPY_AND_ASSIGN(EventAckHandler);
62 }; 62 };
63 63
64 } // namespace 64 } // namespace
65 65
66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, 66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
67 shell::Connector* connector, 67 shell::Connector* connector,
68 mus::Window* mus_window) 68 mus::Window* mus_window)
69 : delegate_(delegate), 69 : delegate_(delegate),
70 mus_window_(mus_window), 70 mus_window_(mus_window),
71 show_state_(mus::mojom::ShowState::DEFAULT),
72 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), 71 last_cursor_(mus::mojom::Cursor::CURSOR_NULL),
73 mus_window_destroyed_(false) { 72 mus_window_destroyed_(false) {
74 DCHECK(delegate_); 73 DCHECK(delegate_);
75 DCHECK(mus_window_); 74 DCHECK(mus_window_);
76 mus_window_->AddObserver(this); 75 mus_window_->AddObserver(this);
77 mus_window_->set_input_event_handler(this); 76 mus_window_->set_input_event_handler(this);
78 77
79 // We need accelerated widget numbers to be different for each 78 // We need accelerated widget numbers to be different for each
80 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t 79 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
81 // has this property. 80 // has this property.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 138 }
140 139
141 void PlatformWindowMus::ReleaseCapture() { 140 void PlatformWindowMus::ReleaseCapture() {
142 mus_window_->ReleaseCapture(); 141 mus_window_->ReleaseCapture();
143 } 142 }
144 143
145 void PlatformWindowMus::ToggleFullscreen() { 144 void PlatformWindowMus::ToggleFullscreen() {
146 NOTIMPLEMENTED(); 145 NOTIMPLEMENTED();
147 } 146 }
148 147
149 void PlatformWindowMus::Maximize() { 148 void PlatformWindowMus::Maximize() {}
150 SetShowState(mus::mojom::ShowState::MAXIMIZED);
151 }
152 149
153 void PlatformWindowMus::Minimize() { 150 void PlatformWindowMus::Minimize() {}
154 SetShowState(mus::mojom::ShowState::MINIMIZED);
155 }
156 151
157 void PlatformWindowMus::Restore() { 152 void PlatformWindowMus::Restore() {}
158 SetShowState(mus::mojom::ShowState::NORMAL);
159 }
160 153
161 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { 154 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) {
162 NOTIMPLEMENTED(); 155 NOTIMPLEMENTED();
163 } 156 }
164 157
165 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { 158 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) {
166 NOTIMPLEMENTED(); 159 NOTIMPLEMENTED();
167 } 160 }
168 161
169 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) { 162 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) {
170 NOTIMPLEMENTED(); 163 NOTIMPLEMENTED();
171 } 164 }
172 165
173 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() { 166 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() {
174 return nullptr; 167 return nullptr;
175 } 168 }
176 169
177 void PlatformWindowMus::SetShowState(mus::mojom::ShowState show_state) {
178 mus_window_->SetSharedProperty<int32_t>(
179 mus::mojom::WindowManager::kShowState_Property,
180 static_cast<int32_t>(show_state));
181 }
182
183 void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) { 170 void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) {
184 DCHECK_EQ(mus_window_, window); 171 DCHECK_EQ(mus_window_, window);
185 mus_window_destroyed_ = true; 172 mus_window_destroyed_ = true;
186 #ifndef NDEBUG 173 #ifndef NDEBUG
187 weak_factory_.reset(new base::WeakPtrFactory<PlatformWindowMus>(this)); 174 weak_factory_.reset(new base::WeakPtrFactory<PlatformWindowMus>(this));
188 base::WeakPtr<PlatformWindowMus> weak_ptr = weak_factory_->GetWeakPtr(); 175 base::WeakPtr<PlatformWindowMus> weak_ptr = weak_factory_->GetWeakPtr();
189 #endif 176 #endif
190 delegate_->OnClosed(); 177 delegate_->OnClosed();
191 // |this| has been destroyed at this point. 178 // |this| has been destroyed at this point.
192 #ifndef NDEBUG 179 #ifndef NDEBUG
193 DCHECK(!weak_ptr); 180 DCHECK(!weak_ptr);
194 #endif 181 #endif
195 } 182 }
196 183
197 void PlatformWindowMus::OnWindowFocusChanged(mus::Window* gained_focus, 184 void PlatformWindowMus::OnWindowFocusChanged(mus::Window* gained_focus,
198 mus::Window* lost_focus) { 185 mus::Window* lost_focus) {
199 if (gained_focus == mus_window_) 186 if (gained_focus == mus_window_)
200 delegate_->OnActivationChanged(true); 187 delegate_->OnActivationChanged(true);
201 else if (lost_focus == mus_window_) 188 else if (lost_focus == mus_window_)
202 delegate_->OnActivationChanged(false); 189 delegate_->OnActivationChanged(false);
203 } 190 }
204 191
205 void PlatformWindowMus::OnWindowPredefinedCursorChanged( 192 void PlatformWindowMus::OnWindowPredefinedCursorChanged(
206 mus::Window* window, 193 mus::Window* window,
207 mus::mojom::Cursor cursor) { 194 mus::mojom::Cursor cursor) {
208 DCHECK_EQ(window, mus_window_); 195 DCHECK_EQ(window, mus_window_);
209 last_cursor_ = cursor; 196 last_cursor_ = cursor;
210 } 197 }
211 198
212 void PlatformWindowMus::OnWindowSharedPropertyChanged(
213 mus::Window* window,
214 const std::string& name,
215 const std::vector<uint8_t>* old_data,
216 const std::vector<uint8_t>* new_data) {
217 if (name != mus::mojom::WindowManager::kShowState_Property)
218 return;
219 mus::mojom::ShowState show_state =
220 static_cast<mus::mojom::ShowState>(window->GetSharedProperty<int32_t>(
221 mus::mojom::WindowManager::kShowState_Property));
222 if (show_state == show_state_)
223 return;
224 show_state_ = show_state;
225 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN;
226 switch (show_state_) {
227 case mus::mojom::ShowState::MINIMIZED:
228 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED;
229 break;
230 case mus::mojom::ShowState::MAXIMIZED:
231 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED;
232 break;
233 case mus::mojom::ShowState::DEFAULT:
234 case mus::mojom::ShowState::INACTIVE:
235 case mus::mojom::ShowState::NORMAL:
236 case mus::mojom::ShowState::DOCKED:
237 // TODO(sky): support docked.
238 state = ui::PLATFORM_WINDOW_STATE_NORMAL;
239 break;
240 case mus::mojom::ShowState::FULLSCREEN:
241 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN;
242 break;
243 }
244 delegate_->OnWindowStateChanged(state);
245 }
246
247 void PlatformWindowMus::OnRequestClose(mus::Window* window) { 199 void PlatformWindowMus::OnRequestClose(mus::Window* window) {
248 delegate_->OnCloseRequest(); 200 delegate_->OnCloseRequest();
249 } 201 }
250 202
251 void PlatformWindowMus::OnWindowInputEvent( 203 void PlatformWindowMus::OnWindowInputEvent(
252 mus::Window* view, 204 mus::Window* view,
253 const ui::Event& event_in, 205 const ui::Event& event_in,
254 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 206 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
255 // Take ownership of the callback, indicating that we will handle it. 207 // Take ownership of the callback, indicating that we will handle it.
256 EventAckHandler ack_handler(std::move(*ack_callback)); 208 EventAckHandler ack_handler(std::move(*ack_callback));
257 209
258 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); 210 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in);
259 delegate_->DispatchEvent(event.get()); 211 delegate_->DispatchEvent(event.get());
260 // NOTE: |this| may be deleted. 212 // NOTE: |this| may be deleted.
261 213
262 ack_handler.set_handled(event->handled()); 214 ack_handler.set_handled(event->handled());
263 // |ack_handler| acks the event on destruction if necessary. 215 // |ack_handler| acks the event on destruction if necessary.
264 } 216 }
265 217
266 } // namespace views 218 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/platform_window_mus.h ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698