| 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/platform_window_mus.h" | 5 #include "ui/views/mus/platform_window_mus.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "components/mus/public/cpp/property_type_converters.h" | 8 #include "components/mus/public/cpp/property_type_converters.h" |
| 9 #include "components/mus/public/cpp/window_property.h" | 9 #include "components/mus/public/cpp/window_property.h" |
| 10 #include "components/mus/public/interfaces/window_manager.mojom.h" | 10 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 11 #include "mojo/converters/input_events/input_events_type_converters.h" | 11 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 12 #include "ui/platform_window/platform_window_delegate.h" | 12 #include "ui/platform_window/platform_window_delegate.h" |
| 13 #include "ui/views/mus/window_manager_connection.h" | 13 #include "ui/views/mus/window_manager_connection.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 static uint32_t accelerated_widget_count = 1; | 18 static uint32_t accelerated_widget_count = 1; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, | 22 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, |
| 23 mus::Window* mus_window) | 23 mus::Window* mus_window) |
| 24 : delegate_(delegate), | 24 : delegate_(delegate), |
| 25 mus_window_(mus_window), | 25 mus_window_(mus_window), |
| 26 show_state_(mus::mojom::SHOW_STATE_RESTORED), | 26 show_state_(mus::mojom::ShowState::RESTORED), |
| 27 last_cursor_(mus::mojom::CURSOR_NULL), | 27 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 28 has_capture_(false), | 28 has_capture_(false), |
| 29 mus_window_destroyed_(false) { | 29 mus_window_destroyed_(false) { |
| 30 DCHECK(delegate_); | 30 DCHECK(delegate_); |
| 31 DCHECK(mus_window_); | 31 DCHECK(mus_window_); |
| 32 mus_window_->AddObserver(this); | 32 mus_window_->AddObserver(this); |
| 33 mus_window_->set_input_event_handler(this); | 33 mus_window_->set_input_event_handler(this); |
| 34 | 34 |
| 35 // We need accelerated widget numbers to be different for each | 35 // We need accelerated widget numbers to be different for each |
| 36 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 36 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
| 37 // has this property. | 37 // has this property. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // TODO(sky): this is wrong, need real capture api. | 104 // TODO(sky): this is wrong, need real capture api. |
| 105 has_capture_ = false; | 105 has_capture_ = false; |
| 106 NOTIMPLEMENTED(); | 106 NOTIMPLEMENTED(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void PlatformWindowMus::ToggleFullscreen() { | 109 void PlatformWindowMus::ToggleFullscreen() { |
| 110 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void PlatformWindowMus::Maximize() { | 113 void PlatformWindowMus::Maximize() { |
| 114 SetShowState(mus::mojom::SHOW_STATE_MAXIMIZED); | 114 SetShowState(mus::mojom::ShowState::MAXIMIZED); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PlatformWindowMus::Minimize() { | 117 void PlatformWindowMus::Minimize() { |
| 118 SetShowState(mus::mojom::SHOW_STATE_MINIMIZED); | 118 SetShowState(mus::mojom::ShowState::MINIMIZED); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void PlatformWindowMus::Restore() { | 121 void PlatformWindowMus::Restore() { |
| 122 SetShowState(mus::mojom::SHOW_STATE_RESTORED); | 122 SetShowState(mus::mojom::ShowState::RESTORED); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { | 125 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { |
| 126 NOTIMPLEMENTED(); | 126 NOTIMPLEMENTED(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { | 129 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { |
| 130 NOTIMPLEMENTED(); | 130 NOTIMPLEMENTED(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) { | 133 void PlatformWindowMus::ConfineCursorToBounds(const gfx::Rect& bounds) { |
| 134 NOTIMPLEMENTED(); | 134 NOTIMPLEMENTED(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() { | 137 ui::PlatformImeController* PlatformWindowMus::GetPlatformImeController() { |
| 138 return nullptr; | 138 return nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void PlatformWindowMus::SetShowState(mus::mojom::ShowState show_state) { | 141 void PlatformWindowMus::SetShowState(mus::mojom::ShowState show_state) { |
| 142 mus_window_->SetSharedProperty<int32_t>( | 142 mus_window_->SetSharedProperty<int32_t>( |
| 143 mus::mojom::WindowManager::kShowState_Property, show_state); | 143 mus::mojom::WindowManager::kShowState_Property, |
| 144 static_cast<int32_t>(show_state)); |
| 144 } | 145 } |
| 145 | 146 |
| 146 void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) { | 147 void PlatformWindowMus::OnWindowDestroyed(mus::Window* window) { |
| 147 DCHECK_EQ(mus_window_, window); | 148 DCHECK_EQ(mus_window_, window); |
| 148 mus_window_destroyed_ = true; | 149 mus_window_destroyed_ = true; |
| 149 #ifndef NDEBUG | 150 #ifndef NDEBUG |
| 150 weak_factory_.reset(new base::WeakPtrFactory<PlatformWindowMus>(this)); | 151 weak_factory_.reset(new base::WeakPtrFactory<PlatformWindowMus>(this)); |
| 151 base::WeakPtr<PlatformWindowMus> weak_ptr = weak_factory_->GetWeakPtr(); | 152 base::WeakPtr<PlatformWindowMus> weak_ptr = weak_factory_->GetWeakPtr(); |
| 152 #endif | 153 #endif |
| 153 delegate_->OnClosed(); | 154 delegate_->OnClosed(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 if (name != mus::mojom::WindowManager::kShowState_Property) | 187 if (name != mus::mojom::WindowManager::kShowState_Property) |
| 187 return; | 188 return; |
| 188 mus::mojom::ShowState show_state = | 189 mus::mojom::ShowState show_state = |
| 189 static_cast<mus::mojom::ShowState>(window->GetSharedProperty<int32_t>( | 190 static_cast<mus::mojom::ShowState>(window->GetSharedProperty<int32_t>( |
| 190 mus::mojom::WindowManager::kShowState_Property)); | 191 mus::mojom::WindowManager::kShowState_Property)); |
| 191 if (show_state == show_state_) | 192 if (show_state == show_state_) |
| 192 return; | 193 return; |
| 193 show_state_ = show_state; | 194 show_state_ = show_state; |
| 194 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; | 195 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; |
| 195 switch (show_state_) { | 196 switch (show_state_) { |
| 196 case mus::mojom::SHOW_STATE_MINIMIZED: | 197 case mus::mojom::ShowState::MINIMIZED: |
| 197 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; | 198 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; |
| 198 break; | 199 break; |
| 199 case mus::mojom::SHOW_STATE_MAXIMIZED: | 200 case mus::mojom::ShowState::MAXIMIZED: |
| 200 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; | 201 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; |
| 201 break; | 202 break; |
| 202 case mus::mojom::SHOW_STATE_RESTORED: | 203 case mus::mojom::ShowState::RESTORED: |
| 203 state = ui::PLATFORM_WINDOW_STATE_NORMAL; | 204 state = ui::PLATFORM_WINDOW_STATE_NORMAL; |
| 204 break; | 205 break; |
| 205 case mus::mojom::SHOW_STATE_IMMERSIVE: | 206 case mus::mojom::ShowState::IMMERSIVE: |
| 206 case mus::mojom::SHOW_STATE_PRESENTATION: | 207 case mus::mojom::ShowState::PRESENTATION: |
| 207 // This may not be sufficient. | 208 // This may not be sufficient. |
| 208 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; | 209 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; |
| 209 break; | 210 break; |
| 210 } | 211 } |
| 211 delegate_->OnWindowStateChanged(state); | 212 delegate_->OnWindowStateChanged(state); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void PlatformWindowMus::OnRequestClose(mus::Window* window) { | 215 void PlatformWindowMus::OnRequestClose(mus::Window* window) { |
| 215 delegate_->OnCloseRequest(); | 216 delegate_->OnCloseRequest(); |
| 216 } | 217 } |
| 217 | 218 |
| 218 void PlatformWindowMus::OnWindowInputEvent( | 219 void PlatformWindowMus::OnWindowInputEvent( |
| 219 mus::Window* view, | 220 mus::Window* view, |
| 220 mus::mojom::EventPtr event, | 221 mus::mojom::EventPtr event, |
| 221 scoped_ptr<base::Closure>* ack_callback) { | 222 scoped_ptr<base::Closure>* ack_callback) { |
| 222 // It's possible dispatching the event will spin a nested message loop. Ack | 223 // It's possible dispatching the event will spin a nested message loop. Ack |
| 223 // the callback now, otherwise we appear unresponsive for the life of the | 224 // the callback now, otherwise we appear unresponsive for the life of the |
| 224 // nested message loop. | 225 // nested message loop. |
| 225 (*ack_callback)->Run(); | 226 (*ack_callback)->Run(); |
| 226 ack_callback->reset(); | 227 ack_callback->reset(); |
| 227 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); | 228 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>()); |
| 228 delegate_->DispatchEvent(ui_event.get()); | 229 delegate_->DispatchEvent(ui_event.get()); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace views | 232 } // namespace views |
| OLD | NEW |