Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[app,io] Feature/make decoration size available to consumer #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set decoration size on frame event and config events respectfully
Signed-off-by: tauraamui <[email protected]>
  • Loading branch information
tauraamui committed Mar 18, 2022
commit 203cc9c238c3d29d2e6c70ba75192591b3f673cd
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