Transparent Windows on Linux (Electron)

后端 未结 3 2046
长情又很酷
长情又很酷 2021-02-14 23:07

Using the transparent argument and setting it to true when creating a new BrowserWindow in Electron usually gives the window a transparent background... But on Linux that isn\'t

3条回答
  •  无人共我
    2021-02-14 23:28

    I have encounter the same problem as you and so I have written :

    • this StackOverFlow question : Can't succeed in making transparent window in Electron (javascript)
    • this Electron issue : https://github.com/electron/electron/issues/15947
    • and finally request this feature : https://github.com/electron/electron/issues/16809

    Till the requested feature is implemented, the solution is simple just add a delay before launching the window.

    You can clone this git repo, put the delay to 500, and normally magic will appear.

    EDIT 1 : Use this repo : https://gitlab.com/doom-fr/electron-transparency-demo

    git clone https://gitlab.com/doom-fr/electron-transparency-demo
    cd electron-transparency-demo
    npm install
    npm start
    # or npm run startWithTransparentOption
    # or npm run startWithAllOptions
    

    For me, it works out of the box with Debian Jessie and electron 4.0.5, for npm start, npm run startWithTransparentOption but not with npm run startWithAllOptions.

    NB : be carefull to set at least 500ms to have chance it works. After you can reduce the delay but it is not stable. It is why an event on transparentReady is needed.

    Doom

提交回复
热议问题