├── .gitignore ├── .npmignore ├── LICENSE ├── ReadMe.md ├── appveyor.yml ├── binding.gyp ├── lib └── index.ts ├── package.json ├── src └── blurbehind.cc └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | dist/ 4 | .vscode/ 5 | package-lock.json -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | build/ 2 | lib/ 3 | 4 | appveyor.yml 5 | ReadMe.md 6 | tsconfig.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Charles Milette 2 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 4 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # windows-blurbehind 2 | 3 | Invoke like this: 4 | 5 | ```js 6 | const bb = require('window-blurbehind'); 7 | bb.DwmEnableBlurBehindWindow(myWindow, shouldEnable); 8 | ``` 9 | 10 | Where the first parameter can either be an Electron `BrowserWindow` or a window handle stored as `Buffer`. 11 | 12 | `shouldEnable` is a boolean indicating whether the blur behind is to be turned on or off. 13 | 14 | ## Tips for usage on Electron 15 | 16 | For best user and developer experience, **do not set** `transparent` to `true`. It has many shortcomings, such as no support for maximised window state and shadows. Instead set `backgroundColor` to `#00000000`. -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 'Build #{build}' 2 | platform: 3 | - x86 4 | - x64 5 | install: 6 | - ps: Install-Product node 8 $env:platform 7 | test_script: 8 | - npm install 9 | build: off 10 | deploy: off -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "blurbehind", 5 | "sources": [ "src/blurbehind.cc" ], 6 | "link_settings": { 7 | "libraries": [ "dwmapi.lib" ] 8 | } 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /lib/index.ts: -------------------------------------------------------------------------------- 1 | const native: any = require("../build/Release/blurbehind.node"); 2 | 3 | /** 4 | * Enables or disable blur behind a window 5 | * @param window The target window's native handle. 6 | * @param enable Whether to enable or disable blur behind. 7 | */ 8 | export function DwmEnableBlurBehindWindow(window: Buffer, enable: boolean) { 9 | return native.blurbehind(window, enable); 10 | }; 11 | 12 | /** 13 | * Extends the window frame in the client area. 14 | * @param window The target window's native handle. 15 | * @param left 16 | * @param right 17 | * @param top 18 | * @param bottom 19 | */ 20 | export function DwmExtendFrameIntoClientArea(window: Buffer, left: number, right: number, top: number, bottom: number) { 21 | return native.extendframe(window, left, right, top, bottom); 22 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "windows-blurbehind", 3 | "version": "2.0.0", 4 | "description": "JavaScript bindings for DwmEnableBlurBehindWindow and DwmExtendFrameIntoClientArea", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/sylveon/windows-blurbehind.git" 10 | }, 11 | "keywords": [ 12 | "bindings", 13 | "native", 14 | "transparency", 15 | "blur", 16 | "aero" 17 | ], 18 | "author": { 19 | "name": "Charles Milette", 20 | "email": "charles.milette@gmail.com", 21 | "url": "https://sylveon.dev/" 22 | }, 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/sylveon/windows-blurbehind/issues" 26 | }, 27 | "homepage": "https://github.com/sylveon/windows-blurbehind", 28 | "dependencies": { 29 | "@types/node": "^10.12.18" 30 | }, 31 | "devDependencies": { 32 | "node-gyp": "^3.6.2", 33 | "typescript": "^3.2.4" 34 | }, 35 | "scripts": { 36 | "prepare": "tsc", 37 | "build": "node-gyp build" 38 | }, 39 | "os": [ 40 | "win32" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/blurbehind.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void blurbehind(const v8::FunctionCallbackInfo &args) 6 | { 7 | const HWND handle = *reinterpret_cast(node::Buffer::Data(args[0].As())); 8 | 9 | const DWM_BLURBEHIND bb = { 10 | DWM_BB_ENABLE, 11 | args[1].As()->Value(), 12 | NULL, 13 | FALSE 14 | }; 15 | 16 | const HRESULT returnValue = DwmEnableBlurBehindWindow(handle, &bb); 17 | 18 | args.GetReturnValue().Set(SUCCEEDED(returnValue)); 19 | } 20 | 21 | void extendframe(const v8::FunctionCallbackInfo &args) 22 | { 23 | const HWND handle = *reinterpret_cast(node::Buffer::Data(args[0].As())); 24 | 25 | const MARGINS inset = { 26 | args[1].As()->Value(), 27 | args[2].As()->Value(), 28 | args[3].As()->Value(), 29 | args[4].As()->Value() 30 | }; 31 | 32 | const HRESULT returnValue = DwmExtendFrameIntoClientArea(handle, &inset); 33 | 34 | args.GetReturnValue().Set(SUCCEEDED(returnValue)); 35 | } 36 | 37 | void init(v8::Local exports) 38 | { 39 | NODE_SET_METHOD(exports, "blurbehind", blurbehind); 40 | NODE_SET_METHOD(exports, "extendframe", extendframe); 41 | } 42 | 43 | NODE_MODULE(NODE_GYP_MODULE_NAME, init) 44 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "./dist", 7 | "strict": true, 8 | "noImplicitAny": true 9 | } 10 | } --------------------------------------------------------------------------------