Skip to content

Commit

Permalink
Support for Windows Transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
U-TREVORLINTO9418\trevorlinton authored and U-TREVORLINTO9418\trevorlinton committed Jan 6, 2013
1 parent 05572fb commit e9ac9ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/browser/native_window_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/native_widget_win.h"
#include "ui/views/window/native_frame_view.h"
#include <dwmapi.h>

namespace nw {

Expand Down Expand Up @@ -242,6 +243,11 @@ NativeWindowWin::NativeWindowWin(content::Shell* shell,
maximum_size_() {
window_ = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);

bool transparent;
if(manifest->GetBoolean(switches::kmTransparent, &transparent) && transparent)
params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;

params.delegate = this;
params.remove_standard_frame = !has_frame();
params.use_system_default_icon = true;
Expand All @@ -261,6 +267,11 @@ NativeWindowWin::NativeWindowWin(content::Shell* shell,
window_->UpdateWindowIcon();

OnViewWasResized();

if(transparent) {
MARGINS mgMarInset = { -1, -1, -1, -1 };
DwmExtendFrameIntoClientArea(window_->GetNativeWindow(), &mgMarInset);
}
}

NativeWindowWin::~NativeWindowWin() {
Expand Down
4 changes: 1 addition & 3 deletions src/nw_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,7 @@ void Shell::WebContentsCreated(WebContents* source_contents,

manifest->SetBoolean(switches::kmResizable, features.resizable);
manifest->SetBoolean(switches::kmFullscreen, features.fullscreen);
manifest->SetBoolean(switches::kmTransparent, features.transparent);
manifest->SetBoolean(switches::kmFrame, features.frame);
manifest->SetBoolean(switches::kmShadow, features.shadow);

if (features.widthSet)
manifest->SetInteger(switches::kmWidth, features.width);
if (features.heightSet)
Expand Down
6 changes: 6 additions & 0 deletions src/shell_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ void ShellContentBrowserClient::OverrideWebkitPrefs(

// Force compositing mode to support transparency
prefs->force_compositing_mode = true;
prefs->accelerated_2d_canvas_enabled = true;
prefs->accelerated_animation_enabled = true;
prefs->accelerated_compositing_enabled = true;
prefs->accelerated_filters_enabled = true;
prefs->accelerated_layers_enabled = true;
prefs->accelerated_painting_enabled = true;

base::DictionaryValue* webkit;
if (package->root()->GetDictionary(switches::kmWebkit, &webkit)) {
Expand Down

0 comments on commit e9ac9ef

Please sign in to comment.