| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 tree_client()->SetWindowTextInputState(id_, std::move(state)); | 366 tree_client()->SetWindowTextInputState(id_, std::move(state)); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { | 369 void Window::SetImeVisibility(bool visible, mojo::TextInputStatePtr state) { |
| 370 // SetImeVisibility() shouldn't be used if the window is not editable. | 370 // SetImeVisibility() shouldn't be used if the window is not editable. |
| 371 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); | 371 DCHECK(state.is_null() || state->type != mojo::TEXT_INPUT_TYPE_NONE); |
| 372 if (connection_) | 372 if (connection_) |
| 373 tree_client()->SetImeVisibility(id_, visible, std::move(state)); | 373 tree_client()->SetImeVisibility(id_, visible, std::move(state)); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void Window::SetCapture() { |
| 377 if (connection_) |
| 378 tree_client()->SetCapture(this); |
| 379 LocalSetCapture(true); |
| 380 } |
| 381 |
| 382 void Window::ReleaseCapture() { |
| 383 if (connection_) |
| 384 tree_client()->ReleaseCapture(this); |
| 385 LocalSetCapture(false); |
| 386 } |
| 387 |
| 376 void Window::SetFocus() { | 388 void Window::SetFocus() { |
| 377 if (connection_ && IsDrawn()) | 389 if (connection_ && IsDrawn()) |
| 378 tree_client()->SetFocus(this); | 390 tree_client()->SetFocus(this); |
| 379 } | 391 } |
| 380 | 392 |
| 381 bool Window::HasFocus() const { | 393 bool Window::HasFocus() const { |
| 382 return connection_ && connection_->GetFocusedWindow() == this; | 394 return connection_ && connection_->GetFocusedWindow() == this; |
| 383 } | 395 } |
| 384 | 396 |
| 385 void Window::SetCanFocus(bool can_focus) { | 397 void Window::SetCanFocus(bool can_focus) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 488 |
| 477 Window::Window(WindowTreeConnection* connection, Id id) | 489 Window::Window(WindowTreeConnection* connection, Id id) |
| 478 : connection_(connection), | 490 : connection_(connection), |
| 479 id_(id), | 491 id_(id), |
| 480 parent_(nullptr), | 492 parent_(nullptr), |
| 481 stacking_target_(nullptr), | 493 stacking_target_(nullptr), |
| 482 transient_parent_(nullptr), | 494 transient_parent_(nullptr), |
| 483 input_event_handler_(nullptr), | 495 input_event_handler_(nullptr), |
| 484 viewport_metrics_(CreateEmptyViewportMetrics()), | 496 viewport_metrics_(CreateEmptyViewportMetrics()), |
| 485 visible_(false), | 497 visible_(false), |
| 498 has_capture_(false), |
| 486 cursor_id_(mojom::CURSOR_NULL), | 499 cursor_id_(mojom::CURSOR_NULL), |
| 487 drawn_(false) {} | 500 drawn_(false) {} |
| 488 | 501 |
| 489 WindowTreeClientImpl* Window::tree_client() { | 502 WindowTreeClientImpl* Window::tree_client() { |
| 490 return static_cast<WindowTreeClientImpl*>(connection_); | 503 return static_cast<WindowTreeClientImpl*>(connection_); |
| 491 } | 504 } |
| 492 | 505 |
| 493 void Window::SetSharedPropertyInternal(const std::string& name, | 506 void Window::SetSharedPropertyInternal(const std::string& name, |
| 494 const std::vector<uint8_t>* value) { | 507 const std::vector<uint8_t>* value) { |
| 495 if (!OwnsWindowOrIsRoot(this)) | 508 if (!OwnsWindowOrIsRoot(this)) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 | 595 |
| 583 void Window::LocalSetBounds(const gfx::Rect& old_bounds, | 596 void Window::LocalSetBounds(const gfx::Rect& old_bounds, |
| 584 const gfx::Rect& new_bounds) { | 597 const gfx::Rect& new_bounds) { |
| 585 // If this client owns the window, then it should be the only one to change | 598 // If this client owns the window, then it should be the only one to change |
| 586 // the bounds. | 599 // the bounds. |
| 587 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); | 600 DCHECK(!OwnsWindow(connection_, this) || old_bounds == bounds_); |
| 588 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); | 601 ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); |
| 589 bounds_ = new_bounds; | 602 bounds_ = new_bounds; |
| 590 } | 603 } |
| 591 | 604 |
| 605 void Window::LocalSetCapture(bool capture) { |
| 606 has_capture_ = capture; |
| 607 } |
| 608 |
| 592 void Window::LocalSetClientArea( | 609 void Window::LocalSetClientArea( |
| 593 const gfx::Insets& new_client_area, | 610 const gfx::Insets& new_client_area, |
| 594 const std::vector<gfx::Rect>& additional_client_areas) { | 611 const std::vector<gfx::Rect>& additional_client_areas) { |
| 595 const std::vector<gfx::Rect> old_additional_client_areas = | 612 const std::vector<gfx::Rect> old_additional_client_areas = |
| 596 additional_client_areas_; | 613 additional_client_areas_; |
| 597 const gfx::Insets old_client_area = client_area_; | 614 const gfx::Insets old_client_area = client_area_; |
| 598 client_area_ = new_client_area; | 615 client_area_ = new_client_area; |
| 599 additional_client_areas_ = additional_client_areas; | 616 additional_client_areas_ = additional_client_areas; |
| 600 FOR_EACH_OBSERVER(WindowObserver, observers_, | 617 FOR_EACH_OBSERVER(WindowObserver, observers_, |
| 601 OnWindowClientAreaChanged(this, old_client_area, | 618 OnWindowClientAreaChanged(this, old_client_area, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 notifier->NotifyWindowReordered(); | 830 notifier->NotifyWindowReordered(); |
| 814 | 831 |
| 815 return true; | 832 return true; |
| 816 } | 833 } |
| 817 | 834 |
| 818 // static | 835 // static |
| 819 Window** Window::GetStackingTarget(Window* window) { | 836 Window** Window::GetStackingTarget(Window* window) { |
| 820 return &window->stacking_target_; | 837 return &window->stacking_target_; |
| 821 } | 838 } |
| 822 } // namespace mus | 839 } // namespace mus |
| OLD | NEW |