From 05ae3cb514d685126d57f689e41d318ed3673b02 Mon Sep 17 00:00:00 2001 From: "wez@chromium.org" Date: Wed, 6 Nov 2013 21:45:34 +0000 Subject: Plumb native AppWindow input region through to window shape under Aura. This CL also fixes gfk::NativeRegion leaks in DesktopRootWindowHost for Windows & X11. BUG=310932 Review URL: https://codereview.chromium.org/54983005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233382 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/widget/desktop_aura/desktop_root_window_host.h | 2 ++ .../widget/desktop_aura/desktop_root_window_host_win.cc | 12 +++++++++--- .../widget/desktop_aura/desktop_root_window_host_x11.cc | 17 ++++++++++++----- ui/views/widget/widget.h | 3 ++- 4 files changed, 25 insertions(+), 9 deletions(-) (limited to 'ui') diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host.h b/ui/views/widget/desktop_aura/desktop_root_window_host.h index ad904fa..77c6150 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host.h +++ b/ui/views/widget/desktop_aura/desktop_root_window_host.h @@ -93,6 +93,8 @@ class VIEWS_EXPORT DesktopRootWindowHost { virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0; + // Sets the shape of the root window. If |native_region| is NULL then the + // window reverts to rectangular. Takes ownership of |native_region|. virtual void SetShape(gfx::NativeRegion native_region) = 0; virtual void Activate() = 0; diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 1f85742..2ba7af6 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -236,9 +236,15 @@ gfx::Rect DesktopRootWindowHostWin::GetWorkAreaBoundsInScreen() const { } void DesktopRootWindowHostWin::SetShape(gfx::NativeRegion native_region) { - SkPath path; - native_region->getBoundaryPath(&path); - message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path)); + if (native_region) { + SkPath path; + native_region->getBoundaryPath(&path); + message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path)); + } else { + message_handler_->SetRegion(NULL); + } + + delete native_region; } void DesktopRootWindowHostWin::Activate() { diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 5907f5e..757b509 100644 --- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -433,11 +433,18 @@ gfx::Rect DesktopRootWindowHostX11::GetWorkAreaBoundsInScreen() const { } void DesktopRootWindowHostX11::SetShape(gfx::NativeRegion native_region) { - SkPath path; - native_region->getBoundaryPath(&path); - Region region = gfx::CreateRegionFromSkPath(path); - XShapeCombineRegion(xdisplay_, xwindow_, ShapeBounding, 0, 0, region, false); - XDestroyRegion(region); + if (native_region) { + SkPath path; + native_region->getBoundaryPath(&path); + Region region = gfx::CreateRegionFromSkPath(path); + XShapeCombineRegion( + xdisplay_, xwindow_, ShapeBounding, 0, 0, region, false); + XDestroyRegion(region); + } else { + ResetWindowRegion(); + } + + delete native_region; } void DesktopRootWindowHostX11::Activate() { diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 3ff89e4..894ec23 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -419,7 +419,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // Places the widget below the specified NativeView. void StackBelow(gfx::NativeView native_view); - // Sets a shape on the widget. This takes ownership of shape. + // Sets a shape on the widget. Passing a NULL |shape| reverts the widget to + // be rectangular. Takes ownership of |shape|. void SetShape(gfx::NativeRegion shape); // Hides the widget then closes it after a return to the message loop. -- cgit v1.1