Chromium Code Reviews| 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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "ui/aura/client/default_capture_client.h" | 21 #include "ui/aura/client/default_capture_client.h" |
| 22 #include "ui/aura/client/window_tree_client.h" | 22 #include "ui/aura/client/window_tree_client.h" |
| 23 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 24 #include "ui/aura/layout_manager.h" | 24 #include "ui/aura/layout_manager.h" |
| 25 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
| 26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 27 #include "ui/aura/window_property.h" | 27 #include "ui/aura/window_property.h" |
| 28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 29 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 30 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 31 #include "ui/gfx/path.h" | |
| 31 #include "ui/native_theme/native_theme_aura.h" | 32 #include "ui/native_theme/native_theme_aura.h" |
| 32 #include "ui/platform_window/platform_window_delegate.h" | 33 #include "ui/platform_window/platform_window_delegate.h" |
| 33 #include "ui/views/mus/platform_window_mus.h" | 34 #include "ui/views/mus/platform_window_mus.h" |
| 34 #include "ui/views/mus/surface_context_factory.h" | 35 #include "ui/views/mus/surface_context_factory.h" |
| 35 #include "ui/views/mus/window_manager_constants_converters.h" | 36 #include "ui/views/mus/window_manager_constants_converters.h" |
| 36 #include "ui/views/mus/window_manager_frame_values.h" | 37 #include "ui/views/mus/window_manager_frame_values.h" |
| 37 #include "ui/views/mus/window_tree_host_mus.h" | 38 #include "ui/views/mus/window_tree_host_mus.h" |
| 38 #include "ui/views/widget/native_widget_aura.h" | 39 #include "ui/views/widget/native_widget_aura.h" |
| 39 #include "ui/views/widget/widget_delegate.h" | 40 #include "ui/views/widget/widget_delegate.h" |
| 40 #include "ui/views/window/custom_frame_view.h" | 41 #include "ui/views/window/custom_frame_view.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 // static | 487 // static |
| 487 void NativeWidgetMus::NotifyFrameChanged( | 488 void NativeWidgetMus::NotifyFrameChanged( |
| 488 mus::WindowTreeConnection* connection) { | 489 mus::WindowTreeConnection* connection) { |
| 489 for (mus::Window* window : connection->GetRoots()) { | 490 for (mus::Window* window : connection->GetRoots()) { |
| 490 NativeWidgetMus* native_widget = | 491 NativeWidgetMus* native_widget = |
| 491 window->GetLocalProperty(kNativeWidgetMusKey); | 492 window->GetLocalProperty(kNativeWidgetMusKey); |
| 492 if (native_widget && native_widget->GetWidget()->non_client_view()) { | 493 if (native_widget && native_widget->GetWidget()->non_client_view()) { |
| 493 native_widget->GetWidget()->non_client_view()->Layout(); | 494 native_widget->GetWidget()->non_client_view()->Layout(); |
| 494 native_widget->GetWidget()->non_client_view()->SchedulePaint(); | 495 native_widget->GetWidget()->non_client_view()->SchedulePaint(); |
| 495 native_widget->UpdateClientArea(); | 496 native_widget->UpdateClientArea(); |
| 497 native_widget->UpdateHitTestMask(); | |
| 496 } | 498 } |
| 497 } | 499 } |
| 498 } | 500 } |
| 499 | 501 |
| 500 // static | 502 // static |
| 501 Widget* NativeWidgetMus::GetWidgetForWindow(mus::Window* window) { | 503 Widget* NativeWidgetMus::GetWidgetForWindow(mus::Window* window) { |
| 502 if (!window) | 504 if (!window) |
| 503 return nullptr; | 505 return nullptr; |
| 504 NativeWidgetMus* native_widget = | 506 NativeWidgetMus* native_widget = |
| 505 window->GetLocalProperty(kNativeWidgetMusKey); | 507 window->GetLocalProperty(kNativeWidgetMusKey); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 | 669 |
| 668 native_widget_delegate_->OnNativeWidgetCreated(false); | 670 native_widget_delegate_->OnNativeWidgetCreated(false); |
| 669 } | 671 } |
| 670 | 672 |
| 671 void NativeWidgetMus::OnWidgetInitDone() { | 673 void NativeWidgetMus::OnWidgetInitDone() { |
| 672 // The client area is calculated from the NonClientView. During | 674 // The client area is calculated from the NonClientView. During |
| 673 // InitNativeWidget() the NonClientView has not been created. When this | 675 // InitNativeWidget() the NonClientView has not been created. When this |
| 674 // function is called the NonClientView has been created, so that we can | 676 // function is called the NonClientView has been created, so that we can |
| 675 // correctly calculate the client area and push it to the mus::Window. | 677 // correctly calculate the client area and push it to the mus::Window. |
| 676 UpdateClientArea(); | 678 UpdateClientArea(); |
| 679 UpdateHitTestMask(); | |
| 677 } | 680 } |
| 678 | 681 |
| 679 bool NativeWidgetMus::ShouldUseNativeFrame() const { | 682 bool NativeWidgetMus::ShouldUseNativeFrame() const { |
| 680 // NOTIMPLEMENTED(); | 683 // NOTIMPLEMENTED(); |
| 681 return false; | 684 return false; |
| 682 } | 685 } |
| 683 | 686 |
| 684 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const { | 687 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const { |
| 685 // NOTIMPLEMENTED(); | 688 // NOTIMPLEMENTED(); |
| 686 return true; | 689 return true; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 // Assume that if the old bounds was completely empty a move happened. This | 1152 // Assume that if the old bounds was completely empty a move happened. This |
| 1150 // handles the case of a maximize animation acquiring the layer (acquiring a | 1153 // handles the case of a maximize animation acquiring the layer (acquiring a |
| 1151 // layer results in clearing the bounds). | 1154 // layer results in clearing the bounds). |
| 1152 if (old_bounds.origin() != new_bounds.origin() || | 1155 if (old_bounds.origin() != new_bounds.origin() || |
| 1153 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { | 1156 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { |
| 1154 native_widget_delegate_->OnNativeWidgetMove(); | 1157 native_widget_delegate_->OnNativeWidgetMove(); |
| 1155 } | 1158 } |
| 1156 if (old_bounds.size() != new_bounds.size()) { | 1159 if (old_bounds.size() != new_bounds.size()) { |
| 1157 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 1160 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
| 1158 UpdateClientArea(); | 1161 UpdateClientArea(); |
| 1162 UpdateHitTestMask(); | |
| 1159 } | 1163 } |
| 1160 } | 1164 } |
| 1161 | 1165 |
| 1162 gfx::NativeCursor NativeWidgetMus::GetCursor(const gfx::Point& point) { | 1166 gfx::NativeCursor NativeWidgetMus::GetCursor(const gfx::Point& point) { |
| 1163 return gfx::NativeCursor(); | 1167 return gfx::NativeCursor(); |
| 1164 } | 1168 } |
| 1165 | 1169 |
| 1166 int NativeWidgetMus::GetNonClientComponent(const gfx::Point& point) const { | 1170 int NativeWidgetMus::GetNonClientComponent(const gfx::Point& point) const { |
| 1167 return native_widget_delegate_->GetNonClientComponent(point); | 1171 return native_widget_delegate_->GetNonClientComponent(point); |
| 1168 } | 1172 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1294 if (window->visible()) { | 1298 if (window->visible()) { |
| 1295 window_tree_host_->Show(); | 1299 window_tree_host_->Show(); |
| 1296 GetNativeWindow()->Show(); | 1300 GetNativeWindow()->Show(); |
| 1297 } else { | 1301 } else { |
| 1298 window_tree_host_->Hide(); | 1302 window_tree_host_->Hide(); |
| 1299 GetNativeWindow()->Hide(); | 1303 GetNativeWindow()->Hide(); |
| 1300 } | 1304 } |
| 1301 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); | 1305 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); |
| 1302 } | 1306 } |
| 1303 | 1307 |
| 1308 void NativeWidgetMus::UpdateHitTestMask() { | |
| 1309 if (!native_widget_delegate_->HasHitTestMask()) | |
|
sky
2016/05/19 18:13:17
This case should set the hit test mask to null.
James Cook
2016/05/19 21:47:46
Done.
| |
| 1310 return; | |
| 1311 | |
| 1312 gfx::Path mask_path; | |
| 1313 native_widget_delegate_->GetHitTestMask(&mask_path); | |
| 1314 // TODO(jamescook): Use the full path for the mask. | |
| 1315 gfx::Rect mask_rect = | |
| 1316 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | |
| 1317 window_->SetHitTestMask(mask_rect); | |
| 1318 } | |
| 1319 | |
| 1304 } // namespace views | 1320 } // namespace views |
| OLD | NEW |