summaryrefslogtreecommitdiffstats
path: root/apps/ui
diff options
context:
space:
mode:
authorjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-18 07:21:22 +0000
committerjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-18 07:21:22 +0000
commit7ec744bb44a15ceb8fe1a455568f4b7e9c635ca0 (patch)
tree03c3aee3e3900e7701706c00233c150be93a1a74 /apps/ui
parentfbad5bb4be0194d3288efc3ab16cb4480f03ab33 (diff)
downloadchromium_src-7ec744bb44a15ceb8fe1a455568f4b7e9c635ca0.zip
chromium_src-7ec744bb44a15ceb8fe1a455568f4b7e9c635ca0.tar.gz
chromium_src-7ec744bb44a15ceb8fe1a455568f4b7e9c635ca0.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/ui')
-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
3 files changed, 18 insertions, 4 deletions
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_;