Skip to content

Commit

Permalink
Set decoration size on frame event and config events respectfully
Browse files Browse the repository at this point in the history
Signed-off-by: tauraamui <[email protected]>
  • Loading branch information
tauraamui committed Mar 18, 2022
1 parent 691b812 commit 203cc9c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 203cc9c

Please sign in to comment.