Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Changed blur method into ACCENT_ENABLE_ACRYLICBLURBEHIND
Browse files Browse the repository at this point in the history
  • Loading branch information
seo-rii committed Jul 27, 2020
1 parent ed75570 commit f1bdc9d
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 124 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules/
.gitignore
.travis.yml
logo.png
screenshots/
screenshots/
test/
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ branches:
- master

install:
- npm install
- npm install
- npm run-script test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<img alt="logo" src="./logo.png" width="250">

[![Build Status](https://travis-ci.com/04seohyun/electron-acrylic-window.svg?branch=master)](https://travis-ci.com/04seohyun/electron-acrylic-window)
[![Dependencies](https://david-dm.org/04seohyun/electron-acrylic-window.svg)](https://david-dm.org/04seohyun/electron-acrylic-window)
[![Build Status](https://travis-ci.com/seo-rii/electron-acrylic-window.svg?branch=master)](https://travis-ci.com/seo-rii/electron-acrylic-window)
[![Dependencies](https://david-dm.org/seo-rii/electron-acrylic-window.svg)](https://david-dm.org/seo-rii/electron-acrylic-window)
[![npm version](https://badge.fury.io/js/electron-acrylic-window.svg)](https://badge.fury.io/js/electron-acrylic-window)

Simply add vibrancy effect to Electron application on Windows.
Expand Down
37 changes: 27 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const {setVibrancy: wSetVibrancy, disableVibrancy: wDisableVibrancy} = require('bindings')('vibrancy-wrapper');
const {setVibrancy: wSetVibrancy, disableVibrancy: wDisableVibrancy} = require("bindings")("vibrancy-wrapper");
const os = require("os");
const eBrowserWindow = require('electron').BrowserWindow;
const eBrowserWindow = require("electron").BrowserWindow;
const {nativeTheme} = require("electron");
const supportedType = ['light', 'dark', 'appearance-based'];

function isWindows10() {
if (process.platform !== 'win32') return false;
Expand All @@ -24,26 +26,41 @@ function getHwnd(win) {
class vBrowserWindow extends eBrowserWindow {
constructor(props) {
super(props);
if (isWindows10() && props.hasOwnProperty('vibrancy')) wSetVibrancy(getHwnd(this));
if (isWindows10() && props.hasOwnProperty('vibrancy')) this.setVibrancy(props.vibrancy);
}

setVibrancy(type = null) {
if (!isWindows10()) super.setVibrancy(type);
setVibrancy(op = null) {
if (op) this.setVibrancy(null);
if (!isWindows10()) super.setVibrancy(op);
else {
if (type) wSetVibrancy(getHwnd(this));
if (!op in supportedType) op = 'appearance-based';
if (op === 'appearance-based') {
if (nativeTheme.shouldUseDarkColors) op = 'dark';
else op = 'light';
}
console.log(op === 'light' ? 0 : 1);
if (op) wSetVibrancy(getHwnd(this), op === 'light' ? 0 : 1);
else wDisableVibrancy(getHwnd(this));
}
}
}

function setVibrancy(win, op = null) {
function setVibrancy(win, op = 'appearance-based') {
if (op) setVibrancy(win, null);
if (!isWindows10()) win.setVibrancy(op);
else wSetVibrancy(getHwnd(win));
else {
if (!op in supportedType) op = 'appearance-based';
if (op === 'appearance-based') {
if (nativeTheme.shouldUseDarkColors) op = 'dark';
else op = 'light';
}
if (op) wSetVibrancy(getHwnd(this), op === 'light' ? 0 : 1);
else wDisableVibrancy(getHwnd(this));
}
}

function disableVibrancy(win) {
if (!isWindows10()) win.setVibrancy(null);
else wDisableVibrancy(getHwnd(win));
setVibrancy(win, null);
}

exports.setVibrancy = setVibrancy;
Expand Down
Loading

0 comments on commit f1bdc9d

Please sign in to comment.