Skip to content

Commit

Permalink
Merge pull request #7 from woofdoggo/patch-eventcopy
Browse files Browse the repository at this point in the history
- Fixed EventCopy.Write() in xgbgen to write the type of the event rather than keep the type of the event it is derived from
- Regenerated bindings from xcbproto 1.11
  • Loading branch information
jezek authored May 1, 2022
2 parents 7a4fade + 500d370 commit 7effddc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion xgbgen/go_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ func (e *EventCopy) Read(c *Context) {
func (e *EventCopy) Write(c *Context) {
c.Putln("// Bytes writes a %s value to a byte slice.", e.EvType())
c.Putln("func (v %s) Bytes() []byte {", e.EvType())
c.Putln("return %s(v).Bytes()", e.Old.(*Event).EvType())
c.Putln("buf := %s(v).Bytes()", e.Old.(*Event).EvType())
c.Putln("buf[0] = %d", e.Number)
c.Putln("return buf")
c.Putln("}")
c.Putln("")
}
Expand Down
20 changes: 15 additions & 5 deletions xproto/xproto.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ func ButtonReleaseEventNew(buf []byte) xgb.Event {

// Bytes writes a ButtonReleaseEvent value to a byte slice.
func (v ButtonReleaseEvent) Bytes() []byte {
return ButtonPressEvent(v).Bytes()
buf := ButtonPressEvent(v).Bytes()
buf[0] = 5
return buf
}

// SequenceId returns the sequence id attached to the ButtonRelease event.
Expand Down Expand Up @@ -806,7 +808,9 @@ func CirculateRequestEventNew(buf []byte) xgb.Event {

// Bytes writes a CirculateRequestEvent value to a byte slice.
func (v CirculateRequestEvent) Bytes() []byte {
return CirculateNotifyEvent(v).Bytes()
buf := CirculateNotifyEvent(v).Bytes()
buf[0] = 27
return buf
}

// SequenceId returns the sequence id attached to the CirculateRequest event.
Expand Down Expand Up @@ -2441,7 +2445,9 @@ func FocusOutEventNew(buf []byte) xgb.Event {

// Bytes writes a FocusOutEvent value to a byte slice.
func (v FocusOutEvent) Bytes() []byte {
return FocusInEvent(v).Bytes()
buf := FocusInEvent(v).Bytes()
buf[0] = 10
return buf
}

// SequenceId returns the sequence id attached to the FocusOut event.
Expand Down Expand Up @@ -3412,7 +3418,9 @@ func KeyReleaseEventNew(buf []byte) xgb.Event {

// Bytes writes a KeyReleaseEvent value to a byte slice.
func (v KeyReleaseEvent) Bytes() []byte {
return KeyPressEvent(v).Bytes()
buf := KeyPressEvent(v).Bytes()
buf[0] = 3
return buf
}

// SequenceId returns the sequence id attached to the KeyRelease event.
Expand Down Expand Up @@ -3514,7 +3522,9 @@ func LeaveNotifyEventNew(buf []byte) xgb.Event {

// Bytes writes a LeaveNotifyEvent value to a byte slice.
func (v LeaveNotifyEvent) Bytes() []byte {
return EnterNotifyEvent(v).Bytes()
buf := EnterNotifyEvent(v).Bytes()
buf[0] = 8
return buf
}

// SequenceId returns the sequence id attached to the LeaveNotify event.
Expand Down

0 comments on commit 7effddc

Please sign in to comment.