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/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "components/mus/public/cpp/property_type_converters.h" | 11 #include "components/mus/public/cpp/property_type_converters.h" |
12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
13 #include "components/mus/public/cpp/window_observer.h" | 13 #include "components/mus/public/cpp/window_observer.h" |
14 #include "components/mus/public/cpp/window_property.h" | 14 #include "components/mus/public/cpp/window_property.h" |
15 #include "components/mus/public/cpp/window_tree_connection.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
16 #include "components/mus/public/interfaces/cursor.mojom.h" | 16 #include "components/mus/public/interfaces/cursor.mojom.h" |
17 #include "components/mus/public/interfaces/window_manager.mojom.h" | 17 #include "components/mus/public/interfaces/window_manager.mojom.h" |
18 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" |
19 #include "components/mus/public/interfaces/window_tree.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree.mojom.h" |
20 #include "ui/aura/client/default_capture_client.h" | 20 #include "ui/aura/client/default_capture_client.h" |
21 #include "ui/aura/client/window_tree_client.h" | 21 #include "ui/aura/client/window_tree_client.h" |
22 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
23 #include "ui/aura/layout_manager.h" | 23 #include "ui/aura/layout_manager.h" |
24 #include "ui/aura/mus/mus_util.h" | 24 #include "ui/aura/mus/mus_util.h" |
25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 DCHECK(!window_); | 515 DCHECK(!window_); |
516 delete native_widget_delegate_; | 516 delete native_widget_delegate_; |
517 } else { | 517 } else { |
518 if (window_) | 518 if (window_) |
519 window_->set_input_event_handler(nullptr); | 519 window_->set_input_event_handler(nullptr); |
520 CloseNow(); | 520 CloseNow(); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 // static | 524 // static |
525 void NativeWidgetMus::NotifyFrameChanged( | 525 void NativeWidgetMus::NotifyFrameChanged(mus::WindowTreeClient* client) { |
526 mus::WindowTreeConnection* connection) { | 526 for (mus::Window* window : client->GetRoots()) { |
527 for (mus::Window* window : connection->GetRoots()) { | |
528 NativeWidgetMus* native_widget = | 527 NativeWidgetMus* native_widget = |
529 window->GetLocalProperty(kNativeWidgetMusKey); | 528 window->GetLocalProperty(kNativeWidgetMusKey); |
530 if (native_widget && native_widget->GetWidget()->non_client_view()) { | 529 if (native_widget && native_widget->GetWidget()->non_client_view()) { |
531 native_widget->GetWidget()->non_client_view()->Layout(); | 530 native_widget->GetWidget()->non_client_view()->Layout(); |
532 native_widget->GetWidget()->non_client_view()->SchedulePaint(); | 531 native_widget->GetWidget()->non_client_view()->SchedulePaint(); |
533 native_widget->UpdateClientArea(); | 532 native_widget->UpdateClientArea(); |
534 native_widget->UpdateHitTestMask(); | 533 native_widget->UpdateHitTestMask(); |
535 } | 534 } |
536 } | 535 } |
537 } | 536 } |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 972 |
974 void NativeWidgetMus::Activate() { | 973 void NativeWidgetMus::Activate() { |
975 if (window_) | 974 if (window_) |
976 window_->SetFocus(); | 975 window_->SetFocus(); |
977 static_cast<aura::client::ActivationClient*>(focus_client_.get()) | 976 static_cast<aura::client::ActivationClient*>(focus_client_.get()) |
978 ->ActivateWindow(content_); | 977 ->ActivateWindow(content_); |
979 } | 978 } |
980 | 979 |
981 void NativeWidgetMus::Deactivate() { | 980 void NativeWidgetMus::Deactivate() { |
982 if (IsActive()) | 981 if (IsActive()) |
983 window_->connection()->ClearFocus(); | 982 window_->window_tree()->ClearFocus(); |
984 } | 983 } |
985 | 984 |
986 bool NativeWidgetMus::IsActive() const { | 985 bool NativeWidgetMus::IsActive() const { |
987 mus::Window* focused = | 986 mus::Window* focused = |
988 window_ ? window_->connection()->GetFocusedWindow() : nullptr; | 987 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; |
989 return focused && window_->Contains(focused); | 988 return focused && window_->Contains(focused); |
990 } | 989 } |
991 | 990 |
992 void NativeWidgetMus::SetAlwaysOnTop(bool always_on_top) { | 991 void NativeWidgetMus::SetAlwaysOnTop(bool always_on_top) { |
993 if (window_) { | 992 if (window_) { |
994 window_->SetSharedProperty<bool>( | 993 window_->SetSharedProperty<bool>( |
995 mus::mojom::WindowManager::kAlwaysOnTop_Property, always_on_top); | 994 mus::mojom::WindowManager::kAlwaysOnTop_Property, always_on_top); |
996 } | 995 } |
997 } | 996 } |
998 | 997 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1100 |
1102 bool NativeWidgetMus::IsMouseEventsEnabled() const { | 1101 bool NativeWidgetMus::IsMouseEventsEnabled() const { |
1103 // NOTIMPLEMENTED(); | 1102 // NOTIMPLEMENTED(); |
1104 return true; | 1103 return true; |
1105 } | 1104 } |
1106 | 1105 |
1107 void NativeWidgetMus::ClearNativeFocus() { | 1106 void NativeWidgetMus::ClearNativeFocus() { |
1108 if (!IsActive()) | 1107 if (!IsActive()) |
1109 return; | 1108 return; |
1110 mus::Window* focused = | 1109 mus::Window* focused = |
1111 window_ ? window_->connection()->GetFocusedWindow() : nullptr; | 1110 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; |
1112 if (focused && window_->Contains(focused) && focused != window_) | 1111 if (focused && window_->Contains(focused) && focused != window_) |
1113 window_->SetFocus(); | 1112 window_->SetFocus(); |
1114 // Move aura-focus back to |content_|, so that the Widget still receives | 1113 // Move aura-focus back to |content_|, so that the Widget still receives |
1115 // events correctly. | 1114 // events correctly. |
1116 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow( | 1115 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow( |
1117 content_); | 1116 content_); |
1118 } | 1117 } |
1119 | 1118 |
1120 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const { | 1119 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const { |
1121 // NOTIMPLEMENTED(); | 1120 // NOTIMPLEMENTED(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 | 1359 |
1361 gfx::Path mask_path; | 1360 gfx::Path mask_path; |
1362 native_widget_delegate_->GetHitTestMask(&mask_path); | 1361 native_widget_delegate_->GetHitTestMask(&mask_path); |
1363 // TODO(jamescook): Use the full path for the mask. | 1362 // TODO(jamescook): Use the full path for the mask. |
1364 gfx::Rect mask_rect = | 1363 gfx::Rect mask_rect = |
1365 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1364 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1366 window_->SetHitTestMask(mask_rect); | 1365 window_->SetHitTestMask(mask_rect); |
1367 } | 1366 } |
1368 | 1367 |
1369 } // namespace views | 1368 } // namespace views |
OLD | NEW |