From 146cbb598ad2172ba486af036aba3fef16c34ffc Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Tue, 20 Aug 2019 22:28:14 -0400 Subject: [PATCH] Attempt to offer linux transparency Add 'transparent' as a color option Default to 'transparent' Make sure to set color to appropriate things, so transparency is achieved --- app/display.go | 2 +- app/wtf_app.go | 7 +++++++ cfg/common_settings.go | 2 +- wtf/colors.go | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/display.go b/app/display.go index acd3de9f..3163f8c3 100644 --- a/app/display.go +++ b/app/display.go @@ -20,8 +20,8 @@ func NewDisplay(widgets []wtf.Wtfable, config *config.Config) *Display { config: config, } + display.Grid.SetBackgroundColor(wtf.ColorFor(config.UString("wtf.colors.background", "transparent"))) display.build(widgets) - display.Grid.SetBackgroundColor(wtf.ColorFor(config.UString("wtf.colors.background", "black"))) return &display } diff --git a/app/wtf_app.go b/app/wtf_app.go index 3dbb8e37..bf301094 100644 --- a/app/wtf_app.go +++ b/app/wtf_app.go @@ -37,6 +37,13 @@ func NewWtfApp(app *tview.Application, config *config.Config, configFilePath str pages: tview.NewPages(), } + wtfApp.app.SetBeforeDrawFunc(func(s tcell.Screen) bool { + s.Clear() + return false + }) + + wtfApp.pages.Box.SetBackgroundColor(wtf.ColorFor(config.UString("wtf.colors.background", "transparent"))) + wtfApp.app.SetInputCapture(wtfApp.keyboardIntercept) wtfApp.widgets = MakeWidgets(wtfApp.app, wtfApp.pages, wtfApp.config) wtfApp.display = NewDisplay(wtfApp.widgets, wtfApp.config) diff --git a/cfg/common_settings.go b/cfg/common_settings.go index 231738b5..1cf262be 100644 --- a/cfg/common_settings.go +++ b/cfg/common_settings.go @@ -62,7 +62,7 @@ func NewCommonSettingsFromModule(name, defaultTitle string, moduleConfig *config common := Common{ Colors: Colors{ - Background: moduleConfig.UString("background", globalSettings.UString("background", "black")), + Background: moduleConfig.UString("background", globalSettings.UString("background", "transparent")), BorderFocusable: colorsConfig.UString("border.focusable", "red"), BorderFocused: colorsConfig.UString("border.focused", "orange"), BorderNormal: colorsConfig.UString("border.normal", "gray"), diff --git a/wtf/colors.go b/wtf/colors.go index 3f5c0719..332cfcee 100644 --- a/wtf/colors.go +++ b/wtf/colors.go @@ -401,6 +401,7 @@ var colors = map[string]tcell.Color{ "teal": tcell.ColorTeal, "thistle": tcell.ColorThistle, "tomato": tcell.ColorTomato, + "transparent": tcell.ColorDefault, "turquoise": tcell.ColorTurquoise, "violet": tcell.ColorViolet, "wheat": tcell.ColorWheat,