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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); | 365 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 void OnMoveLoopEnd(bool* out_success, | 368 void OnMoveLoopEnd(bool* out_success, |
| 369 base::Closure quit_closure, | 369 base::Closure quit_closure, |
| 370 bool in_success) { | 370 bool in_success) { |
| 371 *out_success = in_success; | 371 *out_success = in_success; |
| 372 quit_closure.Run(); | 372 quit_closure.Run(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 ui::mojom::ShowState GetShowState(const ui::Window* window) { | |
| 376 if (!window || | |
| 377 !window->HasSharedProperty( | |
| 378 ui::mojom::WindowManager::kShowState_Property)) { | |
| 379 return ui::mojom::ShowState::DEFAULT; | |
| 380 } | |
| 381 | |
| 382 return static_cast<ui::mojom::ShowState>(window->GetSharedProperty<int32_t>( | |
| 383 ui::mojom::WindowManager::kShowState_Property)); | |
| 384 } | |
| 385 | |
| 375 } // namespace | 386 } // namespace |
| 376 | 387 |
| 377 class NativeWidgetMus::MusWindowObserver : public ui::WindowObserver { | 388 class NativeWidgetMus::MusWindowObserver : public ui::WindowObserver { |
| 378 public: | 389 public: |
| 379 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) | 390 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) |
| 380 : native_widget_mus_(native_widget_mus), | 391 : native_widget_mus_(native_widget_mus), |
| 381 show_state_(ui::mojom::ShowState::DEFAULT) { | 392 show_state_(ui::mojom::ShowState::DEFAULT) { |
| 382 mus_window()->AddObserver(this); | 393 mus_window()->AddObserver(this); |
| 383 } | 394 } |
| 384 | 395 |
| 385 ~MusWindowObserver() override { | 396 ~MusWindowObserver() override { |
| 386 mus_window()->RemoveObserver(this); | 397 mus_window()->RemoveObserver(this); |
| 387 } | 398 } |
| 388 | 399 |
| 389 ui::mojom::ShowState show_state() { return show_state_; } | |
| 390 | |
| 391 // ui::WindowObserver: | 400 // ui::WindowObserver: |
| 392 void OnWindowVisibilityChanging(ui::Window* window) override { | 401 void OnWindowVisibilityChanging(ui::Window* window) override { |
| 393 native_widget_mus_->OnMusWindowVisibilityChanging(window); | 402 native_widget_mus_->OnMusWindowVisibilityChanging(window); |
| 394 } | 403 } |
| 395 void OnWindowVisibilityChanged(ui::Window* window) override { | 404 void OnWindowVisibilityChanged(ui::Window* window) override { |
| 396 native_widget_mus_->OnMusWindowVisibilityChanged(window); | 405 native_widget_mus_->OnMusWindowVisibilityChanged(window); |
| 397 } | 406 } |
| 398 void OnWindowPredefinedCursorChanged(ui::Window* window, | 407 void OnWindowPredefinedCursorChanged(ui::Window* window, |
| 399 ui::mojom::Cursor cursor) override { | 408 ui::mojom::Cursor cursor) override { |
| 400 DCHECK_EQ(window, mus_window()); | 409 DCHECK_EQ(window, mus_window()); |
| 401 native_widget_mus_->set_last_cursor(cursor); | 410 native_widget_mus_->set_last_cursor(cursor); |
| 402 } | 411 } |
| 403 void OnWindowSharedPropertyChanged( | 412 void OnWindowSharedPropertyChanged( |
| 404 ui::Window* window, | 413 ui::Window* window, |
| 405 const std::string& name, | 414 const std::string& name, |
| 406 const std::vector<uint8_t>* old_data, | 415 const std::vector<uint8_t>* old_data, |
| 407 const std::vector<uint8_t>* new_data) override { | 416 const std::vector<uint8_t>* new_data) override { |
| 408 if (name != ui::mojom::WindowManager::kShowState_Property) | 417 if (name != ui::mojom::WindowManager::kShowState_Property) |
| 409 return; | 418 return; |
| 410 ui::mojom::ShowState show_state = | 419 const ui::mojom::ShowState show_state = GetShowState(window); |
| 411 static_cast<ui::mojom::ShowState>(window->GetSharedProperty<int32_t>( | |
| 412 ui::mojom::WindowManager::kShowState_Property)); | |
| 413 if (show_state == show_state_) | 420 if (show_state == show_state_) |
| 414 return; | 421 return; |
| 415 show_state_ = show_state; | 422 show_state_ = show_state; |
| 416 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; | 423 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; |
| 417 switch (show_state_) { | 424 switch (show_state_) { |
| 418 case ui::mojom::ShowState::MINIMIZED: | 425 case ui::mojom::ShowState::MINIMIZED: |
| 419 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; | 426 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; |
| 420 break; | 427 break; |
| 421 case ui::mojom::ShowState::MAXIMIZED: | 428 case ui::mojom::ShowState::MAXIMIZED: |
| 422 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; | 429 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 | 509 |
| 503 //////////////////////////////////////////////////////////////////////////////// | 510 //////////////////////////////////////////////////////////////////////////////// |
| 504 // NativeWidgetMus, public: | 511 // NativeWidgetMus, public: |
| 505 | 512 |
| 506 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 513 NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 507 ui::Window* window, | 514 ui::Window* window, |
| 508 ui::mojom::SurfaceType surface_type) | 515 ui::mojom::SurfaceType surface_type) |
| 509 : window_(window), | 516 : window_(window), |
| 510 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), | 517 last_cursor_(ui::mojom::Cursor::CURSOR_NULL), |
| 511 native_widget_delegate_(delegate), | 518 native_widget_delegate_(delegate), |
| 512 surface_type_(surface_type), | 519 is_parallel_widget_in_window_manager_(surface_type == |
| 520 ui::mojom::SurfaceType::UNDERLAY), | |
| 513 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), | 521 show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), |
| 514 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 522 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 515 content_(new aura::Window(this)), | 523 content_(new aura::Window(this)), |
| 516 close_widget_factory_(this) { | 524 close_widget_factory_(this) { |
| 517 window_->set_input_event_handler(this); | 525 window_->set_input_event_handler(this); |
| 518 mus_window_observer_.reset(new MusWindowObserver(this)); | 526 mus_window_observer_.reset(new MusWindowObserver(this)); |
| 519 | 527 |
| 520 // TODO(fsamuel): Figure out lifetime of |window_|. | 528 // TODO(fsamuel): Figure out lifetime of |window_|. |
| 521 aura::SetMusWindow(content_, window_); | 529 aura::SetMusWindow(content_, window_); |
| 522 window->SetLocalProperty(kNativeWidgetMusKey, this); | 530 window->SetLocalProperty(kNativeWidgetMusKey, this); |
| 523 | 531 |
| 524 // WindowTreeHost creates the compositor using the ContextFactory from | 532 // WindowTreeHost creates the compositor using the ContextFactory from |
| 525 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 533 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
| 526 // picked up. | 534 // picked up. |
| 527 ui::ContextFactory* default_context_factory = | 535 ui::ContextFactory* default_context_factory = |
| 528 aura::Env::GetInstance()->context_factory(); | 536 aura::Env::GetInstance()->context_factory(); |
| 529 if (!default_context_factory) { | 537 if (!default_context_factory) { |
| 530 context_factory_.reset(new SurfaceContextFactory(window_, surface_type_)); | 538 context_factory_.reset(new SurfaceContextFactory(window_, surface_type)); |
| 531 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | 539 aura::Env::GetInstance()->set_context_factory(context_factory_.get()); |
| 532 } | 540 } |
| 533 | 541 |
| 534 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); | 542 window_tree_host_.reset(new WindowTreeHostMus(this, window_)); |
| 535 aura::Env::GetInstance()->set_context_factory(default_context_factory); | 543 aura::Env::GetInstance()->set_context_factory(default_context_factory); |
| 536 } | 544 } |
| 537 | 545 |
| 538 NativeWidgetMus::~NativeWidgetMus() { | 546 NativeWidgetMus::~NativeWidgetMus() { |
| 539 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { | 547 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
| 540 DCHECK(!window_); | 548 DCHECK(!window_); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 native_widget_delegate_->OnNativeFocus(); | 611 native_widget_delegate_->OnNativeFocus(); |
| 604 GetWidget()->GetFocusManager()->RestoreFocusedView(); | 612 GetWidget()->GetFocusManager()->RestoreFocusedView(); |
| 605 } else { | 613 } else { |
| 606 native_widget_delegate_->OnNativeBlur(); | 614 native_widget_delegate_->OnNativeBlur(); |
| 607 GetWidget()->GetFocusManager()->StoreFocusedView(true); | 615 GetWidget()->GetFocusManager()->StoreFocusedView(true); |
| 608 } | 616 } |
| 609 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | 617 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
| 610 } | 618 } |
| 611 | 619 |
| 612 void NativeWidgetMus::UpdateClientArea() { | 620 void NativeWidgetMus::UpdateClientArea() { |
| 621 if (is_parallel_widget_in_window_manager()) | |
| 622 return; | |
| 623 | |
| 613 NonClientView* non_client_view = | 624 NonClientView* non_client_view = |
| 614 native_widget_delegate_->AsWidget()->non_client_view(); | 625 native_widget_delegate_->AsWidget()->non_client_view(); |
| 615 if (!non_client_view || !non_client_view->client_view()) | 626 if (!non_client_view || !non_client_view->client_view()) |
| 616 return; | 627 return; |
| 617 | 628 |
| 618 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); | 629 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); |
| 619 window_->SetClientArea(gfx::Insets( | 630 window_->SetClientArea(gfx::Insets( |
| 620 client_area_rect.y(), client_area_rect.x(), | 631 client_area_rect.y(), client_area_rect.x(), |
| 621 non_client_view->bounds().height() - client_area_rect.bottom(), | 632 non_client_view->bounds().height() - client_area_rect.bottom(), |
| 622 non_client_view->bounds().width() - client_area_rect.right())); | 633 non_client_view->bounds().width() - client_area_rect.right())); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 641 } | 652 } |
| 642 (*properties)[ui::mojom::WindowManager::kAlwaysOnTop_Property] = | 653 (*properties)[ui::mojom::WindowManager::kAlwaysOnTop_Property] = |
| 643 mojo::ConvertTo<std::vector<uint8_t>>(init_params.keep_on_top); | 654 mojo::ConvertTo<std::vector<uint8_t>>(init_params.keep_on_top); |
| 644 | 655 |
| 645 if (!Widget::RequiresNonClientView(init_params.type)) | 656 if (!Widget::RequiresNonClientView(init_params.type)) |
| 646 return; | 657 return; |
| 647 | 658 |
| 648 (*properties)[ui::mojom::WindowManager::kWindowType_Property] = | 659 (*properties)[ui::mojom::WindowManager::kWindowType_Property] = |
| 649 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( | 660 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>( |
| 650 mojo::ConvertTo<ui::mojom::WindowType>(init_params.type))); | 661 mojo::ConvertTo<ui::mojom::WindowType>(init_params.type))); |
| 651 if (!init_params.delegate && | 662 if (init_params.delegate && |
| 652 properties->count(ui::mojom::WindowManager::kResizeBehavior_Property) == | 663 properties->count(ui::mojom::WindowManager::kResizeBehavior_Property) == |
| 653 0) { | 664 0) { |
| 654 (*properties)[ui::mojom::WindowManager::kResizeBehavior_Property] = | 665 (*properties)[ui::mojom::WindowManager::kResizeBehavior_Property] = |
| 655 mojo::ConvertTo<std::vector<uint8_t>>( | 666 mojo::ConvertTo<std::vector<uint8_t>>( |
| 656 ResizeBehaviorFromDelegate(init_params.delegate)); | 667 ResizeBehaviorFromDelegate(init_params.delegate)); |
| 657 } | 668 } |
| 658 SkBitmap app_icon = AppIconFromDelegate(init_params.delegate); | 669 SkBitmap app_icon = AppIconFromDelegate(init_params.delegate); |
| 659 if (!app_icon.isNull()) { | 670 if (!app_icon.isNull()) { |
| 660 (*properties)[ui::mojom::WindowManager::kWindowAppIcon_Property] = | 671 (*properties)[ui::mojom::WindowManager::kWindowAppIcon_Property] = |
| 661 mojo::ConvertTo<std::vector<uint8_t>>(app_icon); | 672 mojo::ConvertTo<std::vector<uint8_t>>(app_icon); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 687 | 698 |
| 688 aura::client::SetFocusClient(hosted_window, focus_client_.get()); | 699 aura::client::SetFocusClient(hosted_window, focus_client_.get()); |
| 689 aura::client::SetActivationClient(hosted_window, focus_client_.get()); | 700 aura::client::SetActivationClient(hosted_window, focus_client_.get()); |
| 690 screen_position_client_.reset(new ScreenPositionClientMus(window_)); | 701 screen_position_client_.reset(new ScreenPositionClientMus(window_)); |
| 691 aura::client::SetScreenPositionClient(hosted_window, | 702 aura::client::SetScreenPositionClient(hosted_window, |
| 692 screen_position_client_.get()); | 703 screen_position_client_.get()); |
| 693 | 704 |
| 694 // TODO(erg): Remove this check when ash/mus/frame/move_event_handler.cc's | 705 // TODO(erg): Remove this check when ash/mus/frame/move_event_handler.cc's |
| 695 // direct usage of ui::Window::SetPredefinedCursor() is switched to a | 706 // direct usage of ui::Window::SetPredefinedCursor() is switched to a |
| 696 // private method on WindowManagerClient. | 707 // private method on WindowManagerClient. |
| 697 if (surface_type_ == ui::mojom::SurfaceType::DEFAULT) { | 708 if (!is_parallel_widget_in_window_manager()) { |
| 698 cursor_manager_.reset(new wm::CursorManager( | 709 cursor_manager_.reset(new wm::CursorManager( |
| 699 base::WrapUnique(new NativeCursorManagerMus(window_)))); | 710 base::WrapUnique(new NativeCursorManagerMus(window_)))); |
| 700 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); | 711 aura::client::SetCursorClient(hosted_window, cursor_manager_.get()); |
| 701 } | 712 } |
| 702 | 713 |
| 703 window_tree_client_.reset(new NativeWidgetMusWindowTreeClient(hosted_window)); | 714 window_tree_client_.reset(new NativeWidgetMusWindowTreeClient(hosted_window)); |
| 704 hosted_window->AddPreTargetHandler(focus_client_.get()); | 715 hosted_window->AddPreTargetHandler(focus_client_.get()); |
| 705 hosted_window->SetLayoutManager( | 716 hosted_window->SetLayoutManager( |
| 706 new ContentWindowLayoutManager(hosted_window, content_)); | 717 new ContentWindowLayoutManager(hosted_window, content_)); |
| 707 capture_client_.reset(new MusCaptureClient(hosted_window, content_, window_)); | 718 capture_client_.reset(new MusCaptureClient(hosted_window, content_, window_)); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 827 | 838 |
| 828 bool NativeWidgetMus::HasCapture() const { | 839 bool NativeWidgetMus::HasCapture() const { |
| 829 return content_ && content_->HasCapture(); | 840 return content_ && content_->HasCapture(); |
| 830 } | 841 } |
| 831 | 842 |
| 832 ui::InputMethod* NativeWidgetMus::GetInputMethod() { | 843 ui::InputMethod* NativeWidgetMus::GetInputMethod() { |
| 833 return window_tree_host_ ? window_tree_host_->GetInputMethod() : nullptr; | 844 return window_tree_host_ ? window_tree_host_->GetInputMethod() : nullptr; |
| 834 } | 845 } |
| 835 | 846 |
| 836 void NativeWidgetMus::CenterWindow(const gfx::Size& size) { | 847 void NativeWidgetMus::CenterWindow(const gfx::Size& size) { |
| 848 if (is_parallel_widget_in_window_manager()) | |
| 849 return; | |
| 837 // TODO(beng): clear user-placed property and set preferred size property. | 850 // TODO(beng): clear user-placed property and set preferred size property. |
| 838 window_->SetSharedProperty<gfx::Size>( | 851 window_->SetSharedProperty<gfx::Size>( |
| 839 ui::mojom::WindowManager::kPreferredSize_Property, size); | 852 ui::mojom::WindowManager::kPreferredSize_Property, size); |
| 840 | 853 |
| 841 gfx::Rect bounds = display::Screen::GetScreen() | 854 gfx::Rect bounds = display::Screen::GetScreen() |
| 842 ->GetDisplayNearestWindow(content_) | 855 ->GetDisplayNearestWindow(content_) |
| 843 .work_area(); | 856 .work_area(); |
| 844 bounds.ClampToCenteredSize(size); | 857 bounds.ClampToCenteredSize(size); |
| 845 window_->SetBounds(bounds); | 858 window_->SetBounds(bounds); |
| 846 } | 859 } |
| 847 | 860 |
| 848 void NativeWidgetMus::GetWindowPlacement( | 861 void NativeWidgetMus::GetWindowPlacement( |
| 849 gfx::Rect* bounds, | 862 gfx::Rect* bounds, |
| 850 ui::WindowShowState* maximized) const { | 863 ui::WindowShowState* maximized) const { |
| 851 // NOTIMPLEMENTED(); | 864 // NOTIMPLEMENTED(); |
| 852 } | 865 } |
| 853 | 866 |
| 854 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) { | 867 bool NativeWidgetMus::SetWindowTitle(const base::string16& title) { |
| 855 if (!window_) | 868 if (!window_ || is_parallel_widget_in_window_manager()) |
| 856 return false; | 869 return false; |
| 857 const char* kWindowTitle_Property = | 870 const char* kWindowTitle_Property = |
| 858 ui::mojom::WindowManager::kWindowTitle_Property; | 871 ui::mojom::WindowManager::kWindowTitle_Property; |
| 859 const base::string16 current_title = | 872 const base::string16 current_title = |
| 860 window_->HasSharedProperty(kWindowTitle_Property) | 873 window_->HasSharedProperty(kWindowTitle_Property) |
| 861 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property) | 874 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property) |
| 862 : base::string16(); | 875 : base::string16(); |
| 863 if (current_title == title) | 876 if (current_title == title) |
| 864 return false; | 877 return false; |
| 865 window_->SetSharedProperty<base::string16>(kWindowTitle_Property, title); | 878 window_->SetSharedProperty<base::string16>(kWindowTitle_Property, title); |
| 866 return true; | 879 return true; |
| 867 } | 880 } |
| 868 | 881 |
| 869 void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon, | 882 void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 870 const gfx::ImageSkia& app_icon) { | 883 const gfx::ImageSkia& app_icon) { |
| 884 if (is_parallel_widget_in_window_manager()) | |
| 885 return; | |
| 886 | |
| 871 const char* const kWindowAppIcon_Property = | 887 const char* const kWindowAppIcon_Property = |
| 872 ui::mojom::WindowManager::kWindowAppIcon_Property; | 888 ui::mojom::WindowManager::kWindowAppIcon_Property; |
| 873 | 889 |
| 874 if (!app_icon.isNull()) { | 890 if (!app_icon.isNull()) { |
| 875 // Send the app icon 1x bitmap to the window manager. | 891 // Send the app icon 1x bitmap to the window manager. |
| 876 // TODO(jamescook): Support other scale factors. | 892 // TODO(jamescook): Support other scale factors. |
| 877 window_->SetSharedProperty<SkBitmap>( | 893 window_->SetSharedProperty<SkBitmap>( |
| 878 kWindowAppIcon_Property, app_icon.GetRepresentation(1.f).sk_bitmap()); | 894 kWindowAppIcon_Property, app_icon.GetRepresentation(1.f).sk_bitmap()); |
| 879 } else if (window_->HasSharedProperty(kWindowAppIcon_Property)) { | 895 } else if (window_->HasSharedProperty(kWindowAppIcon_Property)) { |
| 880 // Remove the existing icon. | 896 // Remove the existing icon. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1050 | 1066 |
| 1051 void NativeWidgetMus::Maximize() { | 1067 void NativeWidgetMus::Maximize() { |
| 1052 SetShowState(ui::mojom::ShowState::MAXIMIZED); | 1068 SetShowState(ui::mojom::ShowState::MAXIMIZED); |
| 1053 } | 1069 } |
| 1054 | 1070 |
| 1055 void NativeWidgetMus::Minimize() { | 1071 void NativeWidgetMus::Minimize() { |
| 1056 SetShowState(ui::mojom::ShowState::MINIMIZED); | 1072 SetShowState(ui::mojom::ShowState::MINIMIZED); |
| 1057 } | 1073 } |
| 1058 | 1074 |
| 1059 bool NativeWidgetMus::IsMaximized() const { | 1075 bool NativeWidgetMus::IsMaximized() const { |
| 1060 return mus_window_observer_ && | 1076 return GetShowState(window_) == ui::mojom::ShowState::MAXIMIZED; |
| 1061 mus_window_observer_->show_state() == ui::mojom::ShowState::MAXIMIZED; | |
| 1062 } | 1077 } |
| 1063 | 1078 |
| 1064 bool NativeWidgetMus::IsMinimized() const { | 1079 bool NativeWidgetMus::IsMinimized() const { |
| 1065 return mus_window_observer_ && | 1080 return GetShowState(window_) == ui::mojom::ShowState::MINIMIZED; |
| 1066 mus_window_observer_->show_state() == ui::mojom::ShowState::MINIMIZED; | |
| 1067 } | 1081 } |
| 1068 | 1082 |
| 1069 void NativeWidgetMus::Restore() { | 1083 void NativeWidgetMus::Restore() { |
| 1070 SetShowState(ui::mojom::ShowState::NORMAL); | 1084 SetShowState(ui::mojom::ShowState::NORMAL); |
| 1071 } | 1085 } |
| 1072 | 1086 |
| 1073 void NativeWidgetMus::SetFullscreen(bool fullscreen) { | 1087 void NativeWidgetMus::SetFullscreen(bool fullscreen) { |
| 1074 if (IsFullscreen() == fullscreen) | 1088 if (IsFullscreen() == fullscreen) |
| 1075 return; | 1089 return; |
| 1076 if (fullscreen) { | 1090 if (fullscreen) { |
| 1077 show_state_before_fullscreen_ = mus_window_observer_->show_state(); | 1091 show_state_before_fullscreen_ = GetShowState(window_); |
| 1078 // TODO(markdittmer): Fullscreen not implemented in ui::Window. | 1092 // TODO(markdittmer): Fullscreen not implemented in ui::Window. |
| 1079 } else { | 1093 } else { |
| 1080 switch (show_state_before_fullscreen_) { | 1094 switch (show_state_before_fullscreen_) { |
| 1081 case ui::mojom::ShowState::MAXIMIZED: | 1095 case ui::mojom::ShowState::MAXIMIZED: |
| 1082 Maximize(); | 1096 Maximize(); |
| 1083 break; | 1097 break; |
| 1084 case ui::mojom::ShowState::MINIMIZED: | 1098 case ui::mojom::ShowState::MINIMIZED: |
| 1085 Minimize(); | 1099 Minimize(); |
| 1086 break; | 1100 break; |
| 1087 case ui::mojom::ShowState::DEFAULT: | 1101 case ui::mojom::ShowState::DEFAULT: |
| 1088 case ui::mojom::ShowState::NORMAL: | 1102 case ui::mojom::ShowState::NORMAL: |
| 1089 case ui::mojom::ShowState::INACTIVE: | 1103 case ui::mojom::ShowState::INACTIVE: |
| 1090 case ui::mojom::ShowState::FULLSCREEN: | 1104 case ui::mojom::ShowState::FULLSCREEN: |
| 1091 case ui::mojom::ShowState::DOCKED: | 1105 case ui::mojom::ShowState::DOCKED: |
| 1092 // TODO(sad): This may not be sufficient. | 1106 // TODO(sad): This may not be sufficient. |
| 1093 Restore(); | 1107 Restore(); |
| 1094 break; | 1108 break; |
| 1095 } | 1109 } |
| 1096 } | 1110 } |
| 1097 } | 1111 } |
| 1098 | 1112 |
| 1099 bool NativeWidgetMus::IsFullscreen() const { | 1113 bool NativeWidgetMus::IsFullscreen() const { |
| 1100 return mus_window_observer_ && | 1114 return GetShowState(window_) == ui::mojom::ShowState::FULLSCREEN; |
| 1101 mus_window_observer_->show_state() == ui::mojom::ShowState::FULLSCREEN; | |
| 1102 } | 1115 } |
| 1103 | 1116 |
| 1104 void NativeWidgetMus::SetOpacity(float opacity) { | 1117 void NativeWidgetMus::SetOpacity(float opacity) { |
| 1105 if (window_) | 1118 if (window_) |
| 1106 window_->SetOpacity(opacity); | 1119 window_->SetOpacity(opacity); |
| 1107 } | 1120 } |
| 1108 | 1121 |
| 1109 void NativeWidgetMus::FlashFrame(bool flash_frame) { | 1122 void NativeWidgetMus::FlashFrame(bool flash_frame) { |
| 1110 // NOTIMPLEMENTED(); | 1123 // NOTIMPLEMENTED(); |
| 1111 } | 1124 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1214 void NativeWidgetMus::OnRootViewLayout() { | 1227 void NativeWidgetMus::OnRootViewLayout() { |
| 1215 // NOTIMPLEMENTED(); | 1228 // NOTIMPLEMENTED(); |
| 1216 } | 1229 } |
| 1217 | 1230 |
| 1218 bool NativeWidgetMus::IsTranslucentWindowOpacitySupported() const { | 1231 bool NativeWidgetMus::IsTranslucentWindowOpacitySupported() const { |
| 1219 // NOTIMPLEMENTED(); | 1232 // NOTIMPLEMENTED(); |
| 1220 return true; | 1233 return true; |
| 1221 } | 1234 } |
| 1222 | 1235 |
| 1223 void NativeWidgetMus::OnSizeConstraintsChanged() { | 1236 void NativeWidgetMus::OnSizeConstraintsChanged() { |
| 1224 if (!window_) | 1237 if (!window_ || is_parallel_widget_in_window_manager()) |
| 1225 return; | 1238 return; |
| 1226 | 1239 |
| 1227 window_->SetSharedProperty<int32_t>( | 1240 window_->SetSharedProperty<int32_t>( |
| 1228 ui::mojom::WindowManager::kResizeBehavior_Property, | 1241 ui::mojom::WindowManager::kResizeBehavior_Property, |
| 1229 ResizeBehaviorFromDelegate(GetWidget()->widget_delegate())); | 1242 ResizeBehaviorFromDelegate(GetWidget()->widget_delegate())); |
| 1230 } | 1243 } |
| 1231 | 1244 |
| 1232 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) { | 1245 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) { |
| 1233 // NOTIMPLEMENTED(); | 1246 // NOTIMPLEMENTED(); |
| 1234 } | 1247 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 } else { | 1417 } else { |
| 1405 window_tree_host_->Hide(); | 1418 window_tree_host_->Hide(); |
| 1406 GetNativeWindow()->Hide(); | 1419 GetNativeWindow()->Hide(); |
| 1407 } | 1420 } |
| 1408 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1421 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1409 } | 1422 } |
| 1410 | 1423 |
| 1411 void NativeWidgetMus::UpdateHitTestMask() { | 1424 void NativeWidgetMus::UpdateHitTestMask() { |
| 1412 // The window manager (or other underlay window provider) is not allowed to | 1425 // The window manager (or other underlay window provider) is not allowed to |
| 1413 // set a hit test mask, as that could interfere with a client app mask. | 1426 // set a hit test mask, as that could interfere with a client app mask. |
| 1414 if (surface_type_ == ui::mojom::SurfaceType::UNDERLAY) | 1427 if (is_parallel_widget_in_window_manager()) |
|
sadrul
2016/08/08 20:31:21
SWould it make sense to override these from WmNati
sky
2016/08/08 21:10:43
I have certainly done that, but it's very subtle a
| |
| 1415 return; | 1428 return; |
| 1416 | 1429 |
| 1417 if (!native_widget_delegate_->HasHitTestMask()) { | 1430 if (!native_widget_delegate_->HasHitTestMask()) { |
| 1418 window_->ClearHitTestMask(); | 1431 window_->ClearHitTestMask(); |
| 1419 return; | 1432 return; |
| 1420 } | 1433 } |
| 1421 | 1434 |
| 1422 gfx::Path mask_path; | 1435 gfx::Path mask_path; |
| 1423 native_widget_delegate_->GetHitTestMask(&mask_path); | 1436 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1424 // TODO(jamescook): Use the full path for the mask. | 1437 // TODO(jamescook): Use the full path for the mask. |
| 1425 gfx::Rect mask_rect = | 1438 gfx::Rect mask_rect = |
| 1426 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1439 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1427 window_->SetHitTestMask(mask_rect); | 1440 window_->SetHitTestMask(mask_rect); |
| 1428 } | 1441 } |
| 1429 | 1442 |
| 1430 } // namespace views | 1443 } // namespace views |
| OLD | NEW |