Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/mus/ws/window_manager_state.h" | 5 #include "components/mus/ws/window_manager_state.h" |
| 6 | 6 |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "components/mus/ws/accelerator.h" | 8 #include "components/mus/ws/accelerator.h" |
| 9 #include "components/mus/ws/display_manager.h" | 9 #include "components/mus/ws/display_manager.h" |
| 10 #include "components/mus/ws/platform_display.h" | 10 #include "components/mus/ws/platform_display.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 if (tree_awaiting_input_ack_ != tree) | 158 if (tree_awaiting_input_ack_ != tree) |
| 159 return; | 159 return; |
| 160 // The WindowTree is dying. So it's not going to ack the event. | 160 // The WindowTree is dying. So it's not going to ack the event. |
| 161 // If the dying tree matches the root |tree_| marked as handled so we don't | 161 // If the dying tree matches the root |tree_| marked as handled so we don't |
| 162 // notify it of accelerators. | 162 // notify it of accelerators. |
| 163 OnEventAck(tree_awaiting_input_ack_, tree == tree_ | 163 OnEventAck(tree_awaiting_input_ack_, tree == tree_ |
| 164 ? mojom::EventResult::HANDLED | 164 ? mojom::EventResult::HANDLED |
| 165 : mojom::EventResult::UNHANDLED); | 165 : mojom::EventResult::UNHANDLED); |
| 166 } | 166 } |
| 167 | 167 |
| 168 mojo::ScopedSharedBufferHandle WindowManagerState::GetCursorLocationMemory() { | |
|
sky
2016/04/27 20:10:28
If you put this code here, it means we're only get
| |
| 169 if (!cursor_location_memory_) { | |
| 170 // Create our shared memory segment to share the cursor state with our | |
| 171 // window clients. | |
| 172 MojoResult result = mojo::CreateSharedBuffer(nullptr, | |
| 173 sizeof(base::subtle::Atomic32), | |
| 174 &cursor_location_handle_); | |
| 175 if (result != MOJO_RESULT_OK) | |
| 176 return mojo::ScopedSharedBufferHandle(); | |
| 177 DCHECK(cursor_location_handle_.is_valid()); | |
| 178 | |
| 179 result = mojo::MapBuffer(cursor_location_handle_.get(), 0, | |
| 180 sizeof(base::subtle::Atomic32), | |
| 181 reinterpret_cast<void**>(&cursor_location_memory_), | |
| 182 MOJO_MAP_BUFFER_FLAG_NONE); | |
| 183 if (result != MOJO_RESULT_OK) | |
| 184 return mojo::ScopedSharedBufferHandle(); | |
| 185 DCHECK(cursor_location_memory_); | |
| 186 | |
| 187 base::subtle::NoBarrier_Store(cursor_location_memory_, | |
| 188 current_cursor_location_); | |
| 189 } | |
| 190 | |
| 191 mojo::ScopedSharedBufferHandle duped; | |
| 192 MojoDuplicateBufferHandleOptions options = { | |
| 193 sizeof(MojoDuplicateBufferHandleOptions), | |
| 194 MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_READ_ONLY | |
| 195 }; | |
| 196 MojoResult result = mojo::DuplicateBuffer(cursor_location_handle_.get(), | |
| 197 &options, &duped); | |
| 198 if (result != MOJO_RESULT_OK) | |
| 199 return mojo::ScopedSharedBufferHandle(); | |
| 200 DCHECK(duped.is_valid()); | |
| 201 | |
| 202 return duped; | |
| 203 } | |
| 204 | |
| 168 WindowManagerState::WindowManagerState(Display* display, | 205 WindowManagerState::WindowManagerState(Display* display, |
| 169 PlatformDisplay* platform_display, | 206 PlatformDisplay* platform_display, |
| 170 cc::SurfaceId surface_id, | 207 cc::SurfaceId surface_id, |
| 171 bool is_user_id_valid, | 208 bool is_user_id_valid, |
| 172 const UserId& user_id) | 209 const UserId& user_id) |
| 173 : display_(display), | 210 : display_(display), |
| 174 platform_display_(platform_display), | 211 platform_display_(platform_display), |
| 175 is_user_id_valid_(is_user_id_valid), | 212 is_user_id_valid_(is_user_id_valid), |
| 176 user_id_(user_id), | 213 user_id_(user_id), |
| 177 event_dispatcher_(this) { | 214 event_dispatcher_(this), |
| 215 current_cursor_location_(0), | |
| 216 cursor_location_memory_(nullptr) { | |
| 178 frame_decoration_values_ = mojom::FrameDecorationValues::New(); | 217 frame_decoration_values_ = mojom::FrameDecorationValues::New(); |
| 179 frame_decoration_values_->normal_client_area_insets = mojo::Insets::New(); | 218 frame_decoration_values_->normal_client_area_insets = mojo::Insets::New(); |
| 180 frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New(); | 219 frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New(); |
| 181 frame_decoration_values_->max_title_bar_button_width = 0u; | 220 frame_decoration_values_->max_title_bar_button_width = 0u; |
| 182 | 221 |
| 183 root_.reset(window_server()->CreateServerWindow( | 222 root_.reset(window_server()->CreateServerWindow( |
| 184 window_server()->display_manager()->GetAndAdvanceNextRootId(), | 223 window_server()->display_manager()->GetAndAdvanceNextRootId(), |
| 185 ServerWindow::Properties())); | 224 ServerWindow::Properties())); |
| 186 // Our root is always a child of the Display's root. Do this | 225 // Our root is always a child of the Display's root. Do this |
| 187 // before the WindowTree has been created so that the client doesn't get | 226 // before the WindowTree has been created so that the client doesn't get |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 401 |
| 363 void WindowManagerState::ReleaseNativeCapture() { | 402 void WindowManagerState::ReleaseNativeCapture() { |
| 364 platform_display_->ReleaseCapture(); | 403 platform_display_->ReleaseCapture(); |
| 365 } | 404 } |
| 366 | 405 |
| 367 void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) { | 406 void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) { |
| 368 DCHECK(window); | 407 DCHECK(window); |
| 369 window_server()->ProcessLostCapture(window); | 408 window_server()->ProcessLostCapture(window); |
| 370 } | 409 } |
| 371 | 410 |
| 411 void WindowManagerState::OnMouseCursorLocationChanged( | |
| 412 const gfx::Point& point) { | |
| 413 current_cursor_location_ = | |
| 414 static_cast<base::subtle::Atomic32>( | |
| 415 (point.x() & 0xFFFF) << 16 | (point.y() & 0xFFFF)); | |
| 416 if (cursor_location_memory_) { | |
| 417 base::subtle::NoBarrier_Store(cursor_location_memory_, | |
| 418 current_cursor_location_); | |
| 419 } | |
| 420 } | |
| 421 | |
| 372 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, | 422 void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, |
| 373 bool in_nonclient_area, | 423 bool in_nonclient_area, |
| 374 const ui::Event& event, | 424 const ui::Event& event, |
| 375 Accelerator* accelerator) { | 425 Accelerator* accelerator) { |
| 376 DCHECK(IsActive()); | 426 DCHECK(IsActive()); |
| 377 // TODO(sky): this needs to see if another wms has capture and if so forward | 427 // TODO(sky): this needs to see if another wms has capture and if so forward |
| 378 // to it. | 428 // to it. |
| 379 if (event_ack_timer_.IsRunning()) { | 429 if (event_ack_timer_.IsRunning()) { |
| 380 std::unique_ptr<ProcessedEventTarget> processed_event_target( | 430 std::unique_ptr<ProcessedEventTarget> processed_event_target( |
| 381 new ProcessedEventTarget(target, in_nonclient_area, accelerator)); | 431 new ProcessedEventTarget(target, in_nonclient_area, accelerator)); |
| 382 QueueEvent(event, std::move(processed_event_target)); | 432 QueueEvent(event, std::move(processed_event_target)); |
| 383 return; | 433 return; |
| 384 } | 434 } |
| 385 | 435 |
| 386 base::WeakPtr<Accelerator> weak_accelerator; | 436 base::WeakPtr<Accelerator> weak_accelerator; |
| 387 if (accelerator) | 437 if (accelerator) |
| 388 weak_accelerator = accelerator->GetWeakPtr(); | 438 weak_accelerator = accelerator->GetWeakPtr(); |
| 389 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, | 439 DispatchInputEventToWindowImpl(target, in_nonclient_area, event, |
| 390 weak_accelerator); | 440 weak_accelerator); |
| 391 } | 441 } |
| 392 | 442 |
| 393 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { | 443 void WindowManagerState::OnEventTargetNotFound(const ui::Event& event) { |
| 394 window_server()->SendToEventObservers(event, user_id_, | 444 window_server()->SendToEventObservers(event, user_id_, |
| 395 nullptr /* ignore_tree */); | 445 nullptr /* ignore_tree */); |
| 396 } | 446 } |
| 397 | 447 |
| 398 } // namespace ws | 448 } // namespace ws |
| 399 } // namespace mus | 449 } // namespace mus |
| OLD | NEW |