Allow setting hardcoded background darkening

Normally, one can only change the background of the foreground for the
inactive window. With this change the background of the inactive window
will also change it's brightness by 20%.
This commit is contained in:
Kacper Kowalski 2023-02-03 14:34:16 +01:00
parent 403bf540d0
commit 3854a7c0e2
1 changed files with 10 additions and 2 deletions

View File

@ -112,6 +112,7 @@ class Terminal(Gtk.VBox):
fgcolor_active = None fgcolor_active = None
fgcolor_inactive = None fgcolor_inactive = None
bgcolor = None bgcolor = None
bgcolor_inactive = None
palette_active = None palette_active = None
palette_inactive = None palette_inactive = None
@ -754,6 +755,13 @@ class Terminal(Gtk.VBox):
dbg(("fgcolor_inactive set to: RGB(%s,%s,%s)", getattr(self.fgcolor_inactive, "red"), dbg(("fgcolor_inactive set to: RGB(%s,%s,%s)", getattr(self.fgcolor_inactive, "red"),
getattr(self.fgcolor_inactive, "green"), getattr(self.fgcolor_inactive, "green"),
getattr(self.fgcolor_inactive, "blue"))) getattr(self.fgcolor_inactive, "blue")))
bg_factor = 0.8
self.bgcolor_inactive = self.bgcolor.copy()
for bit in ['red', 'green', 'blue']:
setattr(self.bgcolor_inactive, bit,
getattr(self.bgcolor_inactive, bit) * bg_factor)
colors = self.config['palette'].split(':') colors = self.config['palette'].split(':')
self.palette_active = [] self.palette_active = []
for color in colors: for color in colors:
@ -789,7 +797,7 @@ class Terminal(Gtk.VBox):
self.vte.set_colors(self.fgcolor_active, self.bgcolor, self.vte.set_colors(self.fgcolor_active, self.bgcolor,
self.palette_active) self.palette_active)
else: else:
self.vte.set_colors(self.fgcolor_inactive, self.bgcolor, self.vte.set_colors(self.fgcolor_inactive, self.bgcolor_inactive,
self.palette_inactive) self.palette_inactive)
profiles = self.config.base.profiles profiles = self.config.base.profiles
terminal_box_style_context = self.terminalbox.get_style_context() terminal_box_style_context = self.terminalbox.get_style_context()
@ -1314,7 +1322,7 @@ class Terminal(Gtk.VBox):
def on_vte_focus_out(self, _widget, _event): def on_vte_focus_out(self, _widget, _event):
"""Inform other parts of the application when focus is lost""" """Inform other parts of the application when focus is lost"""
self.vte.set_colors(self.fgcolor_inactive, self.bgcolor, self.vte.set_colors(self.fgcolor_inactive, self.bgcolor_inactive,
self.palette_inactive) self.palette_inactive)
self.set_cursor_color() self.set_cursor_color()
self.emit('focus-out') self.emit('focus-out')