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
|
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
package screensaver
import "github.com/linuxdeepin/go-x11-client"
type NotifyEvent struct {
State uint8
Sequence uint16
Time x.Timestamp
Root x.Window
Window x.Window
Kind uint8
Forced bool
}
func readNotifyEvent(r *x.Reader, v *NotifyEvent) error {
if !r.RemainAtLeast4b(5) {
return x.ErrDataLenShort
}
v.State, v.Sequence = r.ReadEventHeader()
v.Time = x.Timestamp(r.Read4b())
v.Root = x.Window(r.Read4b())
v.Window = x.Window(r.Read4b())
v.Kind = r.Read1b()
v.Forced = r.ReadBool() // 5
return nil
}
// #WREQ
func encodeQueryVersion(clientMajorVersion, clientMinorVersion uint8) (b x.RequestBody) {
b.AddBlock(1).
Write1b(clientMajorVersion).
Write1b(clientMinorVersion).
WritePad(2).
End()
return
}
type QueryVersionReply struct {
ServerMajorVersion uint16
ServerMinorVersion uint16
}
func readQueryVersionReply(r *x.Reader, v *QueryVersionReply) error {
if !r.RemainAtLeast4b(3) {
return x.ErrDataLenShort
}
r.ReadPad(8)
v.ServerMajorVersion = r.Read2b()
v.ServerMinorVersion = r.Read2b() // 3
return nil
}
// #WREQ
func encodeQueryInfo(drawable x.Drawable) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(drawable)).
End()
return
}
type QueryInfoReply struct {
State uint8
SaverWindow x.Window
MsUntilServer uint32
MsSinceUserInput uint32
EventMask uint32
Kind uint8
}
func readQueryInfoReply(r *x.Reader, v *QueryInfoReply) error {
if !r.RemainAtLeast4b(7) {
return x.ErrDataLenShort
}
v.State, _ = r.ReadReplyHeader()
v.SaverWindow = x.Window(r.Read4b())
v.MsUntilServer = r.Read4b()
v.MsSinceUserInput = r.Read4b()
v.EventMask = r.Read4b() // 6
v.Kind = r.Read1b() // 7
return nil
}
// #WREQ
func encodeSelectInput(drawable x.Drawable, eventMask uint32) (b x.RequestBody) {
b.AddBlock(2).
Write4b(uint32(drawable)).
Write4b(eventMask).
End()
return
}
// #WREQ
func encodeSetAttributes(drawable x.Drawable, X, y int16, width, height,
boardWidth uint16, class, depth uint8, visual x.VisualID, valueMask uint32,
valueList []uint32) (b x.RequestBody) {
b0 := b.AddBlock(6 + len(valueList)).
Write4b(uint32(drawable)).
Write2b(uint16(X)).
Write2b(uint16(y)).
Write2b(width).
Write2b(height).
Write2b(boardWidth).
Write1b(class).
Write1b(depth).
Write4b(uint32(visual)).
Write4b(valueMask)
for _, value := range valueList {
b0.Write4b(value)
}
b0.End()
return
}
// #WREQ
func encodeUnsetAttributes(drawable x.Drawable) (b x.RequestBody) {
b.AddBlock(1).
Write4b(uint32(drawable)).
End()
return
}
// #WREQ
func encodeSuspend(suspend bool) (b x.RequestBody) {
b.AddBlock(1).
WriteBool(suspend).
WritePad(3).
End()
return
}
|