| 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 "ui/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 mus::Window* window, | 446 mus::Window* window, |
| 447 mus::mojom::SurfaceType surface_type) | 447 mus::mojom::SurfaceType surface_type) |
| 448 : window_(window), | 448 : window_(window), |
| 449 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), | 449 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 450 native_widget_delegate_(delegate), | 450 native_widget_delegate_(delegate), |
| 451 surface_type_(surface_type), | 451 surface_type_(surface_type), |
| 452 show_state_before_fullscreen_(mus::mojom::ShowState::DEFAULT), | 452 show_state_before_fullscreen_(mus::mojom::ShowState::DEFAULT), |
| 453 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 453 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 454 content_(new aura::Window(this)), | 454 content_(new aura::Window(this)), |
| 455 close_widget_factory_(this) { | 455 close_widget_factory_(this) { |
| 456 window_->set_input_event_handler(this); |
| 456 mus_window_observer_.reset(new MusWindowObserver(this)); | 457 mus_window_observer_.reset(new MusWindowObserver(this)); |
| 457 | 458 |
| 458 // TODO(fsamuel): Figure out lifetime of |window_|. | 459 // TODO(fsamuel): Figure out lifetime of |window_|. |
| 459 aura::SetMusWindow(content_, window_); | 460 aura::SetMusWindow(content_, window_); |
| 460 | 461 |
| 461 window->SetLocalProperty(kNativeWidgetMusKey, this); | 462 window->SetLocalProperty(kNativeWidgetMusKey, this); |
| 462 // WindowTreeHost creates the compositor using the ContextFactory from | 463 // WindowTreeHost creates the compositor using the ContextFactory from |
| 463 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 464 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
| 464 // picked up. | 465 // picked up. |
| 465 ui::ContextFactory* default_context_factory = | 466 ui::ContextFactory* default_context_factory = |
| 466 aura::Env::GetInstance()->context_factory(); | 467 aura::Env::GetInstance()->context_factory(); |
| 467 // For Chrome, we need the GpuProcessTransportFactory so that renderer and | 468 // For Chrome, we need the GpuProcessTransportFactory so that renderer and |
| 468 // browser pixels are composited into a single backing | 469 // browser pixels are composited into a single backing |
| 469 // SoftwareOutputDeviceMus. | 470 // SoftwareOutputDeviceMus. |
| 470 if (!default_context_factory && connector) { | 471 if (!default_context_factory && connector) { |
| 471 context_factory_.reset( | 472 context_factory_.reset( |
| 472 new SurfaceContextFactory(connector, window_, surface_type_)); | 473 new SurfaceContextFactory(connector, window_, surface_type_)); |
| 473 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 474 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
| 474 } | 475 } |
| 475 window_tree_host_.reset(new WindowTreeHostMus(connector, this, window_)); | 476 window_tree_host_.reset(new WindowTreeHostMus(connector, this, window_)); |
| 476 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 477 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
| 477 } | 478 } |
| 478 | 479 |
| 479 NativeWidgetMus::~NativeWidgetMus() { | 480 NativeWidgetMus::~NativeWidgetMus() { |
| 480 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 481 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
| 482 DCHECK(!window_); |
| 481 delete native_widget_delegate_; | 483 delete native_widget_delegate_; |
| 482 else | 484 } else { |
| 485 if (window_) |
| 486 window_->set_input_event_handler(nullptr); |
| 483 CloseNow(); | 487 CloseNow(); |
| 488 } |
| 484 } | 489 } |
| 485 | 490 |
| 486 // static | 491 // static |
| 487 void NativeWidgetMus::NotifyFrameChanged( | 492 void NativeWidgetMus::NotifyFrameChanged( |
| 488 mus::WindowTreeConnection* connection) { | 493 mus::WindowTreeConnection* connection) { |
| 489 for (mus::Window* window : connection->GetRoots()) { | 494 for (mus::Window* window : connection->GetRoots()) { |
| 490 NativeWidgetMus* native_widget = | 495 NativeWidgetMus* native_widget = |
| 491 window->GetLocalProperty(kNativeWidgetMusKey); | 496 window->GetLocalProperty(kNativeWidgetMusKey); |
| 492 if (native_widget && native_widget->GetWidget()->non_client_view()) { | 497 if (native_widget && native_widget->GetWidget()->non_client_view()) { |
| 493 native_widget->GetWidget()->non_client_view()->Layout(); | 498 native_widget->GetWidget()->non_client_view()->Layout(); |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 window_tree_host_->Show(); | 1300 window_tree_host_->Show(); |
| 1296 GetNativeWindow()->Show(); | 1301 GetNativeWindow()->Show(); |
| 1297 } else { | 1302 } else { |
| 1298 window_tree_host_->Hide(); | 1303 window_tree_host_->Hide(); |
| 1299 GetNativeWindow()->Hide(); | 1304 GetNativeWindow()->Hide(); |
| 1300 } | 1305 } |
| 1301 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1306 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1302 } | 1307 } |
| 1303 | 1308 |
| 1304 } // namespace views | 1309 } // namespace views |
| OLD | NEW |