Linux上的透明Windows(Electron) [英] Transparent Windows on Linux (Electron)

查看:447
本文介绍了Linux上的透明Windows(Electron)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Electron中创建新的BrowserWindow时,使用透明参数并将其设置为true通常会为该窗口提供透明背景...但是在Linux上,据我所知并非如此

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 the case for my knowledge

现在我听说您可以设置一些命令行参数...但这不起作用...无论如何,它只会显示黑色或白色...

Now I heard you can set some Command Line Arguments... But that isn't working... It just displays black or white no matter what...

// Should set the commandLine arguments and work...

const {app} = require('electron')

app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');

现在我已经听说这不是电子问题,而是硬件问题...但是我只需要确保创建这个问题即可!

Now i have heard this is no problem with electron rather a problem with hardware... But i just needed to make sure therefore creating this question!

推荐答案

我遇到了与您相同的问题,所以我写了:

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.

您可以克隆此git回购,并放置延迟到500,通常会出现魔法.

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

使用此存储库: https://gitlab.com/doom-fr/electron-transparency-演示

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

对于我来说,它与Debian Jessie和电子版4.0.5兼容,对于npm startnpm run startWithTransparentOption而言是无效的,而对于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.

注意:请谨慎设置至少500ms,以使其有机会工作.之后可以减少延迟,但不稳定.这就是为什么需要有关transparentReady的事件的原因.

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

这篇关于Linux上的透明Windows(Electron)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆