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_tree_client.h" | 5 #include "components/mus/public/cpp/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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 return; | 867 return; |
868 | 868 |
869 InFlightPropertyChange new_change(window, name, new_data); | 869 InFlightPropertyChange new_change(window, name, new_data); |
870 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 870 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
871 return; | 871 return; |
872 | 872 |
873 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); | 873 WindowPrivate(window).LocalSetSharedProperty(name, std::move(new_data)); |
874 } | 874 } |
875 | 875 |
876 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, | 876 void WindowTreeClient::OnWindowInputEvent(uint32_t event_id, |
877 Id window_id, | 877 Id window_id, |
878 mojom::EventPtr event, | 878 std::unique_ptr<ui::Event> event, |
879 uint32_t event_observer_id) { | 879 uint32_t event_observer_id) { |
880 std::unique_ptr<ui::Event> ui_event = event.To<std::unique_ptr<ui::Event>>(); | 880 DCHECK(event); |
881 Window* window = GetWindowByServerId(window_id); // May be null. | 881 Window* window = GetWindowByServerId(window_id); // May be null. |
882 | 882 |
883 // Non-zero event_observer_id means it matched an event observer on the | 883 // Non-zero event_observer_id means it matched an event observer on the |
884 // server. | 884 // server. |
885 if (event_observer_id != 0 && has_event_observer_ && | 885 if (event_observer_id != 0 && has_event_observer_ && |
886 event_observer_id == event_observer_id_) | 886 event_observer_id == event_observer_id_) |
887 delegate_->OnEventObserved(*ui_event, window); | 887 delegate_->OnEventObserved(*event.get(), window); |
888 | 888 |
889 if (!window || !window->input_event_handler_) { | 889 if (!window || !window->input_event_handler_) { |
890 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); | 890 tree_->OnWindowInputEventAck(event_id, mojom::EventResult::UNHANDLED); |
891 return; | 891 return; |
892 } | 892 } |
893 | 893 |
894 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( | 894 std::unique_ptr<base::Callback<void(mojom::EventResult)>> ack_callback( |
895 new base::Callback<void(mojom::EventResult)>( | 895 new base::Callback<void(mojom::EventResult)>( |
896 base::Bind(&mojom::WindowTree::OnWindowInputEventAck, | 896 base::Bind(&mojom::WindowTree::OnWindowInputEventAck, |
897 base::Unretained(tree_), event_id))); | 897 base::Unretained(tree_), event_id))); |
898 window->input_event_handler_->OnWindowInputEvent( | 898 |
899 window, *event.To<std::unique_ptr<ui::Event>>().get(), &ack_callback); | 899 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or |
| 900 // ui::TouchEvent once we have proper support for pointer events. |
| 901 if (event->IsMousePointerEvent()) { |
| 902 window->input_event_handler_->OnWindowInputEvent( |
| 903 window, ui::MouseEvent(*event->AsPointerEvent()), &ack_callback); |
| 904 } else if (event->IsTouchPointerEvent()) { |
| 905 window->input_event_handler_->OnWindowInputEvent( |
| 906 window, ui::TouchEvent(*event->AsPointerEvent()), &ack_callback); |
| 907 } else { |
| 908 window->input_event_handler_->OnWindowInputEvent(window, *event.get(), |
| 909 &ack_callback); |
| 910 } |
900 | 911 |
901 // The handler did not take ownership of the callback, so we send the ack, | 912 // The handler did not take ownership of the callback, so we send the ack, |
902 // marking the event as not consumed. | 913 // marking the event as not consumed. |
903 if (ack_callback) | 914 if (ack_callback) |
904 ack_callback->Run(mojom::EventResult::UNHANDLED); | 915 ack_callback->Run(mojom::EventResult::UNHANDLED); |
905 } | 916 } |
906 | 917 |
907 void WindowTreeClient::OnEventObserved(mojom::EventPtr event, | 918 void WindowTreeClient::OnEventObserved(std::unique_ptr<ui::Event> event, |
908 uint32_t event_observer_id) { | 919 uint32_t event_observer_id) { |
909 if (has_event_observer_ && event_observer_id == event_observer_id_) { | 920 DCHECK(event); |
910 std::unique_ptr<ui::Event> ui_event = | 921 if (has_event_observer_ && event_observer_id == event_observer_id_) |
911 event.To<std::unique_ptr<ui::Event>>(); | 922 delegate_->OnEventObserved(*event.get(), nullptr /* target */); |
912 delegate_->OnEventObserved(*ui_event, nullptr /* target */); | |
913 } | |
914 } | 923 } |
915 | 924 |
916 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { | 925 void WindowTreeClient::OnWindowFocused(Id focused_window_id) { |
917 Window* focused_window = GetWindowByServerId(focused_window_id); | 926 Window* focused_window = GetWindowByServerId(focused_window_id); |
918 InFlightFocusChange new_change(this, focused_window); | 927 InFlightFocusChange new_change(this, focused_window); |
919 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 928 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
920 return; | 929 return; |
921 | 930 |
922 LocalSetFocus(focused_window); | 931 LocalSetFocus(focused_window); |
923 } | 932 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 void WindowTreeClient::WmClientJankinessChanged(ClientSpecificId client_id, | 1041 void WindowTreeClient::WmClientJankinessChanged(ClientSpecificId client_id, |
1033 bool janky) { | 1042 bool janky) { |
1034 if (window_manager_delegate_) { | 1043 if (window_manager_delegate_) { |
1035 auto it = embedded_windows_.find(client_id); | 1044 auto it = embedded_windows_.find(client_id); |
1036 CHECK(it != embedded_windows_.end()); | 1045 CHECK(it != embedded_windows_.end()); |
1037 window_manager_delegate_->OnWmClientJankinessChanged( | 1046 window_manager_delegate_->OnWmClientJankinessChanged( |
1038 embedded_windows_[client_id], janky); | 1047 embedded_windows_[client_id], janky); |
1039 } | 1048 } |
1040 } | 1049 } |
1041 | 1050 |
1042 void WindowTreeClient::OnAccelerator(uint32_t id, mojom::EventPtr event) { | 1051 void WindowTreeClient::OnAccelerator(uint32_t id, |
1043 window_manager_delegate_->OnAccelerator( | 1052 std::unique_ptr<ui::Event> event) { |
1044 id, *event.To<std::unique_ptr<ui::Event>>().get()); | 1053 DCHECK(event); |
| 1054 window_manager_delegate_->OnAccelerator(id, *event.get()); |
1045 } | 1055 } |
1046 | 1056 |
1047 void WindowTreeClient::SetFrameDecorationValues( | 1057 void WindowTreeClient::SetFrameDecorationValues( |
1048 mojom::FrameDecorationValuesPtr values) { | 1058 mojom::FrameDecorationValuesPtr values) { |
1049 if (window_manager_internal_client_) { | 1059 if (window_manager_internal_client_) { |
1050 window_manager_internal_client_->WmSetFrameDecorationValues( | 1060 window_manager_internal_client_->WmSetFrameDecorationValues( |
1051 std::move(values)); | 1061 std::move(values)); |
1052 } | 1062 } |
1053 } | 1063 } |
1054 | 1064 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 Window* window, | 1103 Window* window, |
1094 const gfx::Vector2d& offset, | 1104 const gfx::Vector2d& offset, |
1095 const gfx::Insets& hit_area) { | 1105 const gfx::Insets& hit_area) { |
1096 if (window_manager_internal_client_) { | 1106 if (window_manager_internal_client_) { |
1097 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1107 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
1098 server_id(window), offset.x(), offset.y(), hit_area); | 1108 server_id(window), offset.x(), offset.y(), hit_area); |
1099 } | 1109 } |
1100 } | 1110 } |
1101 | 1111 |
1102 } // namespace mus | 1112 } // namespace mus |
OLD | NEW |