1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package shm
import x "github.com/linuxdeepin/go-x11-client"
func QueryVersion(conn *x.Conn) QueryVersionCookie {
body := encodeQueryVersion()
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: QueryVersionOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return QueryVersionCookie(seq)
}
func (cookie QueryVersionCookie) Reply(conn *x.Conn) (*QueryVersionReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply QueryVersionReply
err = readQueryVersionReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func Attach(conn *x.Conn, shmSeg Seg, shmId uint32, readOnly bool) {
body := encodeAttach(shmSeg, shmId, readOnly)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AttachOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func AttachChecked(conn *x.Conn, shmSeg Seg, shmId uint32, readOnly bool) x.VoidCookie {
body := encodeAttach(shmSeg, shmId, readOnly)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: AttachOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func Detach(conn *x.Conn, shmSeg Seg) {
body := encodeDetach(shmSeg)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DetachOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func DetachChecked(conn *x.Conn, shmSeg Seg) x.VoidCookie {
body := encodeDetach(shmSeg)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: DetachOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func PutImage(conn *x.Conn, drawable x.Drawable, gc x.GContext, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight uint16, dstX, dstY int16, depth, format uint8, sendEvent bool, shmSeg Seg, offset uint32) {
body := encodePutImage(drawable, gc, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight, dstX, dstY, depth, format, sendEvent, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: PutImageOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func PutImageChecked(conn *x.Conn, drawable x.Drawable, gc x.GContext, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight uint16, dstX, dstY int16, depth, format uint8, sendEvent bool, shmSeg Seg, offset uint32) x.VoidCookie {
body := encodePutImage(drawable, gc, totalWidth, totalHeight, srcX, srcY, srcWidth, srcHeight, dstX, dstY, depth, format, sendEvent, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: PutImageOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
func GetImage(conn *x.Conn, drawable x.Drawable, X, y int16, width, height uint16, planeMask uint32, format uint8, shmSeg Seg, offset uint32) GetImageCookie {
body := encodeGetImage(drawable, X, y, width, height, planeMask, format, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
Header: x.RequestHeader{
Data: GetImageOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return GetImageCookie(seq)
}
func (cookie GetImageCookie) Reply(conn *x.Conn) (*GetImageReply, error) {
replyBuf, err := conn.WaitForReply(x.SeqNum(cookie))
if err != nil {
return nil, err
}
r := x.NewReaderFromData(replyBuf)
var reply GetImageReply
err = readGetImageReply(r, &reply)
if err != nil {
return nil, err
}
return &reply, nil
}
func CreatePixmap(conn *x.Conn, pid x.Pixmap, drawable x.Drawable, width, height uint16, depth uint8, shmSeg Seg, offset uint32) {
body := encodeCreatePixmap(pid, drawable, width, height, depth, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePixmapOpcode,
},
Body: body,
}
conn.SendRequest(0, req)
}
func CreatePixmapChecked(conn *x.Conn, pid x.Pixmap, drawable x.Drawable, width, height uint16, depth uint8, shmSeg Seg, offset uint32) x.VoidCookie {
body := encodeCreatePixmap(pid, drawable, width, height, depth, shmSeg, offset)
req := &x.ProtocolRequest{
Ext: _ext,
NoReply: true,
Header: x.RequestHeader{
Data: CreatePixmapOpcode,
},
Body: body,
}
seq := conn.SendRequest(x.RequestChecked, req)
return x.VoidCookie(seq)
}
|