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

Fix EventCopy.Write() #7

Merged
merged 2 commits into from
May 1, 2022
Merged
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
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