From acf56355750316c4c3a4c1019009ae590c6c391e Mon Sep 17 00:00:00 2001 From: Qian Nian Date: Sun, 14 Jun 2026 16:36:52 +0800 Subject: [PATCH] widget/material: add hover state to window decorations Decorations buttons already use widget.Clickable and draw press ink, but they don't draw a hover/focus background. This makes custom window decorations appear unresponsive when the pointer is over minimize, maximize, or close buttons. Register each button's system action over its clickable area and draw the same hovered background used by other material buttons. This also lets platforms query the button action from the material decorations hit area. Signed-off-by: qiannian --- widget/material/decorations.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/widget/material/decorations.go b/widget/material/decorations.go index 6dab1b6d..f52e7c99 100644 --- a/widget/material/decorations.go +++ b/widget/material/decorations.go @@ -5,7 +5,6 @@ import ( "image/color" "gioui.org/f32" - "gioui.org/io/semantic" "gioui.org/io/system" "gioui.org/layout" "gioui.org/op" @@ -86,21 +85,10 @@ func (d DecorationsStyle) layoutDecorations(gtx layout.Context) layout.Dimension continue } cl := d.Decorations.Clickable(a) - dims := cl.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - semantic.Button.Add(gtx.Ops) - return layout.Background{}.Layout(gtx, - func(gtx layout.Context) layout.Dimensions { - defer clip.Rect{Max: gtx.Constraints.Min}.Push(gtx.Ops).Pop() - for _, c := range cl.History() { - drawInk(gtx, c) - } - return layout.Dimensions{Size: gtx.Constraints.Min} - }, - func(gtx layout.Context) layout.Dimensions { - paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops) - return inset.Layout(gtx, w) - }, - ) + dims := Clickable(gtx, cl, func(gtx layout.Context) layout.Dimensions { + system.ActionInputOp(a).Add(gtx.Ops) + paint.ColorOp{Color: d.Foreground}.Add(gtx.Ops) + return inset.Layout(gtx, w) }) size.X += dims.Size.X if size.Y < dims.Size.Y {