Exporting decorations buttons as images

Vlad Zahorodnii vlad.zahorodnii at kde.org
Mon Apr 27 08:36:38 BST 2020


Hi,

On 4/25/20 11:33 AM, Zolotukhin Mikhail wrote:
> Hello,
> 
> I am interested in providing support for custom window decorations for 
> GTK applications with Client Sided Decorations. Currently I have an idea 
> in mind, that may or may not work depending on multiple circumstances. 
> One of the things I need to implement that idea is to tell KWin to draw 
> window decorations with different states (hover, clicked, normal) to 
> images (.png and .svg). If I understand correctly, to do that I need to 
> call paint 
> <https://api.kde.org/kdecoration/html/classKDecoration2_1_1DecorationButton.html#ab57e4b79de9bf233a8cd5b7812c19c75> 
> method from KDecoration library with a custom QPainter. However, to call 
> it, I need to create a KDecoration2::DecorationButton instance first. 
> Unfortunately, I do not fully understand how to do so from an arbitrary 
> place.

Unfortunately, that's the way it is. You have to mock a lot of objects 
to render decoration buttons.

> As I could see Window Decorations KCM and Latte Dock Buttons applet 
> <https://github.com/psifidotos/applet-window-buttons> uses some kind of 
> complicated bridge to draw decorations in QML. I am not really sure if I 
> need exactly that to just draw decorations to images, so I tried to 
> build a custom minimal solution here:
> https://phabricator.kde.org/D28623
> Unfortunately it does not work and the program just crashes with seg fault.

Do you have a backtrace? :-)

> So, I want to ask the experts for help with that part: how can I 
> correctly ask KWin to draw decorations buttons to images?

I'm not sure that KDecoration had been designed for such a specific use 
case. As far as I know, in order to render a decoration outside of kwin, 
you have to mock DecorationBridge and DecorationSettings. There is no 
other way around, unfortunately. You've mentioned the decoration preview 
plugin from Window Decorations KCM and Latte Dock Buttons applet, I 
suggest to continue following what they do.

Cheers,
Vlad


More information about the kwin mailing list