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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions app/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
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
2 changes: 2 additions & 0 deletions io/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down