Merge pull request #4131 from etiktin/add_is_DWM_enabled
Add API for checking if DWM composition (Aero Glass) is enabled
This commit is contained in:
commit
775e475d5c
3 changed files with 43 additions and 1 deletions
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
#include "ui/base/win/shell.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using atom::Browser;
|
using atom::Browser;
|
||||||
|
@ -318,6 +319,12 @@ std::string App::GetLocale() {
|
||||||
return l10n_util::GetApplicationLocale("");
|
return l10n_util::GetApplicationLocale("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool App::IsAeroGlassEnabled() {
|
||||||
|
return ui::win::IsAeroGlassEnabled();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool App::MakeSingleInstance(
|
bool App::MakeSingleInstance(
|
||||||
const ProcessSingleton::NotificationCallback& callback) {
|
const ProcessSingleton::NotificationCallback& callback) {
|
||||||
if (process_singleton_.get())
|
if (process_singleton_.get())
|
||||||
|
@ -361,6 +368,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
.SetMethod("setUserTasks",
|
.SetMethod("setUserTasks",
|
||||||
base::Bind(&Browser::SetUserTasks, browser))
|
base::Bind(&Browser::SetUserTasks, browser))
|
||||||
|
.SetMethod("isAeroGlassEnabled", &App::IsAeroGlassEnabled)
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("setPath", &App::SetPath)
|
.SetMethod("setPath", &App::SetPath)
|
||||||
.SetMethod("getPath", &App::GetPath)
|
.SetMethod("getPath", &App::GetPath)
|
||||||
|
|
|
@ -88,6 +88,10 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
const ProcessSingleton::NotificationCallback& callback);
|
const ProcessSingleton::NotificationCallback& callback);
|
||||||
std::string GetLocale();
|
std::string GetLocale();
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
bool IsAeroGlassEnabled();
|
||||||
|
#endif
|
||||||
|
|
||||||
scoped_ptr<ProcessSingleton> process_singleton_;
|
scoped_ptr<ProcessSingleton> process_singleton_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(App);
|
DISALLOW_COPY_AND_ASSIGN(App);
|
||||||
|
|
|
@ -400,7 +400,7 @@ starts:
|
||||||
var myWindow = null;
|
var myWindow = null;
|
||||||
|
|
||||||
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
|
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
|
||||||
// Someone tried to run a second instance, we should focus our window
|
// Someone tried to run a second instance, we should focus our window.
|
||||||
if (myWindow) {
|
if (myWindow) {
|
||||||
if (myWindow.isMinimized()) myWindow.restore();
|
if (myWindow.isMinimized()) myWindow.restore();
|
||||||
myWindow.focus();
|
myWindow.focus();
|
||||||
|
@ -424,6 +424,36 @@ app.on('ready', function() {
|
||||||
|
|
||||||
Changes the [Application User Model ID][app-user-model-id] to `id`.
|
Changes the [Application User Model ID][app-user-model-id] to `id`.
|
||||||
|
|
||||||
|
### `app.isAeroGlassEnabled()` _Windows_
|
||||||
|
|
||||||
|
This method returns `true` if [DWM composition](https://msdn.microsoft.com/en-us/library/windows/desktop/aa969540.aspx)
|
||||||
|
(Aero Glass) is enabled, and `false` otherwise. You can use it to determine if
|
||||||
|
you should create a transparent window or not (transparent windows won't work
|
||||||
|
correctly when DWM composition is disabled).
|
||||||
|
|
||||||
|
Usage example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
let browserOptions = {width: 1000, height: 800};
|
||||||
|
|
||||||
|
// Make the window transparent only if the platform supports it.
|
||||||
|
if (process.platform !== 'win32' || app.isAeroGlassEnabled()) {
|
||||||
|
browserOptions.transparent = true;
|
||||||
|
browserOptions.frame = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the window.
|
||||||
|
win = new BrowserWindow(browserOptions);
|
||||||
|
|
||||||
|
// Navigate.
|
||||||
|
if (browserOptions.transparent) {
|
||||||
|
win.loadURL('file://' + __dirname + '/index.html');
|
||||||
|
} else {
|
||||||
|
// No transparency, so we load a fallback that uses basic styles.
|
||||||
|
win.loadURL('file://' + __dirname + '/fallback.html');
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### `app.commandLine.appendSwitch(switch[, value])`
|
### `app.commandLine.appendSwitch(switch[, value])`
|
||||||
|
|
||||||
Append a switch (with optional `value`) to Chromium's command line.
|
Append a switch (with optional `value`) to Chromium's command line.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue