forked from joejulian/gio
io/pointer,io/router: [API] make pass-through a property of AreaOp
We're about to make operation scopes explicit, which would result in both AreaOp and PassOp be scoped. However, PassOp seems to light to have its separate stack, so this change instead makes pass-through a property of an area. We're assuming that clients that want pass-through are also aware of the affected hit area. API change: replace PassOps with the AreaOp.PassThrough field. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+11
-17
@@ -46,6 +46,10 @@ type Event struct {
|
||||
// hit area and the area. The area is transformed before applying
|
||||
// it.
|
||||
type AreaOp struct {
|
||||
// PassThrough areas and their children don't block events to siblings
|
||||
// them.
|
||||
PassThrough bool
|
||||
|
||||
kind areaKind
|
||||
rect image.Rectangle
|
||||
}
|
||||
@@ -72,11 +76,6 @@ type InputOp struct {
|
||||
ScrollBounds image.Rectangle
|
||||
}
|
||||
|
||||
// PassOp sets the pass-through mode.
|
||||
type PassOp struct {
|
||||
Pass bool
|
||||
}
|
||||
|
||||
type ID uint16
|
||||
|
||||
// Type of an Event.
|
||||
@@ -190,11 +189,14 @@ func (op AreaOp) Add(o *op.Ops) {
|
||||
data := o.Write(opconst.TypeAreaLen)
|
||||
data[0] = byte(opconst.TypeArea)
|
||||
data[1] = byte(op.kind)
|
||||
if op.PassThrough {
|
||||
data[2] = 1
|
||||
}
|
||||
bo := binary.LittleEndian
|
||||
bo.PutUint32(data[2:], uint32(op.rect.Min.X))
|
||||
bo.PutUint32(data[6:], uint32(op.rect.Min.Y))
|
||||
bo.PutUint32(data[10:], uint32(op.rect.Max.X))
|
||||
bo.PutUint32(data[14:], uint32(op.rect.Max.Y))
|
||||
bo.PutUint32(data[3:], uint32(op.rect.Min.X))
|
||||
bo.PutUint32(data[7:], uint32(op.rect.Min.Y))
|
||||
bo.PutUint32(data[11:], uint32(op.rect.Max.X))
|
||||
bo.PutUint32(data[15:], uint32(op.rect.Max.Y))
|
||||
}
|
||||
|
||||
func (op CursorNameOp) Add(o *op.Ops) {
|
||||
@@ -223,14 +225,6 @@ func (op InputOp) Add(o *op.Ops) {
|
||||
bo.PutUint32(data[15:], uint32(op.ScrollBounds.Max.Y))
|
||||
}
|
||||
|
||||
func (op PassOp) Add(o *op.Ops) {
|
||||
data := o.Write(opconst.TypePassLen)
|
||||
data[0] = byte(opconst.TypePass)
|
||||
if op.Pass {
|
||||
data[1] = 1
|
||||
}
|
||||
}
|
||||
|
||||
func (t Type) String() string {
|
||||
switch t {
|
||||
case Press:
|
||||
|
||||
Reference in New Issue
Block a user