diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 19:33:13 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 19:33:13 +0000 |
commit | 71c6ea9a117a85f224f0e08c391ea38def8f6a1b (patch) | |
tree | fde8143e413de17e0f2ffb7180d575859ae97da0 | |
parent | 8a3cb872a77bfb14176fdf100e39ed3588d0d8bb (diff) | |
download | chromium_src-71c6ea9a117a85f224f0e08c391ea38def8f6a1b.zip chromium_src-71c6ea9a117a85f224f0e08c391ea38def8f6a1b.tar.gz chromium_src-71c6ea9a117a85f224f0e08c391ea38def8f6a1b.tar.bz2 |
Support the various flavors of window-shape setting.
. expose a win-specific function to convert a SkPath->HRGN
. implement the various functions to use it:
- NativeWidgetPrivate::SetShape() is called for windows that want to programmatically set a shape.
- HWNDMessageHandler::ResetWindowRegion asks the non-client frameview for its shape
- DNWA::Has/GetHitTestMask implements this for event dispatch.
http://crbug.com/146077
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/10917299
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157167 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/gfx/path_win.cc | 18 | ||||
-rw-r--r-- | ui/gfx/path_win.h | 22 | ||||
-rw-r--r-- | ui/ui.gyp | 2 | ||||
-rw-r--r-- | ui/views/widget/desktop_native_widget_aura.cc | 4 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host.h | 3 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_linux.cc | 5 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_linux.h | 1 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_win.cc | 14 | ||||
-rw-r--r-- | ui/views/widget/desktop_root_window_host_win.h | 1 | ||||
-rw-r--r-- | ui/views/win/hwnd_message_handler.cc | 10 |
10 files changed, 67 insertions, 13 deletions
diff --git a/ui/gfx/path_win.cc b/ui/gfx/path_win.cc index e011f6b..35b98d8 100644 --- a/ui/gfx/path_win.cc +++ b/ui/gfx/path_win.cc @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/gfx/path.h" +#include "ui/gfx/path_win.h" #include "base/memory/scoped_ptr.h" +#include "ui/gfx/path.h" namespace gfx { -HRGN Path::CreateNativeRegion() const { - int point_count = getPoints(NULL, 0); +HRGN CreateHRGNFromSkPath(const SkPath& path) { + int point_count = path.getPoints(NULL, 0); scoped_array<SkPoint> points(new SkPoint[point_count]); - getPoints(points.get(), point_count); + path.getPoints(points.get(), point_count); scoped_array<POINT> windows_points(new POINT[point_count]); for (int i = 0; i < point_count; ++i) { windows_points[i].x = SkScalarRound(points[i].fX); @@ -21,6 +22,13 @@ HRGN Path::CreateNativeRegion() const { return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); } +// See path_aura.cc for Aura definition of these methods: +#if !defined(USE_AURA) + +NativeRegion Path::CreateNativeRegion() const { + return CreateHRGNFromSkPath(*this); +} + // static NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) { HRGN dest = CreateRectRgn(0, 0, 1, 1); @@ -42,4 +50,6 @@ NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) { return dest; } +#endif + } // namespace gfx diff --git a/ui/gfx/path_win.h b/ui/gfx/path_win.h new file mode 100644 index 0000000..6df025b --- /dev/null +++ b/ui/gfx/path_win.h @@ -0,0 +1,22 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_GFX_PATH_WIN_H_ +#define UI_GFX_PATH_WIN_H_ + +#include <windows.h> + +#include "ui/base/ui_export.h" + +class SkPath; + +namespace gfx { + +// Creates a new HRGN given |path|. The caller is responsible for destroying +// the returned region. +UI_EXPORT HRGN CreateHRGNFromSkPath(const SkPath& path); + +} // namespace gfx + +#endif // UI_GFX_PATH_WIN_H_ @@ -452,6 +452,7 @@ 'gfx/path_aura.cc', 'gfx/path_gtk.cc', 'gfx/path_win.cc', + 'gfx/path_win.h', 'gfx/platform_font.h', 'gfx/platform_font_android.cc', 'gfx/platform_font_ios.h', @@ -570,7 +571,6 @@ ['exclude', 'base/dragdrop/os_exchange_data_provider_win.h'], ['exclude', 'base/native_theme/native_theme_win.cc'], ['exclude', 'base/native_theme/native_theme_win.h'], - ['exclude', 'gfx/path_win.cc'], ], }], ['use_aura==0 and toolkit_views==0', { diff --git a/ui/views/widget/desktop_native_widget_aura.cc b/ui/views/widget/desktop_native_widget_aura.cc index 70f76c4..a19611f 100644 --- a/ui/views/widget/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_native_widget_aura.cc @@ -198,6 +198,7 @@ void DesktopNativeWidgetAura::StackBelow(gfx::NativeView native_view) { } void DesktopNativeWidgetAura::SetShape(gfx::NativeRegion shape) { + desktop_root_window_host_->SetShape(shape); } void DesktopNativeWidgetAura::Close() { @@ -386,10 +387,11 @@ void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { } bool DesktopNativeWidgetAura::HasHitTestMask() const { - return false; + return native_widget_delegate_->HasHitTestMask(); } void DesktopNativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { + native_widget_delegate_->GetHitTestMask(mask); } scoped_refptr<ui::Texture> DesktopNativeWidgetAura::CopyTexture() { diff --git a/ui/views/widget/desktop_root_window_host.h b/ui/views/widget/desktop_root_window_host.h index 49f1165..645ec1d 100644 --- a/ui/views/widget/desktop_root_window_host.h +++ b/ui/views/widget/desktop_root_window_host.h @@ -51,6 +51,9 @@ class DesktopRootWindowHost { virtual gfx::Rect GetWindowBoundsInScreen() const = 0; virtual gfx::Rect GetClientAreaBoundsInScreen() const = 0; virtual gfx::Rect GetRestoredBounds() const = 0; + + virtual void SetShape(gfx::NativeRegion native_region) = 0; + virtual bool ShouldUseNativeFrame() = 0; virtual void Activate() = 0; diff --git a/ui/views/widget/desktop_root_window_host_linux.cc b/ui/views/widget/desktop_root_window_host_linux.cc index 8a9a9e1..c2f2865 100644 --- a/ui/views/widget/desktop_root_window_host_linux.cc +++ b/ui/views/widget/desktop_root_window_host_linux.cc @@ -95,6 +95,11 @@ gfx::Rect DesktopRootWindowHostLinux::GetRestoredBounds() const { return gfx::Rect(); } +void DesktopRootWindowHostLinux::SetShape(gfx::NativeRegion native_region) { + // TODO(erg): + NOTIMPLEMENTED(); +} + bool DesktopRootWindowHostLinux::ShouldUseNativeFrame() { return false; } diff --git a/ui/views/widget/desktop_root_window_host_linux.h b/ui/views/widget/desktop_root_window_host_linux.h index 626212f..8a5de34 100644 --- a/ui/views/widget/desktop_root_window_host_linux.h +++ b/ui/views/widget/desktop_root_window_host_linux.h @@ -34,6 +34,7 @@ class DesktopRootWindowHostLinux : public DesktopRootWindowHost { virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; + virtual void SetShape(gfx::NativeRegion native_region) OVERRIDE; virtual bool ShouldUseNativeFrame() OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; diff --git a/ui/views/widget/desktop_root_window_host_win.cc b/ui/views/widget/desktop_root_window_host_win.cc index 4bf4539..623ccdf 100644 --- a/ui/views/widget/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_root_window_host_win.cc @@ -4,12 +4,16 @@ #include "ui/views/widget/desktop_root_window_host_win.h" +#include "third_party/skia/include/core/SkPath.h" +#include "third_party/skia/include/core/SkRegion.h" #include "ui/aura/desktop/desktop_activation_client.h" #include "ui/aura/desktop/desktop_dispatcher_client.h" #include "ui/aura/focus_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/shared/compound_event_filter.h" #include "ui/base/win/shell.h" +#include "ui/gfx/native_widget_types.h" +#include "ui/gfx/path_win.h" #include "ui/views/ime/input_method_win.h" #include "ui/views/widget/desktop_capture_client.h" #include "ui/views/win/hwnd_message_handler.h" @@ -125,6 +129,12 @@ gfx::Rect DesktopRootWindowHostWin::GetRestoredBounds() const { return message_handler_->GetRestoredBounds(); } +void DesktopRootWindowHostWin::SetShape(gfx::NativeRegion native_region) { + SkPath path; + native_region->getBoundaryPath(&path); + message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path)); +} + bool DesktopRootWindowHostWin::ShouldUseNativeFrame() { return false; // TODO(scottmg): Should be: @@ -337,6 +347,10 @@ int DesktopRootWindowHostWin::GetNonClientComponent( void DesktopRootWindowHostWin::GetWindowMask(const gfx::Size& size, gfx::Path* path) { + views::NonClientView* ncv = + native_widget_delegate_->AsWidget()->non_client_view(); + if (ncv) + ncv->GetWindowMask(size, path); } bool DesktopRootWindowHostWin::GetClientAreaInsets(gfx::Insets* insets) const { diff --git a/ui/views/widget/desktop_root_window_host_win.h b/ui/views/widget/desktop_root_window_host_win.h index 6ea0207..574e842 100644 --- a/ui/views/widget/desktop_root_window_host_win.h +++ b/ui/views/widget/desktop_root_window_host_win.h @@ -47,6 +47,7 @@ class DesktopRootWindowHostWin : public DesktopRootWindowHost, virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; + virtual void SetShape(gfx::NativeRegion native_region) OVERRIDE; virtual bool ShouldUseNativeFrame() OVERRIDE; virtual void Activate() OVERRIDE; virtual void Deactivate() OVERRIDE; diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc index 8581fbe..98a69e8 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc @@ -22,6 +22,7 @@ #include "ui/gfx/icon_util.h" #include "ui/gfx/insets.h" #include "ui/gfx/path.h" +#include "ui/gfx/path_win.h" #include "ui/gfx/screen.h" #include "ui/views/views_delegate.h" #include "ui/views/widget/monitor_win.h" @@ -1129,13 +1130,8 @@ void HWNDMessageHandler::ResetWindowRegion(bool force) { } else { gfx::Path window_mask; delegate_->GetWindowMask( - gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); - // TODO(beng): resolve wrt aura. -#if defined(USE_AURA) - new_region = NULL; -#else - new_region = window_mask.CreateNativeRegion(); -#endif + gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); + new_region = gfx::CreateHRGNFromSkPath(window_mask); } if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { |