summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramineer@chromium.org <amineer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 21:24:00 +0000
committeramineer@chromium.org <amineer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-23 21:24:00 +0000
commite95d17c08a2ebd04d6348abd33147d48e4b2a36f (patch)
tree82d9deca307150499ae45f7fc576129e9d89f1cd
parent9cdf03c946d934f12070c4272c87f902ae844d86 (diff)
downloadchromium_src-e95d17c08a2ebd04d6348abd33147d48e4b2a36f.zip
chromium_src-e95d17c08a2ebd04d6348abd33147d48e4b2a36f.tar.gz
chromium_src-e95d17c08a2ebd04d6348abd33147d48e4b2a36f.tar.bz2
Merge 284026 "Add app.window.alphaEnabled() and onAlphaEnabledCh..."
> Add app.window.alphaEnabled() and onAlphaEnabledChanged. > > This allows an app to determine whether a window created with > "transparent_background" will work as expected. > > This also allows the app to detect when "transparent_background" might > stop working, e.g. when Windows changes from Aero to Classic. > > This also fixes the bug where "transparent_background" windows > created in Classic render as black rectangles. > > BUG=260810 > > Review URL: https://codereview.chromium.org/375183002 TBR=jackhou@chromium.org Review URL: https://codereview.chromium.org/412033002 git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@285044 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--apps/app_window.cc8
-rw-r--r--apps/app_window.h8
-rw-r--r--apps/ui/native_app_window.h4
-rw-r--r--apps/ui/views/native_app_window_views.cc13
-rw-r--r--apps/ui/views/native_app_window_views.h5
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h1
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm4
-rw-r--r--chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc1
-rw-r--r--chrome/common/extensions/api/app_current_window_internal.idl1
-rw-r--r--chrome/common/extensions/api/app_window.idl7
-rw-r--r--chrome/renderer/resources/extensions/app_window_custom_bindings.js9
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.cc5
-rw-r--r--ui/views/widget/desktop_aura/desktop_native_widget_aura.h1
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host.h3
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc6
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_win.h1
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc4
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h1
-rw-r--r--ui/views/widget/native_widget_aura.cc4
-rw-r--r--ui/views/widget/native_widget_aura.h1
-rw-r--r--ui/views/widget/native_widget_mac.h1
-rw-r--r--ui/views/widget/native_widget_mac.mm4
-rw-r--r--ui/views/widget/native_widget_private.h1
-rw-r--r--ui/views/widget/widget.cc4
-rw-r--r--ui/views/widget/widget.h6
-rw-r--r--ui/views/widget/widget_unittest.cc1
26 files changed, 97 insertions, 7 deletions
diff --git a/apps/app_window.cc b/apps/app_window.cc
index 814d2e0..427cdc6 100644
--- a/apps/app_window.cc
+++ b/apps/app_window.cc
@@ -245,7 +245,8 @@ AppWindow::AppWindow(BrowserContext* context,
has_been_shown_(false),
can_send_events_(false),
is_hidden_(false),
- cached_always_on_top_(false) {
+ cached_always_on_top_(false),
+ requested_transparent_background_(false) {
extensions::ExtensionsBrowserClient* client =
extensions::ExtensionsBrowserClient::Get();
CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
@@ -284,6 +285,8 @@ void AppWindow::Init(const GURL& url,
if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
new_params.always_on_top = false;
+ requested_transparent_background_ = new_params.transparent_background;
+
native_app_window_.reset(delegate_->CreateNativeAppWindow(this, new_params));
// Prevent the browser process from shutting down while this window exists.
@@ -751,6 +754,9 @@ void AppWindow::GetSerializedState(base::DictionaryValue* properties) const {
properties->SetBoolean("maximized", native_app_window_->IsMaximized());
properties->SetBoolean("alwaysOnTop", IsAlwaysOnTop());
properties->SetBoolean("hasFrameColor", native_app_window_->HasFrameColor());
+ properties->SetBoolean("alphaEnabled",
+ requested_transparent_background_ &&
+ native_app_window_->CanHaveAlphaEnabled());
// These properties are undocumented and are to enable testing. Alpha is
// removed to
diff --git a/apps/app_window.h b/apps/app_window.h
index f2e0e98..216ee3c 100644
--- a/apps/app_window.h
+++ b/apps/app_window.h
@@ -362,6 +362,11 @@ class AppWindow : public content::NotificationObserver,
// app.
void WindowEventsReady();
+ // Whether the app window wants a transparent background.
+ bool requested_transparent_background() const {
+ return requested_transparent_background_;
+ }
+
protected:
virtual ~AppWindow();
@@ -558,6 +563,9 @@ class AppWindow : public content::NotificationObserver,
// taskbar.
bool cached_always_on_top_;
+ // Whether |transparent_background| was set in the CreateParams.
+ bool requested_transparent_background_;
+
DISALLOW_COPY_AND_ASSIGN(AppWindow);
};
diff --git a/apps/ui/native_app_window.h b/apps/ui/native_app_window.h
index cde4c1d..fd0cc26 100644
--- a/apps/ui/native_app_window.h
+++ b/apps/ui/native_app_window.h
@@ -87,6 +87,10 @@ class NativeAppWindow : public ui::BaseWindow,
virtual void SetContentSizeConstraints(const gfx::Size& min_size,
const gfx::Size& max_size) = 0;
+ // Returns false if the underlying native window ignores alpha transparency
+ // when compositing.
+ virtual bool CanHaveAlphaEnabled() const = 0;
+
virtual ~NativeAppWindow() {}
};
diff --git a/apps/ui/views/native_app_window_views.cc b/apps/ui/views/native_app_window_views.cc
index 62b941d..da84d8a 100644
--- a/apps/ui/views/native_app_window_views.cc
+++ b/apps/ui/views/native_app_window_views.cc
@@ -27,14 +27,12 @@ NativeAppWindowViews::NativeAppWindowViews()
web_view_(NULL),
widget_(NULL),
frameless_(false),
- transparent_background_(false),
resizable_(false) {}
void NativeAppWindowViews::Init(AppWindow* app_window,
const AppWindow::CreateParams& create_params) {
app_window_ = app_window;
frameless_ = create_params.frame == AppWindow::FRAME_NONE;
- transparent_background_ = create_params.transparent_background;
resizable_ = create_params.resizable;
size_constraints_.set_minimum_size(
create_params.GetContentMinimumSize(gfx::Insets()));
@@ -53,6 +51,10 @@ NativeAppWindowViews::~NativeAppWindowViews() {
web_view_->SetWebContents(NULL);
}
+void NativeAppWindowViews::OnCanHaveAlphaEnabledChanged() {
+ app_window_->OnNativeWindowChanged();
+}
+
void NativeAppWindowViews::InitializeWindow(
AppWindow* app_window,
const AppWindow::CreateParams& create_params) {
@@ -260,7 +262,8 @@ void NativeAppWindowViews::OnWidgetActivationChanged(views::Widget* widget,
void NativeAppWindowViews::RenderViewCreated(
content::RenderViewHost* render_view_host) {
- if (transparent_background_) {
+ if (app_window_->requested_transparent_background() &&
+ CanHaveAlphaEnabled()) {
content::RenderWidgetHostView* view = render_view_host->GetView();
DCHECK(view);
view->SetBackgroundOpaque(false);
@@ -398,4 +401,8 @@ void NativeAppWindowViews::SetContentSizeConstraints(
size_constraints_.set_maximum_size(max_size);
}
+bool NativeAppWindowViews::CanHaveAlphaEnabled() const {
+ return widget_->IsTranslucentWindowOpacitySupported();
+}
+
} // namespace apps
diff --git a/apps/ui/views/native_app_window_views.h b/apps/ui/views/native_app_window_views.h
index bdebfde..917feca 100644
--- a/apps/ui/views/native_app_window_views.h
+++ b/apps/ui/views/native_app_window_views.h
@@ -52,6 +52,9 @@ class NativeAppWindowViews : public NativeAppWindow,
void Init(AppWindow* app_window,
const AppWindow::CreateParams& create_params);
+ // Signal that CanHaveTransparentBackground has changed.
+ void OnCanHaveAlphaEnabledChanged();
+
views::Widget* widget() { return widget_; }
void set_window_for_testing(views::Widget* window) { widget_ = window; }
@@ -156,6 +159,7 @@ class NativeAppWindowViews : public NativeAppWindow,
virtual gfx::Size GetContentMaximumSize() const OVERRIDE;
virtual void SetContentSizeConstraints(const gfx::Size& min_size,
const gfx::Size& max_size) OVERRIDE;
+ virtual bool CanHaveAlphaEnabled() const OVERRIDE;
// web_modal::WebContentsModalDialogHost implementation.
virtual gfx::NativeView GetHostView() const OVERRIDE;
@@ -177,7 +181,6 @@ class NativeAppWindowViews : public NativeAppWindow,
scoped_ptr<SkRegion> draggable_region_;
bool frameless_;
- bool transparent_background_;
bool resizable_;
apps::SizeConstraints size_constraints_;
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
index cea4db8..c896571 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
@@ -135,6 +135,7 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow,
virtual SkColor ActiveFrameColor() const OVERRIDE;
virtual SkColor InactiveFrameColor() const OVERRIDE;
virtual gfx::Insets GetFrameInsets() const OVERRIDE;
+ virtual bool CanHaveAlphaEnabled() const OVERRIDE;
// These are used to simulate Mac-style hide/show. Since windows can be hidden
// and shown using the app.window API, this sets is_hidden_with_app_ to
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 9b45321..e3bdc70 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -799,6 +799,10 @@ gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const {
return frame_rect.InsetsFrom(content_rect);
}
+bool NativeAppWindowCocoa::CanHaveAlphaEnabled() const {
+ return false;
+}
+
gfx::NativeView NativeAppWindowCocoa::GetHostView() const {
NOTIMPLEMENTED();
return NULL;
diff --git a/chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc b/chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc
index b2301e6..f6a8139 100644
--- a/chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc
+++ b/chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc
@@ -48,6 +48,7 @@ bool AppWindowDesktopWindowTreeHostWin::GetClientAreaInsets(
void AppWindowDesktopWindowTreeHostWin::HandleFrameChanged() {
// We need to update the glass region on or off before the base class adjusts
// the window region.
+ app_window_->OnCanHaveAlphaEnabledChanged();
UpdateDWMFrame();
DesktopWindowTreeHostWin::HandleFrameChanged();
}
diff --git a/chrome/common/extensions/api/app_current_window_internal.idl b/chrome/common/extensions/api/app_current_window_internal.idl
index a8a1cd5..890e75b 100644
--- a/chrome/common/extensions/api/app_current_window_internal.idl
+++ b/chrome/common/extensions/api/app_current_window_internal.idl
@@ -61,6 +61,7 @@
static void onMinimized();
static void onMaximized();
static void onRestored();
+ static void onAlphaEnabledChanged();
// Only sent in tests.
static void onWindowShownForTests();
};
diff --git a/chrome/common/extensions/api/app_window.idl b/chrome/common/extensions/api/app_window.idl
index b08037b..26922d7 100644
--- a/chrome/common/extensions/api/app_window.idl
+++ b/chrome/common/extensions/api/app_window.idl
@@ -351,6 +351,10 @@ namespace app.window {
// <code>"alwaysOnTopWindows"</code> permission.
static void setAlwaysOnTop(boolean alwaysOnTop);
+ // Can the window use alpha transparency?
+ // TODO(jackhou): Document this properly before going to stable.
+ [nodoc] static boolean alphaEnabled();
+
// The JavaScript 'window' object for the created child.
[instanceOf=Window] object contentWindow;
@@ -433,6 +437,9 @@ namespace app.window {
// Fired when the window is restored from being minimized or maximized.
[nocompile] static void onRestored();
+ // Fired when the window's ability to use alpha transparency changes.
+ [nocompile, nodoc] static void onAlphaEnabledChanged();
+
// Event for testing. Lets tests wait until a window has been shown.
[nocompile, nodoc] static void onWindowFirstShown();
};
diff --git a/chrome/renderer/resources/extensions/app_window_custom_bindings.js b/chrome/renderer/resources/extensions/app_window_custom_bindings.js
index 99ca8bc..c666d32 100644
--- a/chrome/renderer/resources/extensions/app_window_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/app_window_custom_bindings.js
@@ -241,6 +241,9 @@ appWindow.registerCustomHook(function(bindingsAPI) {
AppWindow.prototype.isAlwaysOnTop = function() {
return appWindowData.alwaysOnTop;
};
+ AppWindow.prototype.alphaEnabled = function() {
+ return appWindowData.alphaEnabled;
+ }
AppWindow.prototype.handleWindowFirstShownForTests = function(callback) {
// This allows test apps to get have their callback run even if they
// call this after the first show has happened.
@@ -301,7 +304,8 @@ appWindow.registerCustomHook(function(bindingsAPI) {
alwaysOnTop: params.alwaysOnTop,
hasFrameColor: params.hasFrameColor,
activeFrameColor: params.activeFrameColor,
- inactiveFrameColor: params.inactiveFrameColor
+ inactiveFrameColor: params.inactiveFrameColor,
+ alphaEnabled: params.alphaEnabled
};
currentAppWindow = new AppWindow;
});
@@ -348,6 +352,9 @@ function updateAppWindowProperties(update) {
(oldData.minimized && !update.minimized) ||
(oldData.maximized && !update.maximized))
dispatchEventIfExists(currentWindow, "onRestored");
+
+ if (oldData.alphaEnabled !== update.alphaEnabled)
+ dispatchEventIfExists(currentWindow, "onAlphaEnabledChanged");
};
function onAppWindowShownForTests() {
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 60458c7..1a45795 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -932,6 +932,11 @@ void DesktopNativeWidgetAura::OnRootViewLayout() const {
desktop_window_tree_host_->OnRootViewLayout();
}
+bool DesktopNativeWidgetAura::IsTranslucentWindowOpacitySupported() const {
+ return content_window_ &&
+ desktop_window_tree_host_->IsTranslucentWindowOpacitySupported();
+}
+
void DesktopNativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) {
OnEvent(native_event);
}
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
index f265814..f005f36 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h
@@ -178,6 +178,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE;
+ virtual bool IsTranslucentWindowOpacitySupported() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
// Overridden from aura::WindowDelegate:
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host.h b/ui/views/widget/desktop_aura/desktop_window_tree_host.h
index 26925b67..9ccb672 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host.h
@@ -153,6 +153,9 @@ class VIEWS_EXPORT DesktopWindowTreeHost {
// Returns true if the Widget was closed but is still showing because of
// animations.
virtual bool IsAnimatingClosed() const = 0;
+
+ // Returns true if the Widget supports translucency.
+ virtual bool IsTranslucentWindowOpacitySupported() const = 0;
};
} // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index fc2bda6..6347526 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -365,7 +365,7 @@ void DesktopWindowTreeHostWin::SetVisibilityChangedAnimationsEnabled(
}
bool DesktopWindowTreeHostWin::ShouldUseNativeFrame() const {
- return ui::win::IsAeroGlassEnabled();
+ return IsTranslucentWindowOpacitySupported();
}
bool DesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const {
@@ -427,6 +427,10 @@ bool DesktopWindowTreeHostWin::IsAnimatingClosed() const {
return pending_close_;
}
+bool DesktopWindowTreeHostWin::IsTranslucentWindowOpacitySupported() const {
+ return ui::win::IsAeroGlassEnabled();
+}
+
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostWin, WindowTreeHost implementation:
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
index 5fb0639..225365f 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -103,6 +103,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
virtual void OnNativeWidgetFocus() OVERRIDE;
virtual void OnNativeWidgetBlur() OVERRIDE;
virtual bool IsAnimatingClosed() const OVERRIDE;
+ virtual bool IsTranslucentWindowOpacitySupported() const OVERRIDE;
// Overridden from aura::WindowTreeHost:
virtual ui::EventSource* GetEventSource() OVERRIDE;
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index e7d86b5..74026c1 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -831,6 +831,10 @@ bool DesktopWindowTreeHostX11::IsAnimatingClosed() const {
return false;
}
+bool DesktopWindowTreeHostX11::IsTranslucentWindowOpacitySupported() const {
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, aura::WindowTreeHost implementation:
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
index cbcd9fc..cee65f5 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
@@ -144,6 +144,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
virtual void OnNativeWidgetFocus() OVERRIDE;
virtual void OnNativeWidgetBlur() OVERRIDE;
virtual bool IsAnimatingClosed() const OVERRIDE;
+ virtual bool IsTranslucentWindowOpacitySupported() const OVERRIDE;
// Overridden from aura::WindowTreeHost:
virtual ui::EventSource* GetEventSource() OVERRIDE;
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index e26c52c..a1f05c4 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -691,6 +691,10 @@ ui::NativeTheme* NativeWidgetAura::GetNativeTheme() const {
void NativeWidgetAura::OnRootViewLayout() const {
}
+bool NativeWidgetAura::IsTranslucentWindowOpacitySupported() const {
+ return true;
+}
+
void NativeWidgetAura::RepostNativeEvent(gfx::NativeEvent native_event) {
OnEvent(native_event);
}
diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h
index 3b1e58a..dd6fafe 100644
--- a/ui/views/widget/native_widget_aura.h
+++ b/ui/views/widget/native_widget_aura.h
@@ -132,6 +132,7 @@ class VIEWS_EXPORT NativeWidgetAura
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE;
+ virtual bool IsTranslucentWindowOpacitySupported() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
// Overridden from views::InputMethodDelegate:
diff --git a/ui/views/widget/native_widget_mac.h b/ui/views/widget/native_widget_mac.h
index 0cd87b7..64cb9a3 100644
--- a/ui/views/widget/native_widget_mac.h
+++ b/ui/views/widget/native_widget_mac.h
@@ -102,6 +102,7 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE;
virtual void OnRootViewLayout() const OVERRIDE;
+ virtual bool IsTranslucentWindowOpacitySupported() const OVERRIDE;
virtual void RepostNativeEvent(gfx::NativeEvent native_event) OVERRIDE;
private:
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
index 729207a..37545b9 100644
--- a/ui/views/widget/native_widget_mac.mm
+++ b/ui/views/widget/native_widget_mac.mm
@@ -359,6 +359,10 @@ void NativeWidgetMac::OnRootViewLayout() const {
NOTIMPLEMENTED();
}
+bool NativeWidgetMac::IsTranslucentWindowOpacitySupported() const {
+ return false;
+}
+
void NativeWidgetMac::RepostNativeEvent(gfx::NativeEvent native_event) {
NOTIMPLEMENTED();
}
diff --git a/ui/views/widget/native_widget_private.h b/ui/views/widget/native_widget_private.h
index d87bb0f..8c9233a 100644
--- a/ui/views/widget/native_widget_private.h
+++ b/ui/views/widget/native_widget_private.h
@@ -227,6 +227,7 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0;
virtual ui::NativeTheme* GetNativeTheme() const = 0;
virtual void OnRootViewLayout() const = 0;
+ virtual bool IsTranslucentWindowOpacitySupported() const = 0;
// Repost an unhandled event to the native widget for default OS processing.
virtual void RepostNativeEvent(gfx::NativeEvent native_event) = 0;
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index fdcb32a..3f4a170 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -981,6 +981,10 @@ void Widget::OnRootViewLayout() {
native_widget_->OnRootViewLayout();
}
+bool Widget::IsTranslucentWindowOpacitySupported() const {
+ return native_widget_->IsTranslucentWindowOpacitySupported();
+}
+
void Widget::OnOwnerClosing() {
}
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index bc3f914..c76633b 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -198,6 +198,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
WidgetDelegate* delegate;
bool child;
// If TRANSLUCENT_WINDOW, the widget may be fully or partially transparent.
+ // Translucent windows may not always be supported. Use
+ // IsTranslucentWindowOpacitySupported to determine if translucent windows
+ // are supported.
// If OPAQUE_WINDOW, we can perform optimizations based on the widget being
// fully opaque. Defaults to TRANSLUCENT_WINDOW if
// ViewsDelegate::UseTransparentWindows(). Defaults to OPAQUE_WINDOW for
@@ -726,6 +729,9 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
// window sizing information to the window server on some platforms.
void OnRootViewLayout();
+ // Whether the widget supports translucency.
+ bool IsTranslucentWindowOpacitySupported() const;
+
// Notification that our owner is closing.
// NOTE: this is not invoked for aura as it's currently not needed there.
// Under aura menus close by way of activation getting reset when the owner
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index d6ab099..d606206 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -623,6 +623,7 @@ class WidgetWithDestroyedNativeViewTest : public ViewsTestBase {
widget->ReleaseCapture();
widget->HasCapture();
widget->GetWorkAreaBoundsInScreen();
+ widget->IsTranslucentWindowOpacitySupported();
}
private: