Chromium Code Reviews| Index: ui/views/mus/native_widget_mus.cc |
| diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc |
| index ca04c519c22a36467feb9488b854b8f0a38f5f33..bb2fe8091afd51ae02b78b3758a93c47e70e9d95 100644 |
| --- a/ui/views/mus/native_widget_mus.cc |
| +++ b/ui/views/mus/native_widget_mus.cc |
| @@ -12,6 +12,8 @@ |
| #include "components/mus/public/cpp/window_property.h" |
| #include "components/mus/public/cpp/window_tree_connection.h" |
| #include "components/mus/public/interfaces/cursor.mojom.h" |
| +#include "components/mus/public/interfaces/window_manager.mojom.h" |
| +#include "components/mus/public/interfaces/window_manager_constants.mojom.h" |
| #include "mojo/converters/geometry/geometry_type_converters.h" |
| #include "ui/aura/client/default_capture_client.h" |
| #include "ui/aura/client/window_tree_client.h" |
| @@ -298,7 +300,8 @@ SkBitmap AppIconFromDelegate(WidgetDelegate* delegate) { |
| class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| public: |
| explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) |
| - : native_widget_mus_(native_widget_mus) { |
| + : native_widget_mus_(native_widget_mus), |
| + show_state_(mus::mojom::ShowState::DEFAULT) { |
| mus_window()->AddObserver(this); |
| } |
| @@ -318,6 +321,40 @@ class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| const gfx::Rect& new_bounds) override { |
| platform_window_delegate()->OnBoundsChanged(new_bounds); |
| } |
| + void OnWindowSharedPropertyChanged( |
| + mus::Window* window, |
| + const std::string& name, |
| + const std::vector<uint8_t>* old_data, |
| + const std::vector<uint8_t>* new_data) override { |
| + if (name != mus::mojom::WindowManager::kShowState_Property) |
| + return; |
| + mus::mojom::ShowState show_state = |
| + static_cast<mus::mojom::ShowState>(window->GetSharedProperty<int32_t>( |
| + mus::mojom::WindowManager::kShowState_Property)); |
| + if (show_state == show_state_) |
| + return; |
| + show_state_ = show_state; |
| + ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; |
| + switch (show_state_) { |
| + case mus::mojom::ShowState::MINIMIZED: |
| + state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; |
| + break; |
| + case mus::mojom::ShowState::MAXIMIZED: |
| + state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; |
| + break; |
| + case mus::mojom::ShowState::DEFAULT: |
| + case mus::mojom::ShowState::INACTIVE: |
| + case mus::mojom::ShowState::NORMAL: |
| + case mus::mojom::ShowState::DOCKED: |
| + // TODO(sky): support docked. |
| + state = ui::PLATFORM_WINDOW_STATE_NORMAL; |
| + break; |
| + case mus::mojom::ShowState::FULLSCREEN: |
| + state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; |
| + break; |
| + } |
| + platform_window_delegate()->OnWindowStateChanged(state); |
| + } |
| private: |
| mus::Window* mus_window() { return native_widget_mus_->window(); } |
| @@ -330,6 +367,7 @@ class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| } |
| NativeWidgetMus* native_widget_mus_; |
| + mus::mojom::ShowState show_state_; |
| DISALLOW_COPY_AND_ASSIGN(MusWindowObserver); |
| }; |
| @@ -856,13 +894,19 @@ void NativeWidgetMus::SetVisibleOnAllWorkspaces(bool always_visible) { |
| } |
| void NativeWidgetMus::Maximize() { |
| - if (window_tree_host_) |
| - window_tree_host_->platform_window()->Maximize(); |
| + if (!(window_ && window_tree_host_)) |
| + return; |
| + |
| + window_tree_host_->platform_window()->Maximize(); |
|
sadrul
2016/05/11 05:12:47
Remove these calls to platform_window()
Mark Dittmer
2016/05/11 13:37:37
Done.
|
| + SetShowState(mus::mojom::ShowState::MAXIMIZED); |
| } |
| void NativeWidgetMus::Minimize() { |
| - if (window_tree_host_) |
| - window_tree_host_->platform_window()->Minimize(); |
| + if (!(window_ && window_tree_host_)) |
| + return; |
| + |
| + window_tree_host_->platform_window()->Minimize(); |
| + SetShowState(mus::mojom::ShowState::MINIMIZED); |
| } |
| bool NativeWidgetMus::IsMaximized() const { |
| @@ -876,8 +920,11 @@ bool NativeWidgetMus::IsMinimized() const { |
| } |
| void NativeWidgetMus::Restore() { |
| - if (window_tree_host_) |
| - window_tree_host_->platform_window()->Restore(); |
| + if (!(window_ && window_tree_host_)) |
| + return; |
| + |
| + window_tree_host_->platform_window()->Restore(); |
| + SetShowState(mus::mojom::ShowState::NORMAL); |
| } |
| void NativeWidgetMus::SetFullscreen(bool fullscreen) { |
| @@ -1096,6 +1143,12 @@ void NativeWidgetMus::GetHitTestMask(gfx::Path* mask) const { |
| native_widget_delegate_->GetHitTestMask(mask); |
| } |
| +void NativeWidgetMus::SetShowState(mus::mojom::ShowState show_state) { |
| + window_->SetSharedProperty<int32_t>( |
| + mus::mojom::WindowManager::kShowState_Property, |
| + static_cast<int32_t>(show_state)); |
| +} |
| + |
| void NativeWidgetMus::OnKeyEvent(ui::KeyEvent* event) { |
| if (event->is_char()) { |
| // If a ui::InputMethod object is attached to the root window, character |