Skip to content

Commit

Permalink
Update launcher icons to show transparent if iconified
Browse files Browse the repository at this point in the history
And update switcher to match
  • Loading branch information
andydotxyz committed Jun 11, 2024
1 parent 905b608 commit f1add32
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 5 deletions.
16 changes: 13 additions & 3 deletions internal/ui/bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,20 @@ func (b *bar) WindowRemoved(win fynedesk.Window) {
if icon.windowData == nil || win != icon.windowData.win {
continue
}
if !win.Iconic() {
b.removeFromTaskbar(icon)
b.icons = append(b.icons[:i], b.icons[i+1:]...)

b.removeFromTaskbar(icon)
b.icons = append(b.icons[:i], b.icons[i+1:]...)
break
}
}

func (b *bar) WindowStateChanged(win fynedesk.Window) {
for _, icon := range b.icons {
if icon.windowData == nil || win != icon.windowData.win {
continue
}

icon.Refresh()
break
}
}
Expand Down
6 changes: 6 additions & 0 deletions internal/ui/baricon.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ func (bi *barIconRenderer) Refresh() {
}
bi.Layout(bi.image.Size())

if bi.image.windowData != nil && bi.image.windowData.win.Iconic() {
if img, ok := bi.objects[0].(*canvas.Image); ok {
img.Translucency = 0.67
}
}

canvas.Refresh(bi.image)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/ui/switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *switchIcon) CreateRenderer() fyne.WidgetRenderer {
bg.CornerRadius = theme.InputRadiusSize()
img := canvas.NewImageFromResource(res)
if s.win.Iconic() {
img.Translucency = 0.8
img.Translucency = 0.67
}
text := widget.NewLabelWithStyle(title, fyne.TextAlignCenter, fyne.TextStyle{})
text.Truncation = fyne.TextTruncateEllipsis
Expand Down
2 changes: 1 addition & 1 deletion internal/x11/win/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func (c *client) NotifyFullscreen() {
}

func (c *client) NotifyIconify() {
c.frame.hide()
c.iconic = true
c.frame.hide()
x11.WindowExtendedHintsAdd(c.wm.X(), c.win, "_NET_WM_STATE_HIDDEN")
}

Expand Down
2 changes: 2 additions & 0 deletions internal/x11/wm/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func (x *x11WM) handleClientMessage(ev xproto.ClientMessageEvent) {
switch ev.Data.Bytes()[0] {
case icccm.StateIconic:
c.NotifyIconify()
x.publishWindowChange(c)
case icccm.StateNormal:
c.NotifyUnIconify()
x.publishWindowChange(c)
}
case "_NET_ACTIVE_WINDOW":
x.handleActiveWin(ev)
Expand Down
6 changes: 6 additions & 0 deletions internal/x11/wm/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ func (s *stack) indexForWin(win fynedesk.Window) int {
return pos
}

func (s *stack) publishWindowChange(win fynedesk.Window) {
for _, l := range s.listeners {
l.WindowStateChanged(win)
}
}

func (s *stack) removeFromStack(win fynedesk.Window) {
pos := s.indexForWin(win)

Expand Down
3 changes: 3 additions & 0 deletions modules/desktops/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (p *pager) WindowRemoved(_ fynedesk.Window) {
p.refresh()
}

func (p *pager) WindowStateChanged(_ fynedesk.Window) {
}

func (p *pager) refresh() {
desk := fynedesk.Instance()
p.refreshFrom(desk.Desktop())
Expand Down
1 change: 1 addition & 0 deletions wm.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Stack interface {
type StackListener interface {
WindowAdded(Window)
WindowRemoved(Window)
WindowStateChanged(Window)

WindowMoved(Window)
WindowOrderChanged()
Expand Down

0 comments on commit f1add32

Please sign in to comment.