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

Side by Side Diff: ui/views/mus/native_widget_mus.cc

Issue 1991973003: mash: Preliminary support for widget hit test masks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months 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
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // static 492 // static
492 void NativeWidgetMus::NotifyFrameChanged( 493 void NativeWidgetMus::NotifyFrameChanged(
493 mus::WindowTreeConnection* connection) { 494 mus::WindowTreeConnection* connection) {
494 for (mus::Window* window : connection->GetRoots()) { 495 for (mus::Window* window : connection->GetRoots()) {
495 NativeWidgetMus* native_widget = 496 NativeWidgetMus* native_widget =
496 window->GetLocalProperty(kNativeWidgetMusKey); 497 window->GetLocalProperty(kNativeWidgetMusKey);
497 if (native_widget && native_widget->GetWidget()->non_client_view()) { 498 if (native_widget && native_widget->GetWidget()->non_client_view()) {
498 native_widget->GetWidget()->non_client_view()->Layout(); 499 native_widget->GetWidget()->non_client_view()->Layout();
499 native_widget->GetWidget()->non_client_view()->SchedulePaint(); 500 native_widget->GetWidget()->non_client_view()->SchedulePaint();
500 native_widget->UpdateClientArea(); 501 native_widget->UpdateClientArea();
502 native_widget->UpdateHitTestMask();
501 } 503 }
502 } 504 }
503 } 505 }
504 506
505 // static 507 // static
506 Widget* NativeWidgetMus::GetWidgetForWindow(mus::Window* window) { 508 Widget* NativeWidgetMus::GetWidgetForWindow(mus::Window* window) {
507 if (!window) 509 if (!window)
508 return nullptr; 510 return nullptr;
509 NativeWidgetMus* native_widget = 511 NativeWidgetMus* native_widget =
510 window->GetLocalProperty(kNativeWidgetMusKey); 512 window->GetLocalProperty(kNativeWidgetMusKey);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 676
675 native_widget_delegate_->OnNativeWidgetCreated(false); 677 native_widget_delegate_->OnNativeWidgetCreated(false);
676 } 678 }
677 679
678 void NativeWidgetMus::OnWidgetInitDone() { 680 void NativeWidgetMus::OnWidgetInitDone() {
679 // The client area is calculated from the NonClientView. During 681 // The client area is calculated from the NonClientView. During
680 // InitNativeWidget() the NonClientView has not been created. When this 682 // InitNativeWidget() the NonClientView has not been created. When this
681 // function is called the NonClientView has been created, so that we can 683 // function is called the NonClientView has been created, so that we can
682 // correctly calculate the client area and push it to the mus::Window. 684 // correctly calculate the client area and push it to the mus::Window.
683 UpdateClientArea(); 685 UpdateClientArea();
686 UpdateHitTestMask();
684 } 687 }
685 688
686 bool NativeWidgetMus::ShouldUseNativeFrame() const { 689 bool NativeWidgetMus::ShouldUseNativeFrame() const {
687 // NOTIMPLEMENTED(); 690 // NOTIMPLEMENTED();
688 return false; 691 return false;
689 } 692 }
690 693
691 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const { 694 bool NativeWidgetMus::ShouldWindowContentsBeTransparent() const {
692 // NOTIMPLEMENTED(); 695 // NOTIMPLEMENTED();
693 return true; 696 return true;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 // Assume that if the old bounds was completely empty a move happened. This 1165 // Assume that if the old bounds was completely empty a move happened. This
1163 // handles the case of a maximize animation acquiring the layer (acquiring a 1166 // handles the case of a maximize animation acquiring the layer (acquiring a
1164 // layer results in clearing the bounds). 1167 // layer results in clearing the bounds).
1165 if (old_bounds.origin() != new_bounds.origin() || 1168 if (old_bounds.origin() != new_bounds.origin() ||
1166 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { 1169 (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) {
1167 native_widget_delegate_->OnNativeWidgetMove(); 1170 native_widget_delegate_->OnNativeWidgetMove();
1168 } 1171 }
1169 if (old_bounds.size() != new_bounds.size()) { 1172 if (old_bounds.size() != new_bounds.size()) {
1170 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); 1173 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
1171 UpdateClientArea(); 1174 UpdateClientArea();
1175 UpdateHitTestMask();
1172 } 1176 }
1173 } 1177 }
1174 1178
1175 gfx::NativeCursor NativeWidgetMus::GetCursor(const gfx::Point& point) { 1179 gfx::NativeCursor NativeWidgetMus::GetCursor(const gfx::Point& point) {
1176 return gfx::NativeCursor(); 1180 return gfx::NativeCursor();
1177 } 1181 }
1178 1182
1179 int NativeWidgetMus::GetNonClientComponent(const gfx::Point& point) const { 1183 int NativeWidgetMus::GetNonClientComponent(const gfx::Point& point) const {
1180 return native_widget_delegate_->GetNonClientComponent(point); 1184 return native_widget_delegate_->GetNonClientComponent(point);
1181 } 1185 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 if (window->visible()) { 1311 if (window->visible()) {
1308 window_tree_host_->Show(); 1312 window_tree_host_->Show();
1309 GetNativeWindow()->Show(); 1313 GetNativeWindow()->Show();
1310 } else { 1314 } else {
1311 window_tree_host_->Hide(); 1315 window_tree_host_->Hide();
1312 GetNativeWindow()->Hide(); 1316 GetNativeWindow()->Hide();
1313 } 1317 }
1314 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1318 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
1315 } 1319 }
1316 1320
1321 void NativeWidgetMus::UpdateHitTestMask() {
1322 // The window manager (or other underlay window provider) is not allowed to
1323 // set a hit test mask, as that could interfere with a client app mask.
1324 if (surface_type_ == mus::mojom::SurfaceType::UNDERLAY)
1325 return;
1326
1327 if (!native_widget_delegate_->HasHitTestMask()) {
1328 window_->ClearHitTestMask();
1329 return;
1330 }
1331
1332 gfx::Path mask_path;
1333 native_widget_delegate_->GetHitTestMask(&mask_path);
1334 // TODO(jamescook): Use the full path for the mask.
1335 gfx::Rect mask_rect =
1336 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
1337 window_->SetHitTestMask(mask_rect);
1338 }
1339
1317 } // namespace views 1340 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.h ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698