Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 1962043002: Move Show and Hide impls from PlatformWindowMus to NativeWidgetMus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/mus/platform_window_mus.h » ('j') | ui/views/mus/platform_window_mus.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 7 #include "base/macros.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property); 704 return window_->GetSharedProperty<gfx::Rect>(kRestoreBounds_Property);
705 } 705 }
706 return GetWindowBoundsInScreen(); 706 return GetWindowBoundsInScreen();
707 } 707 }
708 708
709 std::string NativeWidgetMus::GetWorkspace() const { 709 std::string NativeWidgetMus::GetWorkspace() const {
710 return std::string(); 710 return std::string();
711 } 711 }
712 712
713 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) { 713 void NativeWidgetMus::SetBounds(const gfx::Rect& bounds) {
714 if (!window_tree_host_) 714 if (!(window_ && window_tree_host_))
715 return; 715 return;
716 716
717 gfx::Size size(bounds.size()); 717 gfx::Size size(bounds.size());
718 const gfx::Size min_size = GetMinimumSize(); 718 const gfx::Size min_size = GetMinimumSize();
719 const gfx::Size max_size = GetMaximumSize(); 719 const gfx::Size max_size = GetMaximumSize();
720 if (!max_size.IsEmpty()) 720 if (!max_size.IsEmpty())
721 size.SetToMin(max_size); 721 size.SetToMin(max_size);
722 size.SetToMax(min_size); 722 size.SetToMax(min_size);
723 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size)); 723 window_tree_host_->SetBounds(gfx::Rect(bounds.origin(), size));
724 window_->SetBounds(gfx::Rect(bounds.origin(), size));
724 } 725 }
725 726
726 void NativeWidgetMus::SetSize(const gfx::Size& size) { 727 void NativeWidgetMus::SetSize(const gfx::Size& size) {
727 if (!window_tree_host_) 728 if (!window_tree_host_)
728 return; 729 return;
729 730
730 gfx::Rect bounds = window_tree_host_->GetBounds(); 731 gfx::Rect bounds = window_tree_host_->GetBounds();
731 SetBounds(gfx::Rect(bounds.origin(), size)); 732 SetBounds(gfx::Rect(bounds.origin(), size));
732 } 733 }
733 734
(...skipping 30 matching lines...) Expand all
764 765
765 void NativeWidgetMus::Show() { 766 void NativeWidgetMus::Show() {
766 ShowWithWindowState(ui::SHOW_STATE_NORMAL); 767 ShowWithWindowState(ui::SHOW_STATE_NORMAL);
767 } 768 }
768 769
769 void NativeWidgetMus::Hide() { 770 void NativeWidgetMus::Hide() {
770 if (!window_tree_host_) 771 if (!window_tree_host_)
771 return; 772 return;
772 773
773 window_tree_host_->Hide(); 774 window_tree_host_->Hide();
775 window_->SetVisible(false);
774 GetNativeWindow()->Hide(); 776 GetNativeWindow()->Hide();
775 } 777 }
776 778
777 void NativeWidgetMus::ShowMaximizedWithBounds( 779 void NativeWidgetMus::ShowMaximizedWithBounds(
778 const gfx::Rect& restored_bounds) { 780 const gfx::Rect& restored_bounds) {
779 // NOTIMPLEMENTED(); 781 // NOTIMPLEMENTED();
780 } 782 }
781 783
782 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) { 784 void NativeWidgetMus::ShowWithWindowState(ui::WindowShowState state) {
783 if (!window_tree_host_) 785 if (!(window_ && window_tree_host_))
784 return; 786 return;
785 787
786 window_tree_host_->Show(); 788 window_tree_host_->Show();
789 window_->SetVisible(true);
787 GetNativeWindow()->Show(); 790 GetNativeWindow()->Show();
788 if (native_widget_delegate_->CanActivate()) { 791 if (native_widget_delegate_->CanActivate()) {
789 if (state != ui::SHOW_STATE_INACTIVE) 792 if (state != ui::SHOW_STATE_INACTIVE)
790 Activate(); 793 Activate();
791 GetWidget()->SetInitialFocus(state); 794 GetWidget()->SetInitialFocus(state);
792 } 795 }
793 } 796 }
794 797
795 bool NativeWidgetMus::IsVisible() const { 798 bool NativeWidgetMus::IsVisible() const {
796 // TODO(beng): this should probably be wired thru PlatformWindow. 799 // TODO(beng): this should probably be wired thru PlatformWindow.
797 return window_ && window_->visible(); 800 return window_ && window_->visible();
798 } 801 }
799 802
800 void NativeWidgetMus::Activate() { 803 void NativeWidgetMus::Activate() {
801 if (window_tree_host_) 804 if (window_)
802 window_tree_host_->platform_window()->Activate(); 805 window_->SetFocus();
803 } 806 }
804 807
805 void NativeWidgetMus::Deactivate() { 808 void NativeWidgetMus::Deactivate() {
806 if (IsActive()) 809 if (IsActive())
807 window_->connection()->ClearFocus(); 810 window_->connection()->ClearFocus();
808 } 811 }
809 812
810 bool NativeWidgetMus::IsActive() const { 813 bool NativeWidgetMus::IsActive() const {
811 mus::Window* focused = 814 mus::Window* focused =
812 window_ ? window_->connection()->GetFocusedWindow() : nullptr; 815 window_ ? window_->connection()->GetFocusedWindow() : nullptr;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 GetWidget()->Close(); 1117 GetWidget()->Close();
1115 } 1118 }
1116 1119
1117 void NativeWidgetMus::OnMusWindowVisibilityChanging(mus::Window* window) { 1120 void NativeWidgetMus::OnMusWindowVisibilityChanging(mus::Window* window) {
1118 native_widget_delegate_->OnNativeWidgetVisibilityChanging(!window->visible()); 1121 native_widget_delegate_->OnNativeWidgetVisibilityChanging(!window->visible());
1119 } 1122 }
1120 1123
1121 void NativeWidgetMus::OnMusWindowVisibilityChanged(mus::Window* window) { 1124 void NativeWidgetMus::OnMusWindowVisibilityChanged(mus::Window* window) {
1122 if (window->visible()) { 1125 if (window->visible()) {
1123 window_tree_host_->Show(); 1126 window_tree_host_->Show();
1127 window_->SetVisible(true);
1124 GetNativeWindow()->Show(); 1128 GetNativeWindow()->Show();
1125 } else { 1129 } else {
1126 window_tree_host_->Hide(); 1130 window_tree_host_->Hide();
1131 window_->SetVisible(false);
1127 GetNativeWindow()->Hide(); 1132 GetNativeWindow()->Hide();
1128 } 1133 }
1129 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1134 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
1130 } 1135 }
1131 1136
1132 } // namespace views 1137 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/mus/platform_window_mus.h » ('j') | ui/views/mus/platform_window_mus.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698