func (i *PrimarySelectionSource) AddCancelledHandler(f PrimarySelectionSourceCancelledHandlerFunc) {
	if f == nil {
		return
	}
	i.cancelledHandlers = append(i.cancelledHandlers, f)
}
AddCancelledHandler : adds handler for PrimarySelectionSourceCancelledEvent
package primary_selection
import (
	"reflect"
	"github.com/rajveermalviya/go-wayland/wayland/client"
	"golang.org/x/sys/unix"
)
type PrimarySelectionDeviceManager struct {
	client.BaseProxy
}
func NewPrimarySelectionDeviceManager(ctx *client.Context) *PrimarySelectionDeviceManager {
	zwpPrimarySelectionDeviceManagerV1 := &PrimarySelectionDeviceManager{}
	ctx.Register(zwpPrimarySelectionDeviceManagerV1)
	return zwpPrimarySelectionDeviceManagerV1
}
func (i *PrimarySelectionDeviceManager) CreateSource() (*PrimarySelectionSource, error) {
	id := NewPrimarySelectionSource(i.Context())
	const opcode = 0
	const rLen = 8 + 4
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(r[l:l+4], id.ID())
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return id, err
}
func (i *PrimarySelectionDeviceManager) GetDevice(seat *client.Seat) (*PrimarySelectionDevice, error) {
	id := NewPrimarySelectionDevice(i.Context())
	const opcode = 1
	const rLen = 8 + 4 + 4
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(r[l:l+4], id.ID())
	l += 4
	client.PutUint32(r[l:l+4], seat.ID())
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return id, err
}
func (i *PrimarySelectionDeviceManager) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 2
	const rLen = 8
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return err
}
type PrimarySelectionDevice struct {
	client.BaseProxy
	dataOfferHandlers []PrimarySelectionDeviceDataOfferHandlerFunc
	selectionHandlers []PrimarySelectionDeviceSelectionHandlerFunc
}
func NewPrimarySelectionDevice(ctx *client.Context) *PrimarySelectionDevice {
	zwpPrimarySelectionDeviceV1 := &PrimarySelectionDevice{}
	ctx.Register(zwpPrimarySelectionDeviceV1)
	return zwpPrimarySelectionDeviceV1
}
func (i *PrimarySelectionDevice) SetSelection(source *PrimarySelectionSource, serial uint32) error {
	const opcode = 0
	const rLen = 8 + 4 + 4
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	if source == nil {
		client.PutUint32(r[l:l+4], 0)
		l += 4
	} else {
		client.PutUint32(r[l:l+4], source.ID())
		l += 4
	}
	client.PutUint32(r[l:l+4], uint32(serial))
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return err
}
func (i *PrimarySelectionDevice) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 1
	const rLen = 8
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return err
}
type PrimarySelectionDeviceDataOfferEvent struct {
	Offer *PrimarySelectionOffer
}
type PrimarySelectionDeviceDataOfferHandlerFunc func(PrimarySelectionDeviceDataOfferEvent)
func (i *PrimarySelectionDevice) AddDataOfferHandler(f PrimarySelectionDeviceDataOfferHandlerFunc) {
	if f == nil {
		return
	}
	i.dataOfferHandlers = append(i.dataOfferHandlers, f)
}
func (i *PrimarySelectionDevice) RemoveDataOfferHandler(f PrimarySelectionDeviceDataOfferHandlerFunc) {
	for j, e := range i.dataOfferHandlers {
		if reflect.ValueOf(e).Pointer() == reflect.ValueOf(f).Pointer() {
			i.dataOfferHandlers = append(i.dataOfferHandlers[:j], i.dataOfferHandlers[j+1:]...)
			return
		}
	}
}
type PrimarySelectionDeviceSelectionEvent struct {
	Id *PrimarySelectionOffer
}
type PrimarySelectionDeviceSelectionHandlerFunc func(PrimarySelectionDeviceSelectionEvent)
func (i *PrimarySelectionDevice) AddSelectionHandler(f PrimarySelectionDeviceSelectionHandlerFunc) {
	if f == nil {
		return
	}
	i.selectionHandlers = append(i.selectionHandlers, f)
}
func (i *PrimarySelectionDevice) RemoveSelectionHandler(f PrimarySelectionDeviceSelectionHandlerFunc) {
	for j, e := range i.selectionHandlers {
		if reflect.ValueOf(e).Pointer() == reflect.ValueOf(f).Pointer() {
			i.selectionHandlers = append(i.selectionHandlers[:j], i.selectionHandlers[j+1:]...)
			return
		}
	}
}
func (i *PrimarySelectionDevice) Dispatch(opcode uint16, fd uintptr, data []byte) {
	switch opcode {
	case 0:
		if len(i.dataOfferHandlers) == 0 {
			return
		}
		var e PrimarySelectionDeviceDataOfferEvent
		l := 0
		e.Offer = i.Context().GetProxy(client.Uint32(data[l : l+4])).(*PrimarySelectionOffer)
		l += 4
		for _, f := range i.dataOfferHandlers {
			f(e)
		}
	case 1:
		if len(i.selectionHandlers) == 0 {
			return
		}
		var e PrimarySelectionDeviceSelectionEvent
		l := 0
		e.Id = i.Context().GetProxy(client.Uint32(data[l : l+4])).(*PrimarySelectionOffer)
		l += 4
		for _, f := range i.selectionHandlers {
			f(e)
		}
	}
}
type PrimarySelectionOffer struct {
	client.BaseProxy
	offerHandlers []PrimarySelectionOfferOfferHandlerFunc
}
func NewPrimarySelectionOffer(ctx *client.Context) *PrimarySelectionOffer {
	zwpPrimarySelectionOfferV1 := &PrimarySelectionOffer{}
	ctx.Register(zwpPrimarySelectionOfferV1)
	return zwpPrimarySelectionOfferV1
}
func (i *PrimarySelectionOffer) Receive(mimeType string, fd uintptr) error {
	const opcode = 0
	mimeTypeLen := client.PaddedLen(len(mimeType) + 1)
	rLen := 8 + (4 + mimeTypeLen)
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutString(r[l:l+(4+mimeTypeLen)], mimeType, mimeTypeLen)
	l += (4 + mimeTypeLen)
	oob := unix.UnixRights(int(fd))
	err := i.Context().WriteMsg(r, oob)
	return err
}
func (i *PrimarySelectionOffer) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 1
	const rLen = 8
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return err
}
type PrimarySelectionOfferOfferEvent struct {
	MimeType string
}
type PrimarySelectionOfferOfferHandlerFunc func(PrimarySelectionOfferOfferEvent)
func (i *PrimarySelectionOffer) AddOfferHandler(f PrimarySelectionOfferOfferHandlerFunc) {
	if f == nil {
		return
	}
	i.offerHandlers = append(i.offerHandlers, f)
}
func (i *PrimarySelectionOffer) RemoveOfferHandler(f PrimarySelectionOfferOfferHandlerFunc) {
	for j, e := range i.offerHandlers {
		if reflect.ValueOf(e).Pointer() == reflect.ValueOf(f).Pointer() {
			i.offerHandlers = append(i.offerHandlers[:j], i.offerHandlers[j+1:]...)
			return
		}
	}
}
func (i *PrimarySelectionOffer) Dispatch(opcode uint16, fd uintptr, data []byte) {
	switch opcode {
	case 0:
		if len(i.offerHandlers) == 0 {
			return
		}
		var e PrimarySelectionOfferOfferEvent
		l := 0
		mimeTypeLen := client.PaddedLen(int(client.Uint32(data[l : l+4])))
		l += 4
		e.MimeType = client.String(data[l : l+mimeTypeLen])
		l += mimeTypeLen
		for _, f := range i.offerHandlers {
			f(e)
		}
	}
}
type PrimarySelectionSource struct {
	client.BaseProxy
	sendHandlers      []PrimarySelectionSourceSendHandlerFunc
	cancelledHandlers []PrimarySelectionSourceCancelledHandlerFunc
}
func NewPrimarySelectionSource(ctx *client.Context) *PrimarySelectionSource {
	zwpPrimarySelectionSourceV1 := &PrimarySelectionSource{}
	ctx.Register(zwpPrimarySelectionSourceV1)
	return zwpPrimarySelectionSourceV1
}
func (i *PrimarySelectionSource) Offer(mimeType string) error {
	const opcode = 0
	mimeTypeLen := client.PaddedLen(len(mimeType) + 1)
	rLen := 8 + (4 + mimeTypeLen)
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutString(r[l:l+(4+mimeTypeLen)], mimeType, mimeTypeLen)
	l += (4 + mimeTypeLen)
	err := i.Context().WriteMsg(r, nil)
	return err
}
func (i *PrimarySelectionSource) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 1
	const rLen = 8
	r := make([]byte, rLen)
	l := 0
	client.PutUint32(r[l:4], i.ID())
	l += 4
	client.PutUint32(r[l:l+4], uint32(rLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(r, nil)
	return err
}
type PrimarySelectionSourceSendEvent struct {
	MimeType string
	Fd       uintptr
}
type PrimarySelectionSourceSendHandlerFunc func(PrimarySelectionSourceSendEvent)
func (i *PrimarySelectionSource) AddSendHandler(f PrimarySelectionSourceSendHandlerFunc) {
	if f == nil {
		return
	}
	i.sendHandlers = append(i.sendHandlers, f)
}
func (i *PrimarySelectionSource) RemoveSendHandler(f PrimarySelectionSourceSendHandlerFunc) {
	for j, e := range i.sendHandlers {
		if reflect.ValueOf(e).Pointer() == reflect.ValueOf(f).Pointer() {
			i.sendHandlers = append(i.sendHandlers[:j], i.sendHandlers[j+1:]...)
			return
		}
	}
}
type PrimarySelectionSourceCancelledEvent struct{}
type PrimarySelectionSourceCancelledHandlerFunc func(PrimarySelectionSourceCancelledEvent)