From 691b81206ef7d907ba10eb9c5a12acf42de23cc1 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Fri, 18 Mar 2022 02:08:48 +0000 Subject: [PATCH 1/2] Define decoration size fields on config and FrameEvent Signed-off-by: tauraamui --- app/os.go | 2 ++ io/system/system.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/os.go b/app/os.go index c6968954b..4bc4395c8 100644 --- a/app/os.go +++ b/app/os.go @@ -23,6 +23,8 @@ var errOutOfDate = errors.New("app: GPU surface out of date") type Config struct { // Size is the window dimensions (Width, Height). Size image.Point + // Decoration size is the dimensions of the window's decoration. + DecorationSize image.Point // MaxSize is the window maximum allowed dimensions. MaxSize image.Point // MinSize is the window minimum allowed dimensions. diff --git a/io/system/system.go b/io/system/system.go index e14582520..332a12803 100644 --- a/io/system/system.go +++ b/io/system/system.go @@ -24,6 +24,8 @@ type FrameEvent struct { Metric unit.Metric // Size is the dimensions of the window. Size image.Point + // Decoration size is the dimensions of the window's decoration. + DecorationSize image.Point // Insets is the insets to apply. Insets Insets // Frame completes the FrameEvent by drawing the graphical operations From 203cc9c238c3d29d2e6c70ba75192591b3f673cd Mon Sep 17 00:00:00 2001 From: tauraamui Date: Fri, 18 Mar 2022 02:09:04 +0000 Subject: [PATCH 2/2] Set decoration size on frame event and config events respectfully Signed-off-by: tauraamui --- app/window.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/window.go b/app/window.go index 4702958b4..6434aef35 100644 --- a/app/window.go +++ b/app/window.go @@ -753,7 +753,7 @@ func (w *Window) processEvent(d driver, e event.Event) { wrapper := &w.decorations.Ops wrapper.Reset() size := e2.Size // save the initial window size as the decorations will change it. - e2.FrameEvent.Size = w.decorate(d, e2.FrameEvent, wrapper) + e2.FrameEvent.Size, e2.FrameEvent.DecorationSize = w.decorate(d, e2.FrameEvent, wrapper) w.out <- e2.FrameEvent frame, gotFrame := w.waitFrame(d) ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal)) @@ -791,6 +791,7 @@ func (w *Window) processEvent(d driver, e event.Event) { w.decorations.size = image.Point{} } e2.Config.Size = e2.Config.Size.Sub(w.decorations.size) + e2.Config.DecorationSize = w.decorations.size w.out <- e2 case event.Event: if w.queue.q.Queue(e2) { @@ -856,9 +857,9 @@ func (w *Window) fallbackDecorate() bool { } // decorate the window if enabled and returns the corresponding Insets. -func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) image.Point { +func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) (image.Point, image.Point) { if !w.fallbackDecorate() { - return e.Size + return e.Size, image.Point{} } theme := w.decorations.Theme if theme == nil { @@ -906,13 +907,15 @@ func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) image.Point size := image.Point{Y: dims.Size.Y} op.Offset(f32.Point{Y: float32(size.Y)}).Add(o) appSize := e.Size.Sub(size) + decSize := w.decorations.size if w.decorations.size != size { w.decorations.size = size cnf := w.decorations.Config cnf.Size = appSize + cnf.DecorationSize = decSize w.out <- ConfigEvent{Config: cnf} } - return appSize + return appSize, decSize } // Perform the actions on the window.