Chromium Code Reviews| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 ui::PlatformWindowDelegate* platform_window_delegate() { | 431 ui::PlatformWindowDelegate* platform_window_delegate() { |
| 432 return native_widget_mus_->window_tree_host(); | 432 return native_widget_mus_->window_tree_host(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 NativeWidgetMus* native_widget_mus_; | 435 NativeWidgetMus* native_widget_mus_; |
| 436 mus::mojom::ShowState show_state_; | 436 mus::mojom::ShowState show_state_; |
| 437 | 437 |
| 438 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); | 438 DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 class NativeWidgetMus::MusCaptureClient : public aura::client::CaptureClient { | |
|
sadrul
2016/05/24 15:25:19
This could subclass DefaultCaptureClient instead,
Mark Dittmer
2016/05/24 16:06:20
Should work.
| |
| 442 public: | |
| 443 MusCaptureClient(aura::Window* root_window, aura::Window* aura_window, | |
| 444 mus::Window* mus_window) | |
| 445 : aura_window_(aura_window), mus_window_(mus_window), | |
| 446 delegate_(new aura::client::DefaultCaptureClient(root_window)) { | |
| 447 SetCaptureClient(root_window, this); | |
| 448 } | |
| 449 ~MusCaptureClient() override {} | |
| 450 | |
| 451 void SetCapture(aura::Window* window) override { | |
|
sadrul
2016/05/24 15:25:19
// aura::client::CaptureClient:
Mark Dittmer
2016/05/24 16:06:20
Done (against aura::client::DefaultCaptureClient).
| |
| 452 delegate()->SetCapture(window); | |
| 453 if (aura_window_ == window) | |
| 454 mus_window_->SetCapture(); | |
| 455 } | |
| 456 void ReleaseCapture(aura::Window* window) override { | |
| 457 delegate()->ReleaseCapture(window); | |
| 458 if (aura_window_ == window) | |
| 459 mus_window_->ReleaseCapture(); | |
| 460 } | |
| 461 aura::Window* GetCaptureWindow() override { | |
| 462 return delegate()->GetCaptureWindow(); | |
| 463 } | |
| 464 aura::Window* GetGlobalCaptureWindow() override { | |
| 465 return delegate()->GetGlobalCaptureWindow(); | |
| 466 } | |
| 467 | |
| 468 private: | |
| 469 aura::client::CaptureClient* delegate() { return delegate_.get(); } | |
| 470 | |
| 471 aura::Window* aura_window_; | |
| 472 mus::Window* mus_window_; | |
| 473 std::unique_ptr<aura::client::DefaultCaptureClient> delegate_; | |
|
sadrul
2016/05/24 15:25:19
DISALLOW_COPY_AND_ASSIGN
Mark Dittmer
2016/05/24 16:06:20
Done.
| |
| 474 }; | |
| 475 | |
| 441 //////////////////////////////////////////////////////////////////////////////// | 476 //////////////////////////////////////////////////////////////////////////////// |
| 442 // NativeWidgetMus, public: | 477 // NativeWidgetMus, public: |
| 443 | 478 |
| 444 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 479 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 445 shell::Connector* connector, | 480 shell::Connector* connector, |
| 446 mus::Window* window, | 481 mus::Window* window, |
| 447 mus::mojom::SurfaceType surface_type) | 482 mus::mojom::SurfaceType surface_type) |
| 448 : window_(window), | 483 : window_(window), |
| 449 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), | 484 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 450 native_widget_delegate_(delegate), | 485 native_widget_delegate_(delegate), |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 aura::client::SetCursorClient(window_tree_host_->window(), | 673 aura::client::SetCursorClient(window_tree_host_->window(), |
| 639 cursor_manager_.get()); | 674 cursor_manager_.get()); |
| 640 } | 675 } |
| 641 | 676 |
| 642 window_tree_client_.reset( | 677 window_tree_client_.reset( |
| 643 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); | 678 new NativeWidgetMusWindowTreeClient(window_tree_host_->window())); |
| 644 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); | 679 window_tree_host_->window()->AddPreTargetHandler(focus_client_.get()); |
| 645 window_tree_host_->window()->SetLayoutManager( | 680 window_tree_host_->window()->SetLayoutManager( |
| 646 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); | 681 new ContentWindowLayoutManager(window_tree_host_->window(), content_)); |
| 647 capture_client_.reset( | 682 capture_client_.reset( |
| 648 new aura::client::DefaultCaptureClient(window_tree_host_->window())); | 683 new MusCaptureClient(window_tree_host_->window(), content_, window_)); |
| 649 | 684 |
| 650 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 685 content_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 651 content_->Init(ui::LAYER_TEXTURED); | 686 content_->Init(ui::LAYER_TEXTURED); |
| 652 if (window_->visible()) | 687 if (window_->visible()) |
| 653 content_->Show(); | 688 content_->Show(); |
| 654 content_->SetTransparent(true); | 689 content_->SetTransparent(true); |
| 655 content_->SetFillsBoundsCompletely(false); | 690 content_->SetFillsBoundsCompletely(false); |
| 656 window_tree_host_->window()->AddChild(content_); | 691 window_tree_host_->window()->AddChild(content_); |
| 657 | 692 |
| 658 // Set-up transiency if appropriate. | 693 // Set-up transiency if appropriate. |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 window_tree_host_->Show(); | 1343 window_tree_host_->Show(); |
| 1309 GetNativeWindow()->Show(); | 1344 GetNativeWindow()->Show(); |
| 1310 } else { | 1345 } else { |
| 1311 window_tree_host_->Hide(); | 1346 window_tree_host_->Hide(); |
| 1312 GetNativeWindow()->Hide(); | 1347 GetNativeWindow()->Hide(); |
| 1313 } | 1348 } |
| 1314 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1349 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1315 } | 1350 } |
| 1316 | 1351 |
| 1317 } // namespace views | 1352 } // namespace views |
| OLD | NEW |