| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 DCHECK(!window_); | 511 DCHECK(!window_); |
| 512 delete native_widget_delegate_; | 512 delete native_widget_delegate_; |
| 513 } else { | 513 } else { |
| 514 if (window_) | 514 if (window_) |
| 515 window_->set_input_event_handler(nullptr); | 515 window_->set_input_event_handler(nullptr); |
| 516 CloseNow(); | 516 CloseNow(); |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 // static | 520 // static |
| 521 void NativeWidgetMus::NotifyFrameChanged( | 521 void NativeWidgetMus::NotifyFrameChanged(mus::WindowTreeClient* client) { |
| 522 mus::WindowTreeConnection* connection) { | 522 for (mus::Window* window : client->GetRoots()) { |
| 523 for (mus::Window* window : connection->GetRoots()) { | |
| 524 NativeWidgetMus* native_widget = | 523 NativeWidgetMus* native_widget = |
| 525 window->GetLocalProperty(kNativeWidgetMusKey); | 524 window->GetLocalProperty(kNativeWidgetMusKey); |
| 526 if (native_widget && native_widget->GetWidget()->non_client_view()) { | 525 if (native_widget && native_widget->GetWidget()->non_client_view()) { |
| 527 native_widget->GetWidget()->non_client_view()->Layout(); | 526 native_widget->GetWidget()->non_client_view()->Layout(); |
| 528 native_widget->GetWidget()->non_client_view()->SchedulePaint(); | 527 native_widget->GetWidget()->non_client_view()->SchedulePaint(); |
| 529 native_widget->UpdateClientArea(); | 528 native_widget->UpdateClientArea(); |
| 530 native_widget->UpdateHitTestMask(); | 529 native_widget->UpdateHitTestMask(); |
| 531 } | 530 } |
| 532 } | 531 } |
| 533 } | 532 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 | 971 |
| 973 void NativeWidgetMus::Activate() { | 972 void NativeWidgetMus::Activate() { |
| 974 if (window_) | 973 if (window_) |
| 975 window_->SetFocus(); | 974 window_->SetFocus(); |
| 976 static_cast<aura::client::ActivationClient*>(focus_client_.get()) | 975 static_cast<aura::client::ActivationClient*>(focus_client_.get()) |
| 977 ->ActivateWindow(content_); | 976 ->ActivateWindow(content_); |
| 978 } | 977 } |
| 979 | 978 |
| 980 void NativeWidgetMus::Deactivate() { | 979 void NativeWidgetMus::Deactivate() { |
| 981 if (IsActive()) | 980 if (IsActive()) |
| 982 window_->connection()->ClearFocus(); | 981 window_->window_tree()->ClearFocus(); |
| 983 } | 982 } |
| 984 | 983 |
| 985 bool NativeWidgetMus::IsActive() const { | 984 bool NativeWidgetMus::IsActive() const { |
| 986 mus::Window* focused = | 985 mus::Window* focused = |
| 987 window_ ? window_->connection()->GetFocusedWindow() : nullptr; | 986 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; |
| 988 return focused && window_->Contains(focused); | 987 return focused && window_->Contains(focused); |
| 989 } | 988 } |
| 990 | 989 |
| 991 void NativeWidgetMus::SetAlwaysOnTop(bool always_on_top) { | 990 void NativeWidgetMus::SetAlwaysOnTop(bool always_on_top) { |
| 992 if (window_) { | 991 if (window_) { |
| 993 window_->SetSharedProperty<bool>( | 992 window_->SetSharedProperty<bool>( |
| 994 mus::mojom::WindowManager::kAlwaysOnTop_Property, always_on_top); | 993 mus::mojom::WindowManager::kAlwaysOnTop_Property, always_on_top); |
| 995 } | 994 } |
| 996 } | 995 } |
| 997 | 996 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1099 |
| 1101 bool NativeWidgetMus::IsMouseEventsEnabled() const { | 1100 bool NativeWidgetMus::IsMouseEventsEnabled() const { |
| 1102 // NOTIMPLEMENTED(); | 1101 // NOTIMPLEMENTED(); |
| 1103 return true; | 1102 return true; |
| 1104 } | 1103 } |
| 1105 | 1104 |
| 1106 void NativeWidgetMus::ClearNativeFocus() { | 1105 void NativeWidgetMus::ClearNativeFocus() { |
| 1107 if (!IsActive()) | 1106 if (!IsActive()) |
| 1108 return; | 1107 return; |
| 1109 mus::Window* focused = | 1108 mus::Window* focused = |
| 1110 window_ ? window_->connection()->GetFocusedWindow() : nullptr; | 1109 window_ ? window_->window_tree()->GetFocusedWindow() : nullptr; |
| 1111 if (focused && window_->Contains(focused) && focused != window_) | 1110 if (focused && window_->Contains(focused) && focused != window_) |
| 1112 window_->SetFocus(); | 1111 window_->SetFocus(); |
| 1113 // Move aura-focus back to |content_|, so that the Widget still receives | 1112 // Move aura-focus back to |content_|, so that the Widget still receives |
| 1114 // events correctly. | 1113 // events correctly. |
| 1115 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow( | 1114 aura::client::GetFocusClient(content_)->ResetFocusWithinActiveWindow( |
| 1116 content_); | 1115 content_); |
| 1117 } | 1116 } |
| 1118 | 1117 |
| 1119 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const { | 1118 gfx::Rect NativeWidgetMus::GetWorkAreaBoundsInScreen() const { |
| 1120 // NOTIMPLEMENTED(); | 1119 // NOTIMPLEMENTED(); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 | 1358 |
| 1360 gfx::Path mask_path; | 1359 gfx::Path mask_path; |
| 1361 native_widget_delegate_->GetHitTestMask(&mask_path); | 1360 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1362 // TODO(jamescook): Use the full path for the mask. | 1361 // TODO(jamescook): Use the full path for the mask. |
| 1363 gfx::Rect mask_rect = | 1362 gfx::Rect mask_rect = |
| 1364 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1363 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1365 window_->SetHitTestMask(mask_rect); | 1364 window_->SetHitTestMask(mask_rect); |
| 1366 } | 1365 } |
| 1367 | 1366 |
| 1368 } // namespace views | 1367 } // namespace views |
| OLD | NEW |