mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 07:57:29 +00:00
io/pointer: re-introduce PassOp
A previous change merged PassOp with AreaOp under the assumption that
the pass mode would be set on a particular area. That assumption turns
out not to hold, so this change brings back PassOp as an independent
stack operation.
This is an API change: replace AreaOp{Pass: true} with a separate
pointer.PassOp operation.
Fixes gio#288
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+32
-14
@@ -42,14 +42,9 @@ type Event struct {
|
||||
Modifiers key.Modifiers
|
||||
}
|
||||
|
||||
// AreaOp updates the hit area to the intersection of the current
|
||||
// hit area and the area. The area is transformed before applying
|
||||
// it.
|
||||
// AreaOp pushes the current hit area to the stack and updates it to the
|
||||
// intersection of the current hit area and the transformed area.
|
||||
type AreaOp struct {
|
||||
// PassThrough areas and their children don't block events to siblings
|
||||
// them.
|
||||
PassThrough bool
|
||||
|
||||
kind areaKind
|
||||
rect image.Rectangle
|
||||
}
|
||||
@@ -61,6 +56,18 @@ type AreaStack struct {
|
||||
macroID int
|
||||
}
|
||||
|
||||
// PassOp sets the pass-through mode. AreaOps added while the pass-through
|
||||
// mode is set don't block events to siblings.
|
||||
type PassOp struct {
|
||||
}
|
||||
|
||||
// PassStack represents a PassOp on the pass stack.
|
||||
type PassStack struct {
|
||||
ops *ops.Ops
|
||||
id ops.StackID
|
||||
macroID int
|
||||
}
|
||||
|
||||
// CursorNameOp sets the cursor for the current area.
|
||||
type CursorNameOp struct {
|
||||
Name CursorName
|
||||
@@ -204,14 +211,11 @@ func (a AreaOp) add(o *op.Ops, push bool) {
|
||||
data := o.Internal.Write(ops.TypeAreaLen)
|
||||
data[0] = byte(ops.TypeArea)
|
||||
data[1] = byte(a.kind)
|
||||
if a.PassThrough {
|
||||
data[2] = 1
|
||||
}
|
||||
bo := binary.LittleEndian
|
||||
bo.PutUint32(data[3:], uint32(a.rect.Min.X))
|
||||
bo.PutUint32(data[7:], uint32(a.rect.Min.Y))
|
||||
bo.PutUint32(data[11:], uint32(a.rect.Max.X))
|
||||
bo.PutUint32(data[15:], uint32(a.rect.Max.Y))
|
||||
bo.PutUint32(data[2:], uint32(a.rect.Min.X))
|
||||
bo.PutUint32(data[6:], uint32(a.rect.Min.Y))
|
||||
bo.PutUint32(data[10:], uint32(a.rect.Max.X))
|
||||
bo.PutUint32(data[14:], uint32(a.rect.Max.Y))
|
||||
}
|
||||
|
||||
func (o AreaStack) Pop() {
|
||||
@@ -220,6 +224,20 @@ func (o AreaStack) Pop() {
|
||||
data[0] = byte(ops.TypePopArea)
|
||||
}
|
||||
|
||||
// Push the current pass mode to the pass stack and set the pass mode.
|
||||
func (p PassOp) Push(o *op.Ops) PassStack {
|
||||
id, mid := o.Internal.PushOp(ops.PassStack)
|
||||
data := o.Internal.Write(ops.TypePassLen)
|
||||
data[0] = byte(ops.TypePass)
|
||||
return PassStack{ops: &o.Internal, id: id, macroID: mid}
|
||||
}
|
||||
|
||||
func (p PassStack) Pop() {
|
||||
p.ops.PopOp(ops.PassStack, p.id, p.macroID)
|
||||
data := p.ops.Write(ops.TypePopPassLen)
|
||||
data[0] = byte(ops.TypePopPass)
|
||||
}
|
||||
|
||||
func (op CursorNameOp) Add(o *op.Ops) {
|
||||
data := o.Internal.Write1(ops.TypeCursorLen, op.Name)
|
||||
data[0] = byte(ops.TypeCursor)
|
||||
|
||||
Reference in New Issue
Block a user