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:
parent
32e9cb30bf
commit
2690250378
@ -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
|
||||
|
@ -2,5 +2,6 @@ package linux
|
||||
|
||||
// Options specific to Linux builds
|
||||
type Options struct {
|
||||
Icon []byte
|
||||
Icon []byte
|
||||
WindowIsTranslucent bool
|
||||
}
|
||||
|
@ -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, don’t 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`
|
Loading…
Reference in New Issue
Block a user