| 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 "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "components/bitmap_uploader/bitmap_uploader.h" | 9 #include "components/bitmap_uploader/bitmap_uploader.h" |
| 10 #include "components/mus/public/cpp/property_type_converters.h" | 10 #include "components/mus/public/cpp/property_type_converters.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); | 61 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, | 66 PlatformWindowMus::PlatformWindowMus(ui::PlatformWindowDelegate* delegate, |
| 67 shell::Connector* connector, | 67 shell::Connector* connector, |
| 68 mus::Window* mus_window) | 68 mus::Window* mus_window) |
| 69 : delegate_(delegate), | 69 : delegate_(delegate), |
| 70 mus_window_(mus_window), | 70 mus_window_(mus_window), |
| 71 show_state_(mus::mojom::ShowState::RESTORED), | 71 show_state_(mus::mojom::ShowState::DEFAULT), |
| 72 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), | 72 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 73 mus_window_destroyed_(false) { | 73 mus_window_destroyed_(false) { |
| 74 DCHECK(delegate_); | 74 DCHECK(delegate_); |
| 75 DCHECK(mus_window_); | 75 DCHECK(mus_window_); |
| 76 mus_window_->AddObserver(this); | 76 mus_window_->AddObserver(this); |
| 77 mus_window_->set_input_event_handler(this); | 77 mus_window_->set_input_event_handler(this); |
| 78 | 78 |
| 79 // We need accelerated widget numbers to be different for each | 79 // We need accelerated widget numbers to be different for each |
| 80 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t | 80 // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t |
| 81 // has this property. | 81 // has this property. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 void PlatformWindowMus::Maximize() { | 159 void PlatformWindowMus::Maximize() { |
| 160 SetShowState(mus::mojom::ShowState::MAXIMIZED); | 160 SetShowState(mus::mojom::ShowState::MAXIMIZED); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void PlatformWindowMus::Minimize() { | 163 void PlatformWindowMus::Minimize() { |
| 164 SetShowState(mus::mojom::ShowState::MINIMIZED); | 164 SetShowState(mus::mojom::ShowState::MINIMIZED); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void PlatformWindowMus::Restore() { | 167 void PlatformWindowMus::Restore() { |
| 168 SetShowState(mus::mojom::ShowState::RESTORED); | 168 SetShowState(mus::mojom::ShowState::NORMAL); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { | 171 void PlatformWindowMus::SetCursor(ui::PlatformCursor cursor) { |
| 172 NOTIMPLEMENTED(); | 172 NOTIMPLEMENTED(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { | 175 void PlatformWindowMus::MoveCursorTo(const gfx::Point& location) { |
| 176 NOTIMPLEMENTED(); | 176 NOTIMPLEMENTED(); |
| 177 } | 177 } |
| 178 | 178 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 return; | 239 return; |
| 240 show_state_ = show_state; | 240 show_state_ = show_state; |
| 241 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; | 241 ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN; |
| 242 switch (show_state_) { | 242 switch (show_state_) { |
| 243 case mus::mojom::ShowState::MINIMIZED: | 243 case mus::mojom::ShowState::MINIMIZED: |
| 244 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; | 244 state = ui::PLATFORM_WINDOW_STATE_MINIMIZED; |
| 245 break; | 245 break; |
| 246 case mus::mojom::ShowState::MAXIMIZED: | 246 case mus::mojom::ShowState::MAXIMIZED: |
| 247 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; | 247 state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED; |
| 248 break; | 248 break; |
| 249 case mus::mojom::ShowState::RESTORED: | 249 case mus::mojom::ShowState::DEFAULT: |
| 250 case mus::mojom::ShowState::INACTIVE: |
| 251 case mus::mojom::ShowState::NORMAL: |
| 252 case mus::mojom::ShowState::DOCKED: |
| 253 // TODO(sky): support docked. |
| 250 state = ui::PLATFORM_WINDOW_STATE_NORMAL; | 254 state = ui::PLATFORM_WINDOW_STATE_NORMAL; |
| 251 break; | 255 break; |
| 252 case mus::mojom::ShowState::IMMERSIVE: | 256 case mus::mojom::ShowState::FULLSCREEN: |
| 253 case mus::mojom::ShowState::PRESENTATION: | |
| 254 // This may not be sufficient. | |
| 255 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; | 257 state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN; |
| 256 break; | 258 break; |
| 257 } | 259 } |
| 258 delegate_->OnWindowStateChanged(state); | 260 delegate_->OnWindowStateChanged(state); |
| 259 } | 261 } |
| 260 | 262 |
| 261 void PlatformWindowMus::OnRequestClose(mus::Window* window) { | 263 void PlatformWindowMus::OnRequestClose(mus::Window* window) { |
| 262 delegate_->OnCloseRequest(); | 264 delegate_->OnCloseRequest(); |
| 263 } | 265 } |
| 264 | 266 |
| 265 void PlatformWindowMus::OnWindowInputEvent( | 267 void PlatformWindowMus::OnWindowInputEvent( |
| 266 mus::Window* view, | 268 mus::Window* view, |
| 267 const ui::Event& event_in, | 269 const ui::Event& event_in, |
| 268 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { | 270 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { |
| 269 // Take ownership of the callback, indicating that we will handle it. | 271 // Take ownership of the callback, indicating that we will handle it. |
| 270 EventAckHandler ack_handler(std::move(*ack_callback)); | 272 EventAckHandler ack_handler(std::move(*ack_callback)); |
| 271 | 273 |
| 272 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); | 274 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); |
| 273 delegate_->DispatchEvent(event.get()); | 275 delegate_->DispatchEvent(event.get()); |
| 274 // NOTE: |this| may be deleted. | 276 // NOTE: |this| may be deleted. |
| 275 | 277 |
| 276 ack_handler.set_handled(event->handled()); | 278 ack_handler.set_handled(event->handled()); |
| 277 // |ack_handler| acks the event on destruction if necessary. | 279 // |ack_handler| acks the event on destruction if necessary. |
| 278 } | 280 } |
| 279 | 281 |
| 280 } // namespace views | 282 } // namespace views |
| OLD | NEW |