5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 00:22:57 +08:00

Add window transparency for linux (#1926)

This commit is contained in:
Zámbó, Levente 2022-10-01 07:44:38 +02:00 committed by GitHub
parent 32e9cb30bf
commit 2690250378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -623,6 +623,17 @@ void SetWindowIcon(GtkWindow* window, const guchar* buf, gsize len) {
g_object_unref(loader);
}
static void SetWindowTransparency(GtkWidget *widget)
{
GdkScreen *screen = gtk_widget_get_screen(widget);
GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
if (visual != NULL && gdk_screen_is_composited(screen)) {
gtk_widget_set_app_paintable(widget, true);
gtk_widget_set_visual(widget, visual);
}
}
*/
import "C"
import (
@ -714,6 +725,9 @@ func NewWindow(appoptions *options.App, debug bool) *Window {
if appoptions.Linux.Icon != nil {
result.SetWindowIcon(appoptions.Linux.Icon)
}
if appoptions.Linux.WindowIsTranslucent {
C.SetWindowTransparency(gtkWindow)
}
}
// Menu

View File

@ -2,5 +2,6 @@ package linux
// Options specific to Linux builds
type Options struct {
Icon []byte
Icon []byte
WindowIsTranslucent bool
}

View File

@ -89,6 +89,7 @@ func main() {
},
Linux: &linux.Options{
Icon: icon,
WindowIsTranslucent: false,
},
})
if err != nil {
@ -748,3 +749,10 @@ On KDE it should work.
The icon should be provided in whatever size it was naturally drawn; that is, dont scale the image before passing it.
Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.
#### WindowIsTranslucent
Setting this to `true` will make the window background translucent. Some window managers may ignore it, or result in a black window.
Name: WindowIsTranslucent<br/>
Type: `bool`