OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/desktop_window_tree_host_mus.h" | 5 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/client/drag_drop_client.h" | 10 #include "ui/aura/client/drag_drop_client.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 DesktopWindowTreeHostMus::CreateDragDropClient( | 286 DesktopWindowTreeHostMus::CreateDragDropClient( |
287 DesktopNativeCursorManager* cursor_manager) { | 287 DesktopNativeCursorManager* cursor_manager) { |
288 // aura-mus handles installing a DragDropClient. | 288 // aura-mus handles installing a DragDropClient. |
289 return nullptr; | 289 return nullptr; |
290 } | 290 } |
291 | 291 |
292 void DesktopWindowTreeHostMus::Close() { | 292 void DesktopWindowTreeHostMus::Close() { |
293 if (close_widget_factory_.HasWeakPtrs()) | 293 if (close_widget_factory_.HasWeakPtrs()) |
294 return; | 294 return; |
295 | 295 |
| 296 // Even though we don't close immediately, we need to hide immediately |
| 297 // (otherwise events may be processed, which is unexpected). |
| 298 Hide(); |
| 299 |
296 // Close doesn't delete this immediately, as 'this' may still be on the stack | 300 // Close doesn't delete this immediately, as 'this' may still be on the stack |
297 // resulting in possible crashes when the stack unwindes. | 301 // resulting in possible crashes when the stack unwindes. |
298 base::ThreadTaskRunnerHandle::Get()->PostTask( | 302 base::ThreadTaskRunnerHandle::Get()->PostTask( |
299 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, | 303 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, |
300 close_widget_factory_.GetWeakPtr())); | 304 close_widget_factory_.GetWeakPtr())); |
301 } | 305 } |
302 | 306 |
303 void DesktopWindowTreeHostMus::CloseNow() { | 307 void DesktopWindowTreeHostMus::CloseNow() { |
304 native_widget_delegate_->OnNativeWidgetDestroying(); | 308 native_widget_delegate_->OnNativeWidgetDestroying(); |
305 | 309 |
(...skipping 19 matching lines...) Expand all Loading... |
325 | 329 |
326 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { | 330 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { |
327 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN || | 331 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN || |
328 state == ui::SHOW_STATE_DOCKED) { | 332 state == ui::SHOW_STATE_DOCKED) { |
329 window()->SetProperty(aura::client::kShowStateKey, state); | 333 window()->SetProperty(aura::client::kShowStateKey, state); |
330 } | 334 } |
331 window()->Show(); | 335 window()->Show(); |
332 if (compositor()) | 336 if (compositor()) |
333 compositor()->SetVisible(true); | 337 compositor()->SetVisible(true); |
334 | 338 |
| 339 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 340 |
335 if (native_widget_delegate_->CanActivate()) { | 341 if (native_widget_delegate_->CanActivate()) { |
336 if (state != ui::SHOW_STATE_INACTIVE) | 342 if (state != ui::SHOW_STATE_INACTIVE) |
337 Activate(); | 343 Activate(); |
338 | 344 |
339 // SetInitialFocus() should be always be called, even for | 345 // SetInitialFocus() should be always be called, even for |
340 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will | 346 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will |
341 // do the right thing. | 347 // do the right thing. |
342 // Activate() might fail if the window is non-activatable. In this case, we | 348 // Activate() might fail if the window is non-activatable. In this case, we |
343 // should pass SHOW_STATE_INACTIVE to SetInitialFocus() to stop the initial | 349 // should pass SHOW_STATE_INACTIVE to SetInitialFocus() to stop the initial |
344 // focused view from getting focused. See crbug.com/515594 for example. | 350 // focused view from getting focused. See crbug.com/515594 for example. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 if (window == this->window()) { | 703 if (window == this->window()) { |
698 is_active_ = true; | 704 is_active_ = true; |
699 desktop_native_widget_aura_->HandleActivationChanged(true); | 705 desktop_native_widget_aura_->HandleActivationChanged(true); |
700 } else if (is_active_) { | 706 } else if (is_active_) { |
701 is_active_ = false; | 707 is_active_ = false; |
702 desktop_native_widget_aura_->HandleActivationChanged(false); | 708 desktop_native_widget_aura_->HandleActivationChanged(false); |
703 } | 709 } |
704 } | 710 } |
705 | 711 |
706 } // namespace views | 712 } // namespace views |
OLD | NEW |