Skip to content

Commit

Permalink
Only change variant when color scheme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Nov 10, 2024
1 parent 85063d5 commit ebc6492
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/app_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ func rootConfigDir() string {
func watchTheme(s *settings) {
go func() {
// Theme lookup hangs on some desktops. Update theme variant cache from within goroutine.
internalapp.CurrentVariant.Store(uint64(findFreedesktopColorScheme()))
s.setupTheme()
themeVariant := findFreedesktopColorScheme()
internalapp.CurrentVariant.Store(uint64(themeVariant))
s.applyVariant(themeVariant)

portalSettings.OnSignalSettingChanged(func(changed portalSettings.Changed) {
if changed.Namespace == "org.freedesktop.appearance" && changed.Key == "color-scheme" {
themeVariant := colorSchemeToThemeVariant(appearance.ColorScheme(changed.Value.(uint32)))
internalapp.CurrentVariant.Store(uint64(themeVariant))
s.setupTheme()
s.applyVariant(themeVariant)
}
})
}()
Expand Down
7 changes: 7 additions & 0 deletions app/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ func (s *settings) applyTheme(theme fyne.Theme, variant fyne.ThemeVariant) {
s.apply()
}

func (s *settings) applyVariant(variant fyne.ThemeVariant) {
s.propertyLock.Lock()
defer s.propertyLock.Unlock()
s.variant = variant
s.apply()
}

func (s *settings) Scale() float32 {
s.propertyLock.RLock()
defer s.propertyLock.RUnlock()
Expand Down

0 comments on commit ebc6492

Please sign in to comment.