Question

I am using SWT setAlpha() method on the shell. Transparency works correctly in KDE and GNOME environment i.e. typing in terminal:

java -jar program.jar

but when I am starting my java application on pure X without window manager shell is not transparent and has white background. I use command startx and X execute my ~/.xinitrc script which contains:

cd /home/user
java -jar ./program.jar

Here is the code of method:

public void showTransparentShell() {
    transparentShell = new Shell(shell, SWT.NO_TRIM);
    transparentShell.setAlpha(120);
    transparentShell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    transparentShell.setBounds(shell.getBounds());
    AlphaEffect.fadeOnClose(transparentShell, 900, new ExpoOut(), animationRunner);
    transparentShell.open();
    AlphaEffect.setAlpha(animationRunner, transparentShell, 160, 900, new ExpoOut(), null, null);
}

I am using swt-3.7-2 and gtk-3.2.0

What is required in Linux for transparency? Which components/libraries/packages must be installed for "transparency effect" to work?

EDIT: After hours of googling I came across solution, I simply start Kwin before my java program:

kwin&
cd /home/user
java -jar ./program.jar

Only problem is than Kwin is pretty big and has a lot of dependancies. I must run my program on computers with 256 MB RAM, so maybe someone know a bit lighter window manager that support transparency and will work wiht SWT in the same way as Kwin?

Was it helpful?

Solution

I have finally found out how to resolve my problem. Maybe it will be helpful for others. SWT in linux use cairo to draw transparent effects and needs following libraries:

libswt-cairo-gtk-3-jni
libcairo2
libxcomposite1
libxdamage1

Following XOrg extensions must be loaded:

Composite
DAMAGE

GDK require window to be composited to draw transparency so I need to use window manager. KWin was to heavy and I use xfwm4 instead. xfwm4 has built-in compositor which must be enabled.To enable compositing in xfwm4 just edit property file:

~/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml

and set:

<property name="use_compositing" type="bool" value="true"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top