Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2454973003: Wires up modality for aura-mus (Closed)
Patch Set: cleanup Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 13 matching lines...) Expand all
24 #include "ui/aura/mus/surface_id_handler.h" 24 #include "ui/aura/mus/surface_id_handler.h"
25 #include "ui/aura/mus/window_manager_delegate.h" 25 #include "ui/aura/mus/window_manager_delegate.h"
26 #include "ui/aura/mus/window_mus.h" 26 #include "ui/aura/mus/window_mus.h"
27 #include "ui/aura/mus/window_port_mus.h" 27 #include "ui/aura/mus/window_port_mus.h"
28 #include "ui/aura/mus/window_tree_client_delegate.h" 28 #include "ui/aura/mus/window_tree_client_delegate.h"
29 #include "ui/aura/mus/window_tree_client_observer.h" 29 #include "ui/aura/mus/window_tree_client_observer.h"
30 #include "ui/aura/mus/window_tree_host_mus.h" 30 #include "ui/aura/mus/window_tree_host_mus.h"
31 #include "ui/aura/window.h" 31 #include "ui/aura/window.h"
32 #include "ui/aura/window_delegate.h" 32 #include "ui/aura/window_delegate.h"
33 #include "ui/aura/window_tracker.h" 33 #include "ui/aura/window_tracker.h"
34 #include "ui/base/ui_base_types.h"
34 #include "ui/events/event.h" 35 #include "ui/events/event.h"
35 #include "ui/gfx/geometry/insets.h" 36 #include "ui/gfx/geometry/insets.h"
36 #include "ui/gfx/geometry/size.h" 37 #include "ui/gfx/geometry/size.h"
37 38
38 #if defined(HiWord) 39 #if defined(HiWord)
39 #undef HiWord 40 #undef HiWord
40 #endif 41 #endif
41 #if defined(LoWord) 42 #if defined(LoWord)
42 #undef LoWord 43 #undef LoWord
43 #endif 44 #endif
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 109 }
109 } 110 }
110 111
111 private: 112 private:
112 std::unique_ptr<EventResultCallback> ack_callback_; 113 std::unique_ptr<EventResultCallback> ack_callback_;
113 bool handled_ = false; 114 bool handled_ = false;
114 115
115 DISALLOW_COPY_AND_ASSIGN(EventAckHandler); 116 DISALLOW_COPY_AND_ASSIGN(EventAckHandler);
116 }; 117 };
117 118
119 bool IsInternalProperty(const void* key) {
120 return key == client::kModalKey;
121 }
122
118 } // namespace 123 } // namespace
119 124
120 struct WindowTreeClient::CurrentDragState { 125 struct WindowTreeClient::CurrentDragState {
121 // The current change id of the current drag an drop ipc. 126 // The current change id of the current drag an drop ipc.
122 uint32_t change_id; 127 uint32_t change_id;
123 128
124 // The effect to return when we send our finish signal. 129 // The effect to return when we send our finish signal.
125 uint32_t completed_action; 130 uint32_t completed_action;
126 131
127 // Callback executed when a drag initiated by PerformDragDrop() is completed. 132 // Callback executed when a drag initiated by PerformDragDrop() is completed.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (window_manager_delegate_) { 496 if (window_manager_delegate_) {
492 tree_ptr_->GetWindowManagerClient(GetProxy(&window_manager_internal_client_, 497 tree_ptr_->GetWindowManagerClient(GetProxy(&window_manager_internal_client_,
493 tree_ptr_.associated_group())); 498 tree_ptr_.associated_group()));
494 } 499 }
495 } 500 }
496 501
497 void WindowTreeClient::OnConnectionLost() { 502 void WindowTreeClient::OnConnectionLost() {
498 delegate_->OnLostConnection(this); 503 delegate_->OnLostConnection(this);
499 } 504 }
500 505
506 bool WindowTreeClient::HandleInternalPropertyChanged(WindowMus* window,
507 const void* key) {
508 if (key != client::kModalKey)
msw 2016/10/27 18:37:37 q: check !IsInternalProperty(key) for extensibilit
sky 2016/10/27 19:30:06 Ya, I figured once we have more than one property
509 return false;
510
511 if (window->GetWindow()->GetProperty(client::kModalKey) ==
512 ui::MODAL_TYPE_NONE) {
513 return true;
msw 2016/10/27 18:37:37 Should this be clearing modality if the window was
sky 2016/10/27 19:30:06 Yes, but again because the mojom API is basically
514 }
515
516 const uint32_t change_id =
517 ScheduleInFlightChange(base::MakeUnique<InFlightSetModalChange>(window));
518 // TODO: this is subtly different that explicitly specifying a type.
519 // http://crbug.com/660073.
520 tree_->SetModal(change_id, window->server_id());
521 return true;
522 }
523
501 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree, 524 void WindowTreeClient::OnEmbedImpl(ui::mojom::WindowTree* window_tree,
502 ClientSpecificId client_id, 525 ClientSpecificId client_id,
503 ui::mojom::WindowDataPtr root_data, 526 ui::mojom::WindowDataPtr root_data,
504 int64_t display_id, 527 int64_t display_id,
505 Id focused_window_id, 528 Id focused_window_id,
506 bool drawn) { 529 bool drawn) {
507 // WARNING: this is only called if WindowTreeClient was created as the 530 // WARNING: this is only called if WindowTreeClient was created as the
508 // result of an embedding. 531 // result of an embedding.
509 tree_ = window_tree; 532 tree_ = window_tree;
510 client_id_ = client_id; 533 client_id_ = client_id;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 // TODO: add checks to ensure this can work. 720 // TODO: add checks to ensure this can work.
698 DCHECK(tree_); 721 DCHECK(tree_);
699 const uint32_t change_id = ScheduleInFlightChange( 722 const uint32_t change_id = ScheduleInFlightChange(
700 base::MakeUnique<InFlightVisibleChange>(window, !visible)); 723 base::MakeUnique<InFlightVisibleChange>(window, !visible));
701 tree_->SetWindowVisibility(change_id, window->server_id(), visible); 724 tree_->SetWindowVisibility(change_id, window->server_id(), visible);
702 } 725 }
703 726
704 std::unique_ptr<WindowPortPropertyData> 727 std::unique_ptr<WindowPortPropertyData>
705 WindowTreeClient::OnWindowMusWillChangeProperty(WindowMus* window, 728 WindowTreeClient::OnWindowMusWillChangeProperty(WindowMus* window,
706 const void* key) { 729 const void* key) {
730 if (IsInternalProperty(key))
731 return nullptr;
732
707 std::unique_ptr<WindowPortPropertyDataMus> data( 733 std::unique_ptr<WindowPortPropertyDataMus> data(
708 base::MakeUnique<WindowPortPropertyDataMus>()); 734 base::MakeUnique<WindowPortPropertyDataMus>());
709 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport( 735 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport(
710 window->GetWindow(), key, &data->transport_name, 736 window->GetWindow(), key, &data->transport_name,
711 &data->transport_value)) { 737 &data->transport_value)) {
712 return nullptr; 738 return nullptr;
713 } 739 }
714 return std::move(data); 740 return std::move(data);
715 } 741 }
716 742
717 void WindowTreeClient::OnWindowMusPropertyChanged( 743 void WindowTreeClient::OnWindowMusPropertyChanged(
718 WindowMus* window, 744 WindowMus* window,
719 const void* key, 745 const void* key,
720 std::unique_ptr<WindowPortPropertyData> data) { 746 std::unique_ptr<WindowPortPropertyData> data) {
747 if (HandleInternalPropertyChanged(window, key))
msw 2016/10/27 18:37:37 optional nit: combine with the !data early return
sky 2016/10/27 19:30:06 Done.
748 return;
749
721 if (!data) 750 if (!data)
722 return; 751 return;
752
723 WindowPortPropertyDataMus* data_mus = 753 WindowPortPropertyDataMus* data_mus =
724 static_cast<WindowPortPropertyDataMus*>(data.get()); 754 static_cast<WindowPortPropertyDataMus*>(data.get());
725 755
726 std::string transport_name; 756 std::string transport_name;
727 std::unique_ptr<std::vector<uint8_t>> transport_value; 757 std::unique_ptr<std::vector<uint8_t>> transport_value;
728 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport( 758 if (!delegate_->GetPropertyConverter()->ConvertPropertyForTransport(
729 window->GetWindow(), key, &transport_name, &transport_value)) { 759 window->GetWindow(), key, &transport_name, &transport_value)) {
730 return; 760 return;
731 } 761 }
732 DCHECK_EQ(transport_name, data_mus->transport_name); 762 DCHECK_EQ(transport_name, data_mus->transport_name);
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 base::MakeUnique<InFlightCaptureChange>(this, capture_window_)); 1681 base::MakeUnique<InFlightCaptureChange>(this, capture_window_));
1652 WindowMus* old_capture_window = capture_window_; 1682 WindowMus* old_capture_window = capture_window_;
1653 capture_window_ = gained_capture_mus; 1683 capture_window_ = gained_capture_mus;
1654 if (capture_window_) 1684 if (capture_window_)
1655 tree_->SetCapture(change_id, capture_window_->server_id()); 1685 tree_->SetCapture(change_id, capture_window_->server_id());
1656 else 1686 else
1657 tree_->ReleaseCapture(change_id, old_capture_window->server_id()); 1687 tree_->ReleaseCapture(change_id, old_capture_window->server_id());
1658 } 1688 }
1659 1689
1660 } // namespace aura 1690 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698