Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add window transparency for linux #1926

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions v2/internal/frontend/desktop/linux/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion v2/pkg/options/linux/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package linux

// Options specific to Linux builds
type Options struct {
Icon []byte
Icon []byte
WindowIsTranslucent bool
}
8 changes: 8 additions & 0 deletions website/docs/reference/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func main() {
},
Linux: &linux.Options{
Icon: icon,
WindowIsTranslucent: false,
},
})
if err != nil {
Expand Down Expand Up @@ -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`