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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus.cc
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc
index 46a3ede494ce19c303e9671f82462405f5170f7b..81a5b3e4ca4e1f86010081e8adf1d791d126056c 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -28,6 +28,7 @@
#include "ui/base/hit_test.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/path.h"
#include "ui/native_theme/native_theme_aura.h"
#include "ui/platform_window/platform_window_delegate.h"
#include "ui/views/mus/platform_window_mus.h"
@@ -498,6 +499,7 @@ void NativeWidgetMus::NotifyFrameChanged(
native_widget->GetWidget()->non_client_view()->Layout();
native_widget->GetWidget()->non_client_view()->SchedulePaint();
native_widget->UpdateClientArea();
+ native_widget->UpdateHitTestMask();
}
}
}
@@ -681,6 +683,7 @@ void NativeWidgetMus::OnWidgetInitDone() {
// function is called the NonClientView has been created, so that we can
// correctly calculate the client area and push it to the mus::Window.
UpdateClientArea();
+ UpdateHitTestMask();
}
bool NativeWidgetMus::ShouldUseNativeFrame() const {
@@ -1169,6 +1172,7 @@ void NativeWidgetMus::OnBoundsChanged(const gfx::Rect& old_bounds,
if (old_bounds.size() != new_bounds.size()) {
native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
UpdateClientArea();
+ UpdateHitTestMask();
}
}
@@ -1314,4 +1318,23 @@ void NativeWidgetMus::OnMusWindowVisibilityChanged(mus::Window* window) {
native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
}
+void NativeWidgetMus::UpdateHitTestMask() {
+ // The window manager (or other underlay window provider) is not allowed to
+ // set a hit test mask, as that could interfere with a client app mask.
+ if (surface_type_ == mus::mojom::SurfaceType::UNDERLAY)
+ return;
+
+ if (!native_widget_delegate_->HasHitTestMask()) {
+ window_->ClearHitTestMask();
+ return;
+ }
+
+ gfx::Path mask_path;
+ native_widget_delegate_->GetHitTestMask(&mask_path);
+ // TODO(jamescook): Use the full path for the mask.
+ gfx::Rect mask_rect =
+ gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds()));
+ window_->SetHitTestMask(mask_rect);
+}
+
} // namespace views
« 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