| 1 |
// Package composite is the X client API for the Composite extension. |
| 2 |
package composite |
| 3 |
|
| 4 |
// This file is automatically generated from composite.xml. Edit at your peril! |
| 5 |
|
| 6 |
import ( |
| 7 |
"github.com/BurntSushi/xgb" |
| 8 |
|
| 9 |
"github.com/BurntSushi/xgb/xfixes" |
| 10 |
"github.com/BurntSushi/xgb/xproto" |
| 11 |
) |
| 12 |
|
| 13 |
// Init must be called before using the Composite extension. |
| 14 |
func Init(c *xgb.Conn) error { |
| 15 |
reply, err := xproto.QueryExtension(c, 9, "Composite").Reply() |
| 16 |
switch { |
| 17 |
case err != nil: |
| 18 |
return err |
| 19 |
case !reply.Present: |
| 20 |
return xgb.Errorf("No extension named Composite could be found on on the server.") |
| 21 |
} |
| 22 |
|
| 23 |
c.ExtLock.Lock() |
| 24 |
c.Extensions["Composite"] = reply.MajorOpcode |
| 25 |
c.ExtLock.Unlock() |
| 26 |
for evNum, fun := range xgb.NewExtEventFuncs["Composite"] { |
| 27 |
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun |
| 28 |
} |
| 29 |
for errNum, fun := range xgb.NewExtErrorFuncs["Composite"] { |
| 30 |
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun |
| 31 |
} |
| 32 |
return nil |
| 33 |
} |
| 34 |
|
| 35 |
func init() { |
| 36 |
xgb.NewExtEventFuncs["Composite"] = make(map[int]xgb.NewEventFun) |
| 37 |
xgb.NewExtErrorFuncs["Composite"] = make(map[int]xgb.NewErrorFun) |
| 38 |
} |
| 39 |
|
| 40 |
const ( |
| 41 |
RedirectAutomatic = 0 |
| 42 |
RedirectManual = 1 |
| 43 |
) |
| 44 |
|
| 45 |
// Skipping definition for base type 'Bool' |
| 46 |
|
| 47 |
// Skipping definition for base type 'Byte' |
| 48 |
|
| 49 |
// Skipping definition for base type 'Card8' |
| 50 |
|
| 51 |
// Skipping definition for base type 'Char' |
| 52 |
|
| 53 |
// Skipping definition for base type 'Void' |
| 54 |
|
| 55 |
// Skipping definition for base type 'Double' |
| 56 |
|
| 57 |
// Skipping definition for base type 'Float' |
| 58 |
|
| 59 |
// Skipping definition for base type 'Int16' |
| 60 |
|
| 61 |
// Skipping definition for base type 'Int32' |
| 62 |
|
| 63 |
// Skipping definition for base type 'Int8' |
| 64 |
|
| 65 |
// Skipping definition for base type 'Card16' |
| 66 |
|
| 67 |
// Skipping definition for base type 'Card32' |
| 68 |
|
| 69 |
// CreateRegionFromBorderClipCookie is a cookie used only for CreateRegionFromBorderClip requests. |
| 70 |
type CreateRegionFromBorderClipCookie struct { |
| 71 |
*xgb.Cookie |
| 72 |
} |
| 73 |
|
| 74 |
// CreateRegionFromBorderClip sends an unchecked request. |
| 75 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 76 |
func CreateRegionFromBorderClip(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { |
| 77 |
c.ExtLock.RLock() |
| 78 |
defer c.ExtLock.RUnlock() |
| 79 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 80 |
panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 81 |
} |
| 82 |
cookie := c.NewCookie(false, false) |
| 83 |
c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) |
| 84 |
return CreateRegionFromBorderClipCookie{cookie} |
| 85 |
} |
| 86 |
|
| 87 |
// CreateRegionFromBorderClipChecked sends a checked request. |
| 88 |
// If an error occurs, it can be retrieved using CreateRegionFromBorderClipCookie.Check() |
| 89 |
func CreateRegionFromBorderClipChecked(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) CreateRegionFromBorderClipCookie { |
| 90 |
c.ExtLock.RLock() |
| 91 |
defer c.ExtLock.RUnlock() |
| 92 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 93 |
panic("Cannot issue request 'CreateRegionFromBorderClip' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 94 |
} |
| 95 |
cookie := c.NewCookie(true, false) |
| 96 |
c.NewRequest(createRegionFromBorderClipRequest(c, Region, Window), cookie) |
| 97 |
return CreateRegionFromBorderClipCookie{cookie} |
| 98 |
} |
| 99 |
|
| 100 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 101 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 102 |
func (cook CreateRegionFromBorderClipCookie) Check() error { |
| 103 |
return cook.Cookie.Check() |
| 104 |
} |
| 105 |
|
| 106 |
// Write request to wire for CreateRegionFromBorderClip |
| 107 |
// createRegionFromBorderClipRequest writes a CreateRegionFromBorderClip request to a byte slice. |
| 108 |
func createRegionFromBorderClipRequest(c *xgb.Conn, Region xfixes.Region, Window xproto.Window) []byte { |
| 109 |
size := 12 |
| 110 |
b := 0 |
| 111 |
buf := make([]byte, size) |
| 112 |
|
| 113 |
c.ExtLock.RLock() |
| 114 |
buf[b] = c.Extensions["Composite"] |
| 115 |
c.ExtLock.RUnlock() |
| 116 |
b += 1 |
| 117 |
|
| 118 |
buf[b] = 5 // request opcode |
| 119 |
b += 1 |
| 120 |
|
| 121 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 122 |
b += 2 |
| 123 |
|
| 124 |
xgb.Put32(buf[b:], uint32(Region)) |
| 125 |
b += 4 |
| 126 |
|
| 127 |
xgb.Put32(buf[b:], uint32(Window)) |
| 128 |
b += 4 |
| 129 |
|
| 130 |
return buf |
| 131 |
} |
| 132 |
|
| 133 |
// GetOverlayWindowCookie is a cookie used only for GetOverlayWindow requests. |
| 134 |
type GetOverlayWindowCookie struct { |
| 135 |
*xgb.Cookie |
| 136 |
} |
| 137 |
|
| 138 |
// GetOverlayWindow sends a checked request. |
| 139 |
// If an error occurs, it will be returned with the reply by calling GetOverlayWindowCookie.Reply() |
| 140 |
func GetOverlayWindow(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { |
| 141 |
c.ExtLock.RLock() |
| 142 |
defer c.ExtLock.RUnlock() |
| 143 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 144 |
panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 145 |
} |
| 146 |
cookie := c.NewCookie(true, true) |
| 147 |
c.NewRequest(getOverlayWindowRequest(c, Window), cookie) |
| 148 |
return GetOverlayWindowCookie{cookie} |
| 149 |
} |
| 150 |
|
| 151 |
// GetOverlayWindowUnchecked sends an unchecked request. |
| 152 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 153 |
func GetOverlayWindowUnchecked(c *xgb.Conn, Window xproto.Window) GetOverlayWindowCookie { |
| 154 |
c.ExtLock.RLock() |
| 155 |
defer c.ExtLock.RUnlock() |
| 156 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 157 |
panic("Cannot issue request 'GetOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 158 |
} |
| 159 |
cookie := c.NewCookie(false, true) |
| 160 |
c.NewRequest(getOverlayWindowRequest(c, Window), cookie) |
| 161 |
return GetOverlayWindowCookie{cookie} |
| 162 |
} |
| 163 |
|
| 164 |
// GetOverlayWindowReply represents the data returned from a GetOverlayWindow request. |
| 165 |
type GetOverlayWindowReply struct { |
| 166 |
Sequence uint16 // sequence number of the request for this reply |
| 167 |
Length uint32 // number of bytes in this reply |
| 168 |
// padding: 1 bytes |
| 169 |
OverlayWin xproto.Window |
| 170 |
// padding: 20 bytes |
| 171 |
} |
| 172 |
|
| 173 |
// Reply blocks and returns the reply data for a GetOverlayWindow request. |
| 174 |
func (cook GetOverlayWindowCookie) Reply() (*GetOverlayWindowReply, error) { |
| 175 |
buf, err := cook.Cookie.Reply() |
| 176 |
if err != nil { |
| 177 |
return nil, err |
| 178 |
} |
| 179 |
if buf == nil { |
| 180 |
return nil, nil |
| 181 |
} |
| 182 |
return getOverlayWindowReply(buf), nil |
| 183 |
} |
| 184 |
|
| 185 |
// getOverlayWindowReply reads a byte slice into a GetOverlayWindowReply value. |
| 186 |
func getOverlayWindowReply(buf []byte) *GetOverlayWindowReply { |
| 187 |
v := new(GetOverlayWindowReply) |
| 188 |
b := 1 // skip reply determinant |
| 189 |
|
| 190 |
b += 1 // padding |
| 191 |
|
| 192 |
v.Sequence = xgb.Get16(buf[b:]) |
| 193 |
b += 2 |
| 194 |
|
| 195 |
v.Length = xgb.Get32(buf[b:]) // 4-byte units |
| 196 |
b += 4 |
| 197 |
|
| 198 |
v.OverlayWin = xproto.Window(xgb.Get32(buf[b:])) |
| 199 |
b += 4 |
| 200 |
|
| 201 |
b += 20 // padding |
| 202 |
|
| 203 |
return v |
| 204 |
} |
| 205 |
|
| 206 |
// Write request to wire for GetOverlayWindow |
| 207 |
// getOverlayWindowRequest writes a GetOverlayWindow request to a byte slice. |
| 208 |
func getOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { |
| 209 |
size := 8 |
| 210 |
b := 0 |
| 211 |
buf := make([]byte, size) |
| 212 |
|
| 213 |
c.ExtLock.RLock() |
| 214 |
buf[b] = c.Extensions["Composite"] |
| 215 |
c.ExtLock.RUnlock() |
| 216 |
b += 1 |
| 217 |
|
| 218 |
buf[b] = 7 // request opcode |
| 219 |
b += 1 |
| 220 |
|
| 221 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 222 |
b += 2 |
| 223 |
|
| 224 |
xgb.Put32(buf[b:], uint32(Window)) |
| 225 |
b += 4 |
| 226 |
|
| 227 |
return buf |
| 228 |
} |
| 229 |
|
| 230 |
// NameWindowPixmapCookie is a cookie used only for NameWindowPixmap requests. |
| 231 |
type NameWindowPixmapCookie struct { |
| 232 |
*xgb.Cookie |
| 233 |
} |
| 234 |
|
| 235 |
// NameWindowPixmap sends an unchecked request. |
| 236 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 237 |
func NameWindowPixmap(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { |
| 238 |
c.ExtLock.RLock() |
| 239 |
defer c.ExtLock.RUnlock() |
| 240 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 241 |
panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 242 |
} |
| 243 |
cookie := c.NewCookie(false, false) |
| 244 |
c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) |
| 245 |
return NameWindowPixmapCookie{cookie} |
| 246 |
} |
| 247 |
|
| 248 |
// NameWindowPixmapChecked sends a checked request. |
| 249 |
// If an error occurs, it can be retrieved using NameWindowPixmapCookie.Check() |
| 250 |
func NameWindowPixmapChecked(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) NameWindowPixmapCookie { |
| 251 |
c.ExtLock.RLock() |
| 252 |
defer c.ExtLock.RUnlock() |
| 253 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 254 |
panic("Cannot issue request 'NameWindowPixmap' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 255 |
} |
| 256 |
cookie := c.NewCookie(true, false) |
| 257 |
c.NewRequest(nameWindowPixmapRequest(c, Window, Pixmap), cookie) |
| 258 |
return NameWindowPixmapCookie{cookie} |
| 259 |
} |
| 260 |
|
| 261 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 262 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 263 |
func (cook NameWindowPixmapCookie) Check() error { |
| 264 |
return cook.Cookie.Check() |
| 265 |
} |
| 266 |
|
| 267 |
// Write request to wire for NameWindowPixmap |
| 268 |
// nameWindowPixmapRequest writes a NameWindowPixmap request to a byte slice. |
| 269 |
func nameWindowPixmapRequest(c *xgb.Conn, Window xproto.Window, Pixmap xproto.Pixmap) []byte { |
| 270 |
size := 12 |
| 271 |
b := 0 |
| 272 |
buf := make([]byte, size) |
| 273 |
|
| 274 |
c.ExtLock.RLock() |
| 275 |
buf[b] = c.Extensions["Composite"] |
| 276 |
c.ExtLock.RUnlock() |
| 277 |
b += 1 |
| 278 |
|
| 279 |
buf[b] = 6 // request opcode |
| 280 |
b += 1 |
| 281 |
|
| 282 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 283 |
b += 2 |
| 284 |
|
| 285 |
xgb.Put32(buf[b:], uint32(Window)) |
| 286 |
b += 4 |
| 287 |
|
| 288 |
xgb.Put32(buf[b:], uint32(Pixmap)) |
| 289 |
b += 4 |
| 290 |
|
| 291 |
return buf |
| 292 |
} |
| 293 |
|
| 294 |
// QueryVersionCookie is a cookie used only for QueryVersion requests. |
| 295 |
type QueryVersionCookie struct { |
| 296 |
*xgb.Cookie |
| 297 |
} |
| 298 |
|
| 299 |
// QueryVersion sends a checked request. |
| 300 |
// If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() |
| 301 |
func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { |
| 302 |
c.ExtLock.RLock() |
| 303 |
defer c.ExtLock.RUnlock() |
| 304 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 305 |
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 306 |
} |
| 307 |
cookie := c.NewCookie(true, true) |
| 308 |
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) |
| 309 |
return QueryVersionCookie{cookie} |
| 310 |
} |
| 311 |
|
| 312 |
// QueryVersionUnchecked sends an unchecked request. |
| 313 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 314 |
func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { |
| 315 |
c.ExtLock.RLock() |
| 316 |
defer c.ExtLock.RUnlock() |
| 317 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 318 |
panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 319 |
} |
| 320 |
cookie := c.NewCookie(false, true) |
| 321 |
c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) |
| 322 |
return QueryVersionCookie{cookie} |
| 323 |
} |
| 324 |
|
| 325 |
// QueryVersionReply represents the data returned from a QueryVersion request. |
| 326 |
type QueryVersionReply struct { |
| 327 |
Sequence uint16 // sequence number of the request for this reply |
| 328 |
Length uint32 // number of bytes in this reply |
| 329 |
// padding: 1 bytes |
| 330 |
MajorVersion uint32 |
| 331 |
MinorVersion uint32 |
| 332 |
// padding: 16 bytes |
| 333 |
} |
| 334 |
|
| 335 |
// Reply blocks and returns the reply data for a QueryVersion request. |
| 336 |
func (cook QueryVersionCookie) Reply() (*QueryVersionReply, error) { |
| 337 |
buf, err := cook.Cookie.Reply() |
| 338 |
if err != nil { |
| 339 |
return nil, err |
| 340 |
} |
| 341 |
if buf == nil { |
| 342 |
return nil, nil |
| 343 |
} |
| 344 |
return queryVersionReply(buf), nil |
| 345 |
} |
| 346 |
|
| 347 |
// queryVersionReply reads a byte slice into a QueryVersionReply value. |
| 348 |
func queryVersionReply(buf []byte) *QueryVersionReply { |
| 349 |
v := new(QueryVersionReply) |
| 350 |
b := 1 // skip reply determinant |
| 351 |
|
| 352 |
b += 1 // padding |
| 353 |
|
| 354 |
v.Sequence = xgb.Get16(buf[b:]) |
| 355 |
b += 2 |
| 356 |
|
| 357 |
v.Length = xgb.Get32(buf[b:]) // 4-byte units |
| 358 |
b += 4 |
| 359 |
|
| 360 |
v.MajorVersion = xgb.Get32(buf[b:]) |
| 361 |
b += 4 |
| 362 |
|
| 363 |
v.MinorVersion = xgb.Get32(buf[b:]) |
| 364 |
b += 4 |
| 365 |
|
| 366 |
b += 16 // padding |
| 367 |
|
| 368 |
return v |
| 369 |
} |
| 370 |
|
| 371 |
// Write request to wire for QueryVersion |
| 372 |
// queryVersionRequest writes a QueryVersion request to a byte slice. |
| 373 |
func queryVersionRequest(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) []byte { |
| 374 |
size := 12 |
| 375 |
b := 0 |
| 376 |
buf := make([]byte, size) |
| 377 |
|
| 378 |
c.ExtLock.RLock() |
| 379 |
buf[b] = c.Extensions["Composite"] |
| 380 |
c.ExtLock.RUnlock() |
| 381 |
b += 1 |
| 382 |
|
| 383 |
buf[b] = 0 // request opcode |
| 384 |
b += 1 |
| 385 |
|
| 386 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 387 |
b += 2 |
| 388 |
|
| 389 |
xgb.Put32(buf[b:], ClientMajorVersion) |
| 390 |
b += 4 |
| 391 |
|
| 392 |
xgb.Put32(buf[b:], ClientMinorVersion) |
| 393 |
b += 4 |
| 394 |
|
| 395 |
return buf |
| 396 |
} |
| 397 |
|
| 398 |
// RedirectSubwindowsCookie is a cookie used only for RedirectSubwindows requests. |
| 399 |
type RedirectSubwindowsCookie struct { |
| 400 |
*xgb.Cookie |
| 401 |
} |
| 402 |
|
| 403 |
// RedirectSubwindows sends an unchecked request. |
| 404 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 405 |
func RedirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { |
| 406 |
c.ExtLock.RLock() |
| 407 |
defer c.ExtLock.RUnlock() |
| 408 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 409 |
panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 410 |
} |
| 411 |
cookie := c.NewCookie(false, false) |
| 412 |
c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) |
| 413 |
return RedirectSubwindowsCookie{cookie} |
| 414 |
} |
| 415 |
|
| 416 |
// RedirectSubwindowsChecked sends a checked request. |
| 417 |
// If an error occurs, it can be retrieved using RedirectSubwindowsCookie.Check() |
| 418 |
func RedirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectSubwindowsCookie { |
| 419 |
c.ExtLock.RLock() |
| 420 |
defer c.ExtLock.RUnlock() |
| 421 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 422 |
panic("Cannot issue request 'RedirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 423 |
} |
| 424 |
cookie := c.NewCookie(true, false) |
| 425 |
c.NewRequest(redirectSubwindowsRequest(c, Window, Update), cookie) |
| 426 |
return RedirectSubwindowsCookie{cookie} |
| 427 |
} |
| 428 |
|
| 429 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 430 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 431 |
func (cook RedirectSubwindowsCookie) Check() error { |
| 432 |
return cook.Cookie.Check() |
| 433 |
} |
| 434 |
|
| 435 |
// Write request to wire for RedirectSubwindows |
| 436 |
// redirectSubwindowsRequest writes a RedirectSubwindows request to a byte slice. |
| 437 |
func redirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { |
| 438 |
size := 12 |
| 439 |
b := 0 |
| 440 |
buf := make([]byte, size) |
| 441 |
|
| 442 |
c.ExtLock.RLock() |
| 443 |
buf[b] = c.Extensions["Composite"] |
| 444 |
c.ExtLock.RUnlock() |
| 445 |
b += 1 |
| 446 |
|
| 447 |
buf[b] = 2 // request opcode |
| 448 |
b += 1 |
| 449 |
|
| 450 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 451 |
b += 2 |
| 452 |
|
| 453 |
xgb.Put32(buf[b:], uint32(Window)) |
| 454 |
b += 4 |
| 455 |
|
| 456 |
buf[b] = Update |
| 457 |
b += 1 |
| 458 |
|
| 459 |
b += 3 // padding |
| 460 |
|
| 461 |
return buf |
| 462 |
} |
| 463 |
|
| 464 |
// RedirectWindowCookie is a cookie used only for RedirectWindow requests. |
| 465 |
type RedirectWindowCookie struct { |
| 466 |
*xgb.Cookie |
| 467 |
} |
| 468 |
|
| 469 |
// RedirectWindow sends an unchecked request. |
| 470 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 471 |
func RedirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { |
| 472 |
c.ExtLock.RLock() |
| 473 |
defer c.ExtLock.RUnlock() |
| 474 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 475 |
panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 476 |
} |
| 477 |
cookie := c.NewCookie(false, false) |
| 478 |
c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) |
| 479 |
return RedirectWindowCookie{cookie} |
| 480 |
} |
| 481 |
|
| 482 |
// RedirectWindowChecked sends a checked request. |
| 483 |
// If an error occurs, it can be retrieved using RedirectWindowCookie.Check() |
| 484 |
func RedirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) RedirectWindowCookie { |
| 485 |
c.ExtLock.RLock() |
| 486 |
defer c.ExtLock.RUnlock() |
| 487 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 488 |
panic("Cannot issue request 'RedirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 489 |
} |
| 490 |
cookie := c.NewCookie(true, false) |
| 491 |
c.NewRequest(redirectWindowRequest(c, Window, Update), cookie) |
| 492 |
return RedirectWindowCookie{cookie} |
| 493 |
} |
| 494 |
|
| 495 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 496 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 497 |
func (cook RedirectWindowCookie) Check() error { |
| 498 |
return cook.Cookie.Check() |
| 499 |
} |
| 500 |
|
| 501 |
// Write request to wire for RedirectWindow |
| 502 |
// redirectWindowRequest writes a RedirectWindow request to a byte slice. |
| 503 |
func redirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { |
| 504 |
size := 12 |
| 505 |
b := 0 |
| 506 |
buf := make([]byte, size) |
| 507 |
|
| 508 |
c.ExtLock.RLock() |
| 509 |
buf[b] = c.Extensions["Composite"] |
| 510 |
c.ExtLock.RUnlock() |
| 511 |
b += 1 |
| 512 |
|
| 513 |
buf[b] = 1 // request opcode |
| 514 |
b += 1 |
| 515 |
|
| 516 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 517 |
b += 2 |
| 518 |
|
| 519 |
xgb.Put32(buf[b:], uint32(Window)) |
| 520 |
b += 4 |
| 521 |
|
| 522 |
buf[b] = Update |
| 523 |
b += 1 |
| 524 |
|
| 525 |
b += 3 // padding |
| 526 |
|
| 527 |
return buf |
| 528 |
} |
| 529 |
|
| 530 |
// ReleaseOverlayWindowCookie is a cookie used only for ReleaseOverlayWindow requests. |
| 531 |
type ReleaseOverlayWindowCookie struct { |
| 532 |
*xgb.Cookie |
| 533 |
} |
| 534 |
|
| 535 |
// ReleaseOverlayWindow sends an unchecked request. |
| 536 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 537 |
func ReleaseOverlayWindow(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { |
| 538 |
c.ExtLock.RLock() |
| 539 |
defer c.ExtLock.RUnlock() |
| 540 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 541 |
panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 542 |
} |
| 543 |
cookie := c.NewCookie(false, false) |
| 544 |
c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) |
| 545 |
return ReleaseOverlayWindowCookie{cookie} |
| 546 |
} |
| 547 |
|
| 548 |
// ReleaseOverlayWindowChecked sends a checked request. |
| 549 |
// If an error occurs, it can be retrieved using ReleaseOverlayWindowCookie.Check() |
| 550 |
func ReleaseOverlayWindowChecked(c *xgb.Conn, Window xproto.Window) ReleaseOverlayWindowCookie { |
| 551 |
c.ExtLock.RLock() |
| 552 |
defer c.ExtLock.RUnlock() |
| 553 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 554 |
panic("Cannot issue request 'ReleaseOverlayWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 555 |
} |
| 556 |
cookie := c.NewCookie(true, false) |
| 557 |
c.NewRequest(releaseOverlayWindowRequest(c, Window), cookie) |
| 558 |
return ReleaseOverlayWindowCookie{cookie} |
| 559 |
} |
| 560 |
|
| 561 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 562 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 563 |
func (cook ReleaseOverlayWindowCookie) Check() error { |
| 564 |
return cook.Cookie.Check() |
| 565 |
} |
| 566 |
|
| 567 |
// Write request to wire for ReleaseOverlayWindow |
| 568 |
// releaseOverlayWindowRequest writes a ReleaseOverlayWindow request to a byte slice. |
| 569 |
func releaseOverlayWindowRequest(c *xgb.Conn, Window xproto.Window) []byte { |
| 570 |
size := 8 |
| 571 |
b := 0 |
| 572 |
buf := make([]byte, size) |
| 573 |
|
| 574 |
c.ExtLock.RLock() |
| 575 |
buf[b] = c.Extensions["Composite"] |
| 576 |
c.ExtLock.RUnlock() |
| 577 |
b += 1 |
| 578 |
|
| 579 |
buf[b] = 8 // request opcode |
| 580 |
b += 1 |
| 581 |
|
| 582 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 583 |
b += 2 |
| 584 |
|
| 585 |
xgb.Put32(buf[b:], uint32(Window)) |
| 586 |
b += 4 |
| 587 |
|
| 588 |
return buf |
| 589 |
} |
| 590 |
|
| 591 |
// UnredirectSubwindowsCookie is a cookie used only for UnredirectSubwindows requests. |
| 592 |
type UnredirectSubwindowsCookie struct { |
| 593 |
*xgb.Cookie |
| 594 |
} |
| 595 |
|
| 596 |
// UnredirectSubwindows sends an unchecked request. |
| 597 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 598 |
func UnredirectSubwindows(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { |
| 599 |
c.ExtLock.RLock() |
| 600 |
defer c.ExtLock.RUnlock() |
| 601 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 602 |
panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 603 |
} |
| 604 |
cookie := c.NewCookie(false, false) |
| 605 |
c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) |
| 606 |
return UnredirectSubwindowsCookie{cookie} |
| 607 |
} |
| 608 |
|
| 609 |
// UnredirectSubwindowsChecked sends a checked request. |
| 610 |
// If an error occurs, it can be retrieved using UnredirectSubwindowsCookie.Check() |
| 611 |
func UnredirectSubwindowsChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectSubwindowsCookie { |
| 612 |
c.ExtLock.RLock() |
| 613 |
defer c.ExtLock.RUnlock() |
| 614 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 615 |
panic("Cannot issue request 'UnredirectSubwindows' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 616 |
} |
| 617 |
cookie := c.NewCookie(true, false) |
| 618 |
c.NewRequest(unredirectSubwindowsRequest(c, Window, Update), cookie) |
| 619 |
return UnredirectSubwindowsCookie{cookie} |
| 620 |
} |
| 621 |
|
| 622 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 623 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 624 |
func (cook UnredirectSubwindowsCookie) Check() error { |
| 625 |
return cook.Cookie.Check() |
| 626 |
} |
| 627 |
|
| 628 |
// Write request to wire for UnredirectSubwindows |
| 629 |
// unredirectSubwindowsRequest writes a UnredirectSubwindows request to a byte slice. |
| 630 |
func unredirectSubwindowsRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { |
| 631 |
size := 12 |
| 632 |
b := 0 |
| 633 |
buf := make([]byte, size) |
| 634 |
|
| 635 |
c.ExtLock.RLock() |
| 636 |
buf[b] = c.Extensions["Composite"] |
| 637 |
c.ExtLock.RUnlock() |
| 638 |
b += 1 |
| 639 |
|
| 640 |
buf[b] = 4 // request opcode |
| 641 |
b += 1 |
| 642 |
|
| 643 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 644 |
b += 2 |
| 645 |
|
| 646 |
xgb.Put32(buf[b:], uint32(Window)) |
| 647 |
b += 4 |
| 648 |
|
| 649 |
buf[b] = Update |
| 650 |
b += 1 |
| 651 |
|
| 652 |
b += 3 // padding |
| 653 |
|
| 654 |
return buf |
| 655 |
} |
| 656 |
|
| 657 |
// UnredirectWindowCookie is a cookie used only for UnredirectWindow requests. |
| 658 |
type UnredirectWindowCookie struct { |
| 659 |
*xgb.Cookie |
| 660 |
} |
| 661 |
|
| 662 |
// UnredirectWindow sends an unchecked request. |
| 663 |
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. |
| 664 |
func UnredirectWindow(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { |
| 665 |
c.ExtLock.RLock() |
| 666 |
defer c.ExtLock.RUnlock() |
| 667 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 668 |
panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 669 |
} |
| 670 |
cookie := c.NewCookie(false, false) |
| 671 |
c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) |
| 672 |
return UnredirectWindowCookie{cookie} |
| 673 |
} |
| 674 |
|
| 675 |
// UnredirectWindowChecked sends a checked request. |
| 676 |
// If an error occurs, it can be retrieved using UnredirectWindowCookie.Check() |
| 677 |
func UnredirectWindowChecked(c *xgb.Conn, Window xproto.Window, Update byte) UnredirectWindowCookie { |
| 678 |
c.ExtLock.RLock() |
| 679 |
defer c.ExtLock.RUnlock() |
| 680 |
if _, ok := c.Extensions["Composite"]; !ok { |
| 681 |
panic("Cannot issue request 'UnredirectWindow' using the uninitialized extension 'Composite'. composite.Init(connObj) must be called first.") |
| 682 |
} |
| 683 |
cookie := c.NewCookie(true, false) |
| 684 |
c.NewRequest(unredirectWindowRequest(c, Window, Update), cookie) |
| 685 |
return UnredirectWindowCookie{cookie} |
| 686 |
} |
| 687 |
|
| 688 |
// Check returns an error if one occurred for checked requests that are not expecting a reply. |
| 689 |
// This cannot be called for requests expecting a reply, nor for unchecked requests. |
| 690 |
func (cook UnredirectWindowCookie) Check() error { |
| 691 |
return cook.Cookie.Check() |
| 692 |
} |
| 693 |
|
| 694 |
// Write request to wire for UnredirectWindow |
| 695 |
// unredirectWindowRequest writes a UnredirectWindow request to a byte slice. |
| 696 |
func unredirectWindowRequest(c *xgb.Conn, Window xproto.Window, Update byte) []byte { |
| 697 |
size := 12 |
| 698 |
b := 0 |
| 699 |
buf := make([]byte, size) |
| 700 |
|
| 701 |
c.ExtLock.RLock() |
| 702 |
buf[b] = c.Extensions["Composite"] |
| 703 |
c.ExtLock.RUnlock() |
| 704 |
b += 1 |
| 705 |
|
| 706 |
buf[b] = 3 // request opcode |
| 707 |
b += 1 |
| 708 |
|
| 709 |
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units |
| 710 |
b += 2 |
| 711 |
|
| 712 |
xgb.Put32(buf[b:], uint32(Window)) |
| 713 |
b += 4 |
| 714 |
|
| 715 |
buf[b] = Update |
| 716 |
b += 1 |
| 717 |
|
| 718 |
b += 3 // padding |
| 719 |
|
| 720 |
return buf |
| 721 |
} |