From 38b293e74db6631873d5dfd74cf731eb7b76737d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:54:15 -0400 Subject: Padding on a list is on the length of the list. There was a bug where padding was being computed on each element of the list. Close #5. --- nexgb/randr/randr.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'nexgb/randr') diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go index 8891f98..9eb8dc9 100644 --- a/nexgb/randr/randr.go +++ b/nexgb/randr/randr.go @@ -295,9 +295,9 @@ func CrtcChangeListBytes(buf []byte, list []CrtcChange) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } type Mode uint32 @@ -453,11 +453,17 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } +const ( + NotifyCrtcChange = 0 + NotifyOutputChange = 1 + NotifyOutputProperty = 2 +) + // Notify is the event number for a NotifyEvent. const Notify = 1 @@ -526,12 +532,6 @@ func init() { xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew } -const ( - NotifyCrtcChange = 0 - NotifyOutputChange = 1 - NotifyOutputProperty = 2 -) - // NotifyDataUnion is a represention of the NotifyDataUnion union type. // Note that to *create* a Union, you should *never* create // this struct directly (unless you know what you're doing). @@ -809,9 +809,9 @@ func OutputChangeListBytes(buf []byte, list []OutputChange) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } type OutputProperty struct { @@ -889,9 +889,9 @@ func OutputPropertyListBytes(buf []byte, list []OutputProperty) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } type RefreshRates struct { @@ -950,9 +950,9 @@ func RefreshRatesListBytes(buf []byte, list []RefreshRates) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } // RefreshRatesListSize computes the size (bytes) of a list of RefreshRates values. @@ -1174,9 +1174,9 @@ func ScreenSizeListBytes(buf []byte, list []ScreenSize) int { for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) - b += xgb.Pad(len(structBytes)) + b += len(structBytes) } - return b + return xgb.Pad(b) } const ( -- cgit v1.2.3