app: clip client area

On Wayland, app.Window provides fallback window decorations but clients
are not prohibited from drawing over the decorations or capturing events.
This change adds a clip operation to ensure no unwanted interaction between
client content and decorations.

Fixes issue described in

https://lists.sr.ht/~eliasnaur/gio/%3C092fa6a19894af3306fab568fb919c965e98c4da.camel%40gmail.com%3E

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-04 10:56:01 +02:00
parent bd7f50438a
commit f07537335a
+3
View File
@@ -25,6 +25,7 @@ import (
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
@@ -799,7 +800,9 @@ func (w *Window) processEvent(d driver, e event.Event) {
e2.FrameEvent.Size = w.decorate(d, e2.FrameEvent, wrapper)
w.out <- e2.FrameEvent
frame, gotFrame := w.waitFrame(d)
cl := clip.Rect(image.Rectangle{Max: e2.FrameEvent.Size}).Push(wrapper)
ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal))
cl.Pop()
err := w.validateAndProcess(d, size, e2.Sync, wrapper)
if gotFrame {
// We're done with frame, let the client continue.