| 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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 aura::Window* aura_window_; | 497 aura::Window* aura_window_; |
| 498 ui::Window* mus_window_; | 498 ui::Window* mus_window_; |
| 499 | 499 |
| 500 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient); | 500 DISALLOW_COPY_AND_ASSIGN(MusCaptureClient); |
| 501 }; | 501 }; |
| 502 | 502 |
| 503 //////////////////////////////////////////////////////////////////////////////// | 503 //////////////////////////////////////////////////////////////////////////////// |
| 504 // NativeWidgetMus, public: | 504 // NativeWidgetMus, public: |
| 505 | 505 |
| 506 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 506 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 507 shell::Connector* connector, | |
| 508 ui::Window* window, | 507 ui::Window* window, |
| 509 ui::mojom::SurfaceType surface_type) | 508 ui::mojom::SurfaceType surface_type) |
| 510 : window_(window), | 509 : window_(window), |
| 511 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), | 510 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), |
| 512 native_widget_delegate_(delegate), | 511 native_widget_delegate_(delegate), |
| 513 surface_type_(surface_type), | 512 surface_type_(surface_type), |
| 514 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), | 513 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), |
| 515 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 514 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 516 content_(new aura::Window(this)), | 515 content_(new aura::Window(this)), |
| 517 close_widget_factory_(this) { | 516 close_widget_factory_(this) { |
| 518 window_->set_input_event_handler(this); | 517 window_->set_input_event_handler(this); |
| 519 mus_window_observer_.reset(new MusWindowObserver(this)); | 518 mus_window_observer_.reset(new MusWindowObserver(this)); |
| 520 | 519 |
| 521 // TODO(fsamuel): Figure out lifetime of |window_|. | 520 // TODO(fsamuel): Figure out lifetime of |window_|. |
| 522 aura::SetMusWindow(content_, window_); | 521 aura::SetMusWindow(content_, window_); |
| 523 window->SetLocalProperty(kNativeWidgetMusKey, this); | 522 window->SetLocalProperty(kNativeWidgetMusKey, this); |
| 524 | 523 |
| 525 // WindowTreeHost creates the compositor using the ContextFactory from | 524 // WindowTreeHost creates the compositor using the ContextFactory from |
| 526 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 525 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
| 527 // picked up. | 526 // picked up. |
| 528 ui::ContextFactory* default_context_factory = | 527 ui::ContextFactory* default_context_factory = |
| 529 aura::Env::GetInstance()->context_factory(); | 528 aura::Env::GetInstance()->context_factory(); |
| 530 if (!default_context_factory) { | 529 if (!default_context_factory) { |
| 531 context_factory_.reset( | 530 context_factory_.reset(new SurfaceContextFactory(window_, surface_type_)); |
| 532 new SurfaceContextFactory(connector, window_, surface_type_)); | |
| 533 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 531 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
| 534 } | 532 } |
| 535 | 533 |
| 536 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); | 534 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); |
| 537 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 535 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
| 538 } | 536 } |
| 539 | 537 |
| 540 NativeWidgetMus::~NativeWidgetMus() { | 538 NativeWidgetMus::~NativeWidgetMus() { |
| 541 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { | 539 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
| 542 DCHECK(!window_); | 540 DCHECK(!window_); |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 | 1417 |
| 1420 gfx::Path mask_path; | 1418 gfx::Path mask_path; |
| 1421 native_widget_delegate_->GetHitTestMask(&mask_path); | 1419 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1422 // TODO(jamescook): Use the full path for the mask. | 1420 // TODO(jamescook): Use the full path for the mask. |
| 1423 gfx::Rect mask_rect = | 1421 gfx::Rect mask_rect = |
| 1424 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1422 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1425 window_->SetHitTestMask(mask_rect); | 1423 window_->SetHitTestMask(mask_rect); |
| 1426 } | 1424 } |
| 1427 | 1425 |
| 1428 } // namespace views | 1426 } // namespace views |
| OLD | NEW |