summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-01-06 01:43:58 -0800
committerOri Bernstein <ori@eigenstate.org>2019-01-06 01:43:58 -0800
commite1eab19ea317e875334d7836613abf843281c941 (patch)
tree2060abbba4cfa007eba8486891fe4f0b0fc19df0
parent1ab372d81699731afbc12230b6ffcc5dfb897356 (diff)
downloadlibxmyrb-e1eab19ea317e875334d7836613abf843281c941.tar.gz
Closer to useful now.
We dont' stumble over our feet if we get an event between a request and response.
-rw-r--r--conn.myr176
-rw-r--r--display.myr54
-rwxr-xr-xgen.py100
-rw-r--r--types.myr9
-rw-r--r--xevdump.myr8
5 files changed, 234 insertions, 113 deletions
diff --git a/conn.myr b/conn.myr
index c96b86b..aa55031 100644
--- a/conn.myr
+++ b/conn.myr
@@ -16,20 +16,21 @@ pkg xmyrb =
const packuint32 : (c : display#, val : uint32 -> void)
const packuint64 : (c : display#, val : uint64 -> void)
- const unpackbool : (c : display#, valp : bool# -> void)
- const unpackxid : (c : display#, valp : xid# -> void)
- const unpackbyte : (c : display#, valp : byte# -> void)
- const unpackint8 : (c : display#, valp : int8# -> void)
- const unpackint16 : (c : display#, valp : int16# -> void)
- const unpackint32 : (c : display#, valp : int32# -> void)
- const unpackint64 : (c : display#, valp : int64# -> void)
- const unpackuint8 : (c : display#, valp : uint8# -> void)
- const unpackuint16 : (c : display#, valp : uint16# -> void)
- const unpackuint32 : (c : display#, valp : uint32# -> void)
- const unpackuint64 : (c : display#, valp : uint64# -> void)
-
- const unpackpad : (c : display#, cnt : std.size -> void)
- const unpackalign : (c : display#, align : std.size -> void)
+ const unpackdata : (buf : byte[:], off : std.size, val : byte[:] -> std.size)
+ const unpackbool : (buf : byte[:], off : std.size, valp : bool# -> std.size)
+ const unpackxid : (buf : byte[:], off : std.size, valp : xid# -> std.size)
+ const unpackbyte : (buf : byte[:], off : std.size, valp : byte# -> std.size)
+ const unpackint8 : (buf : byte[:], off : std.size, valp : int8# -> std.size)
+ const unpackint16 : (buf : byte[:], off : std.size, valp : int16# -> std.size)
+ const unpackint32 : (buf : byte[:], off : std.size, valp : int32# -> std.size)
+ const unpackint64 : (buf : byte[:], off : std.size, valp : int64# -> std.size)
+ const unpackuint8 : (buf : byte[:], off : std.size, valp : uint8# -> std.size)
+ const unpackuint16 : (buf : byte[:], off : std.size, valp : uint16# -> std.size)
+ const unpackuint32 : (buf : byte[:], off : std.size, valp : uint32# -> std.size)
+ const unpackuint64 : (buf : byte[:], off : std.size, valp : uint64# -> std.size)
+
+ const unpackpad : (buf : byte[:], off : std.size, cnt : std.size -> std.size)
+ const unpackalign : (buf : byte[:], off : std.size, align : std.size -> std.size)
const packpad : (c : display#, cnt : std.size -> void)
const packalign : (c : display#, align : std.size -> void)
@@ -37,8 +38,9 @@ pkg xmyrb =
const ensureread : (c : display#, sz : std.size -> void)
const ensurewrite : (c : display#, sz : std.size -> void)
const donepack : (c : display# -> void)
- const doneunpack : (c : display# -> void)
const flush : (c : display# -> void)
+ const wait : (c : display#, seq : uint16 -> byte[:])
+ const waitevent : (c : display# -> byte[:])
;;
const packdata = {c, val
@@ -99,66 +101,62 @@ const packuint64 = {c , val
c.woff += 8
}
-const unpackbool = {c , valp
- unpackuint8(c, (valp : uint8#))
+const unpackdata = {buf, off, val
+ std.slcp(val, buf[off:off + val.len])
+ -> val.len
}
-const unpackxid = {c , valp
- unpackuint32(c, (valp : uint32#))
+const unpackbool = {buf, off, valp
+ -> unpackuint8(buf, off, (valp : uint8#))
}
-const unpackbyte = {c , valp
- unpackuint8(c, (valp : uint8#))
+const unpackxid = {buf, off, valp
+ -> unpackuint32(buf, off, (valp : uint32#))
}
-const unpackint8 = {c , valp
- unpackuint8(c, (valp : uint8#))
+const unpackbyte = {buf, off, valp
+ -> unpackuint8(buf, off, (valp : uint8#))
}
-const unpackint16 = {c , valp
- unpackuint16(c, (valp : uint16#))
+const unpackint8 = {buf, off, valp
+ -> unpackuint8(buf, off, (valp : uint8#))
}
-const unpackint32 = {c , valp
- unpackuint32(c, (valp : uint32#))
+const unpackint16 = {buf, off, valp
+ -> unpackuint16(buf, off, (valp : uint16#))
}
-const unpackint64 = {c , valp
- unpackuint64(c, (valp : uint64#))
+const unpackint32 = {buf, off, valp
+ -> unpackuint32(buf, off, (valp : uint32#))
}
-const unpackalign = {c , align : std.size
- var n
+const unpackint64 = {buf, off, valp
+ -> unpackuint64(buf, off, (valp : uint64#))
+}
- n = (c.roff - c.rbound) & align - 1
- if n != 0
- ensureread(c, align - n)
- c.roff += align - n
- ;;
+const unpackalign = {buf, off, align : std.size
+ var n = off & align - 1
+ -> n == 0 ? 0 : align - n
}
-const unpackuint8 = {c , valp
- ensureread(c, 1)
- valp# = std.getle8(c.rbuf[c.roff:c.roff+1])
- c.roff += 1
+const unpackuint8 = {buf, off, valp
+ valp# = std.getle8(buf[off:off+1])
+ -> 1
}
-const unpackuint16 = {c , valp
- ensureread(c, 2)
- valp# = std.getle16(c.rbuf[c.roff:c.roff+2])
- c.roff += 2
+const unpackuint16 = {buf, off, valp
+ valp# = std.getle16(buf[off:off+2])
+ -> 2
}
-const unpackuint32 = {c , valp
- ensureread(c, 4)
- valp# = std.getle32(c.rbuf[c.roff:c.roff+4])
- c.roff += 4
+const unpackuint32 = {buf, off, valp
+ valp# = std.getle32(buf[off:off+4])
+ -> 4
}
-const unpackuint64 = {c , valp
- ensureread(c, 8)
- valp# = std.getle64(c.rbuf[c.roff:c.roff+8])
- c.roff += 8
+const unpackuint64 = {buf, off, valp
+ valp# = std.getle64(buf[off:off+8])
+ -> 8
}
const packalign = {c , align : std.size
@@ -177,9 +175,8 @@ const packpad = {c , cnt
c.woff += cnt
}
-const unpackpad = {c , cnt
- ensureread(c, cnt)
- c.roff += 1*cnt
+const unpackpad = {buf, off, cnt
+ -> cnt
}
const ensureread = {c , sz : std.size
@@ -195,7 +192,7 @@ const ensureread = {c , sz : std.size
c.roff = 0
c.rbound -= rem
- r = 0
+ r = rem
while r < sz
match std.read(c.fd, c.rbuf[c.rlen + r:])
| `std.Err e: std.fatal("failed read: {}\n", e)
@@ -212,16 +209,11 @@ const ensurewrite = {c , sz : std.size
;;
}
-const doneunpack = {c
- c.rbound = c.roff
-}
-
const donepack = {c
var sz
sz = c.woff - c.wbound
if sz != 0
- //std.assert(sz < c.msgsz, "big requests not yet supported")
std.assert(sz & 0x3 == 0, "misaligned request: {}:{}\n", c.wbound, c.woff)
std.putle16(c.wbuf[c.wbound + 2 : c.wbound + 4], sz >> 2)
;;
@@ -242,3 +234,65 @@ const flush = {c
c.woff = 0
c.wbound = 0
}
+
+const readmsg = {c
+ var mty, len, seq, ev
+
+ /* Minimum size of a message is 32. */
+ len = 32
+ ensureread(c, len)
+ mty = c.rbuf[c.roff]
+ /*
+ * Slightly ugly: We need to do protocol parsing here,
+ * but we don't have access to the constants. Just hard
+ * code them -- there's not many of them -- and move on.
+ */
+ if mty & 0x7f != 11 /* Keymap notifies are special */
+ seq = std.getle16(c.rbuf[c.roff+2:c.roff+4])
+ /* error */
+ if mty == 0
+ /* wat */
+ /* reply */
+ elif mty == 1
+ len = std.getle32(c.rbuf[c.roff+4:c.roff+8])*4
+ ensureread(c, len)
+ std.htput(c.resp, seq, std.sldup(c.rbuf[c.roff:c.roff+len]))
+ /* event */
+ else
+ /* no big event support yet */
+ ev = std.zalloc()
+ ev.buf = std.sldup(c.rbuf[c.roff:c.roff + len])
+ if c.evhead == (0 : evnode#)
+ c.evhead = ev
+ ;;
+ if c.evtail != (0 : evnode#)
+ c.evtail.next = ev
+ ;;
+ c.evtail = ev
+ ;;
+ c.roff += len
+ ;;
+}
+
+const wait = {c, seq
+ while !std.hthas(c.resp, seq)
+ readmsg(c)
+ ;;
+ -> std.get(std.htget(c.resp, seq))
+}
+
+const waitevent = {c
+ var r, e
+
+ while c.evhead == (0 : evnode#)
+ readmsg(c)
+ ;;
+ e = c.evhead
+ r = e.buf
+ c.evhead = e.next
+ if c.evhead == (0 : evnode#)
+ c.evtail = (0 : evnode#)
+ ;;
+ std.free(e)
+ -> r
+}
diff --git a/display.myr b/display.myr
index 6db5583..12a2b71 100644
--- a/display.myr
+++ b/display.myr
@@ -20,7 +20,8 @@ pkg xmyrb =
;;
const xid = {dpy
- -> dpy.nextid++
+ dpy.nextid++
+ -> dpy.nextid
}
const setup = {dpy
@@ -109,6 +110,7 @@ const mkdisplay = {fd, host, dpynum, scrnum
.screen = scrnum,
.fd=fd,
+ .resp=std.mkht(),
.rbuf=std.slalloc(32*std.KiB),
.roff=0,
.rlen=0,
@@ -137,8 +139,8 @@ const freedisplay = {dpy
const handshake = {dpy
var req : byte[512]
- var resp : setup#
var auth, zauth, valid, sz
+ var buf, setup
zauth = [
.family=0,
@@ -160,7 +162,6 @@ const handshake = {dpy
| AuthfamLhost: valid = islocalip(dpy.host)
| _: valid = false
;;
- std.put("valid: {}, a.fam: {}\n", valid, a.family)
if valid && n == dpy.num
auth = a
break
@@ -187,10 +188,48 @@ const handshake = {dpy
std.slcp(req[sz:sz+auth.data.len], auth.data); sz += auth.data.len
std.writeall(dpy.fd, req[:sz])
- resp = std.zalloc()
- unpacksetup(dpy, resp)
- dpy.nextid = (resp.resource_id_base : xid)
- -> `std.Ok resp
+ setup = std.zalloc()
+
+ /*
+ * Ugly: X11's first response isn't a generic response.
+ * We need to read this shit manually. First, get the generic
+ * error/success message: 6 bytes.
+ */
+ buf = std.slalloc(8)
+ match std.readall(dpy.fd, buf[:6])
+ | `std.Ok 6: /* ok */
+ | `std.Ok _: std.put("here\n"); -> `std.Err `Eproto
+ | `std.Err _: -> `std.Err `Econn
+ ;;
+ /* If it's an error, return a failure error. */
+ if buf[0] == 0
+ std.close(dpy.fd)
+ -> `std.Err `Eproto
+ ;;
+ /*
+ * If it's a success, we have a size. Read it, then read
+ * the tail of the message.
+ */
+ match std.readall(dpy.fd, buf[6:8])
+ | `std.Ok 2: /* ok */
+ | `std.Ok _: std.put("there\n"); -> `std.Err `Eproto
+ | `std.Err _: -> `std.Err `Econn
+ ;;
+
+ sz = 4*std.getle16(buf[6:8])
+ std.slgrow(&buf, sz + 8)
+ match std.readall(dpy.fd, buf[8:])
+ | `std.Ok n:
+ if n != sz
+ -> `std.Err `Eproto
+ ;;
+ | `std.Err _: -> `std.Err `Econn
+ ;;
+
+ unpacksetup(buf, 0, setup)
+ std.slfree(buf)
+ dpy.nextid = (setup.resource_id_base : xid)
+ -> `std.Ok setup
}
@@ -223,7 +262,6 @@ const getnum = {datap
n = std.getbe16(datap#[0:2])
datap# = datap#[2:]
- std.put("n: {}\n", n)
-> n
}
diff --git a/gen.py b/gen.py
index d4c6c66..8900207 100755
--- a/gen.py
+++ b/gen.py
@@ -211,13 +211,13 @@ def genpackfield(elt):
def genunpackfield(elt):
global lentag
if elt.tag == 'field':
- writeln(impl, 'unpack{}(dpy, &val.{})',
+ writeln(impl, 'len += unpack{}(buf, off + len, &val.{})',
myrtype(elt.get('type')), fieldname(elt))
elif elt.tag == 'pad':
if elt.get('bytes'):
- writeln(impl, 'unpackpad(dpy, {})', elt.get('bytes'))
+ writeln(impl, 'len += unpackpad(buf, off + len, {})', elt.get('bytes'))
elif elt.get('align'):
- writeln(impl, 'unpackalign(dpy, {})', elt.get('align'))
+ writeln(impl, 'len += unpackalign(buf, off + len, {})', elt.get('align'))
else:
print etree.tostring(elt)
raise Exception('unknown tag {}'.format(elt.tag))
@@ -231,16 +231,16 @@ def genunpackfield(elt):
if elt.find('value') is None:
writeln(impl, 'val.{} = std.slalloc(len{})', fieldname(elt), lentag)
writeln(impl, 'for var i = 0; i < len{}; i++', lentag)
- writeln(impl, '\tunpack{}(dpy, &val.{}[i])',
+ writeln(impl, '\tlen += unpack{}(buf, off + len, &val.{}[i])',
myrtype(etype), fieldname(elt))
writeln(impl, ';;')
else:
writeln(impl, 'var count{} = 0', lentag)
- writeln(impl, 'var end{} = dpy.rbound + (val.length : std.size)', lentag)
+ writeln(impl, 'var end{} = (val.length : std.size)', lentag)
writeln(impl, 'val.{} = [][:]', fieldname(elt))
- writeln(impl, 'while dpy.roff != end{}', lentag)
+ writeln(impl, 'while off != end{}', lentag)
writeln(impl, '\tstd.slgrow(&val.{}, count{} + 1)', fieldname(elt), lentag)
- writeln(impl, '\tunpack{}(dpy, &val.{}[count{}])',
+ writeln(impl, '\tlen += unpack{}(buf, off + len, &val.{}[count{}])',
myrtype(etype), fieldname(elt), lentag)
writeln(impl, '\tcount{}++', lentag)
writeln(impl, ';;')
@@ -333,7 +333,7 @@ def genstruct(name, selt, isreq=False, isresp=False, isevent=False):
writeln(iface, '')
writeln(iface, 'pkglocal const pack{}{} : (c : display#, val : {}{}# -> void)', sname, suff, sname, suff)
- writeln(iface, 'pkglocal const unpack{}{} : (c : display#, val : {}{}# -> void)', sname, suff, sname, suff)
+ writeln(iface, 'pkglocal const unpack{}{} : (buf : byte[:], off : std.size, val : {}{}# -> std.size)', sname, suff, sname, suff)
writeln(iface, '')
# generate pack
@@ -360,7 +360,7 @@ def genstruct(name, selt, isreq=False, isresp=False, isevent=False):
writeln(impl, 'packuint16(dpy, val.event_type)')
else:
if pack:
- genunpackfield(first)
+ genpackfield(first)
else:
writeln(impl, 'packpad(dpy, 1)')
if selt.get('no-sequence-number') is None:
@@ -379,34 +379,35 @@ def genstruct(name, selt, isreq=False, isresp=False, isevent=False):
writeln(impl, '')
# generate unpack
- writeln(impl, 'const unpack{}{} = {{dpy, val', sname, suff)
+ writeln(impl, 'const unpack{}{} = {{buf, off, val', sname, suff)
indent(impl)
+ writeln(impl, "var len = 0")
if isreq:
- writeln(impl, 'unpackbyte(dpy, &val.major)')
+ writeln(impl, 'len += unpackbyte(buf, off + len, &val.major)')
if pack:
genunpackfield(first)
else:
- writeln(impl, 'unpackbyte(dpy, &val.minor)')
- writeln(impl, 'unpackpad(dpy, 2)')
+ writeln(impl, 'len += unpackbyte(buf, off + len, &val.minor)')
+ writeln(impl, 'len += unpackpad(buf, off + len, 2)')
elif isresp:
- writeln(impl, 'unpackbyte(dpy, &val.response_type)')
- writeln(impl, 'unpackpad(dpy, 1)')
- writeln(impl, 'unpackuint16(dpy, &val.sequence)')
- writeln(impl, 'unpackuint32(dpy, &val.length)')
+ writeln(impl, 'len += unpackbyte(buf, off + len, &val.response_type)')
+ writeln(impl, 'len += unpackpad(buf, off + len, 1)')
+ writeln(impl, 'len += unpackuint16(buf, off + len, &val.sequence)')
+ writeln(impl, 'len += unpackuint32(buf, off + len, &val.length)')
elif isevent:
if selt.get('xge') is not None:
- writeln(impl, 'unpackbyte(dpy, &val.ext)')
- writeln(impl, 'unpackuint16(dpy, &val.sequence)')
- writeln(impl, 'unpackuint32(dpy, &val.length)')
- writeln(impl, 'unpackuint16(dpy, &val.event_type)')
+ writeln(impl, 'len += unpackbyte(buf, off + len, &val.ext)')
+ writeln(impl, 'len += unpackuint16(buf, off + len, &val.sequence)')
+ writeln(impl, 'len += unpackuint32(buf, off + len, &val.length)')
+ writeln(impl, 'len += unpackuint16(buf, off + len, &val.event_type)')
else:
if pack:
genunpackfield(first)
else:
- writeln(impl, 'unpackpad(dpy, 1)')
+ writeln(impl, 'len += unpackpad(buf, off + len, 1)')
if selt.get('no-sequence-number') is None:
- writeln(impl, 'unpackuint16(dpy, &val.sequence)')
+ writeln(impl, 'len += unpackuint16(buf, off + len, &val.sequence)')
lentag = 0
for elt in elts:
@@ -414,8 +415,7 @@ def genstruct(name, selt, isreq=False, isresp=False, isevent=False):
continue
genunpackfield(elt)
- if isreq or isresp:
- writeln(impl, 'doneunpack(dpy)')
+ writeln(impl, "-> len")
outdent(impl)
writeln(impl, '}}')
writeln(impl, '')
@@ -440,15 +440,15 @@ def genunion(name, elts, suff=''):
writeln(iface, '')
writeln(iface, 'const pack{}{} : (c : display#, val : {}{}# -> void)', uname, suff, uname, suff)
- writeln(iface, 'const unpack{}{} : (c : display#, val : {}{}# -> void)', uname, suff, uname, suff)
+ writeln(iface, 'const unpack{}{} : (buf : byte[:], off : std.size, val : {}{}# -> std.size)', uname, suff, uname, suff)
writeln(iface, '')
writeln(impl, 'const pack{}{} = {{dpy, val', uname, suff)
writeln(impl, '\tpackdata(dpy, val.__data[:])')
writeln(impl, '}}')
- writeln(impl, 'const unpack{}{} = {{dpy, val', uname, suff)
- writeln(impl, '\tpackdata(dpy, val.__data[:])')
+ writeln(impl, 'const unpack{}{} = {{buf, off, val', uname, suff)
+ writeln(impl, '\t-> unpackdata(buf, off, val.__data[:])')
writeln(impl, '}}')
writeln(impl, '')
@@ -459,8 +459,6 @@ def gencallproto(name, elts):
iface.write(indents[iface]*'\t')
iface.write('const {} : (dpy : display#'.format(name.lower()))
resp = elts.find('reply')
- if resp is not None:
- iface.write(', resp : {}resp#'.format(name.lower()))
for elt in elts:
if elt.tag is etree.Comment or elt.tag in {'pad', 'reply', 'doc', 'reply', 'exprfield'}:
continue
@@ -483,15 +481,18 @@ def gencallproto(name, elts):
else:
print etree.tostring(elt)
raise Exception('unknown tag {}'.format(elt.tag))
- iface.write('-> void)\n')
+ if resp is not None:
+ writeln(iface, '-> {}seq)\n', name.lower())
+ writeln(iface, 'const wait{} : (dpy : display#, tag : {}seq -> {}resp#)',
+ name.lower(), name.lower(), name.lower())
+ else:
+ iface.write('-> void)\n')
def gencallbody(name, elts):
join = ''
args = []
resp = elts.find('reply')
- if resp is not None:
- args.append('resp')
for elt in elts:
if elt.tag is etree.Comment or elt.tag in {'pad', 'reply', 'doc', 'reply', 'exprfield'}:
continue
@@ -524,11 +525,24 @@ def gencallbody(name, elts):
# TODO: make async
writeln(impl, 'flush(dpy)')
if resp is not None:
- writeln(impl, 'unpack{}resp(dpy, resp)', name.lower())
+ writeln(impl, "-> (dpy.nextseq++ : {}seq)", name.lower())
outdent(impl)
writeln(impl, '}}')
writeln(impl, '')
-
+ if resp is not None:
+ writeln(impl, 'const wait{} = {{dpy, seq', name.lower())
+ indent(impl)
+ writeln(impl, 'var resp, buf, len')
+ writeln(impl, '')
+ writeln(impl, 'resp = std.alloc()')
+ writeln(impl, 'buf = wait(dpy, (seq : uint16))')
+ writeln(impl, 'len = unpack{}resp(buf, 0, resp)', name.lower())
+ writeln(impl, "std.assert(len == buf.len, \"short unpack\\n\")")
+ writeln(impl, 'std.slfree(buf)')
+ writeln(impl, '-> resp')
+ outdent(impl)
+ writeln(impl, '}}')
+ writeln(impl, '')
def genrequest(name, elts):
@@ -536,6 +550,7 @@ def genrequest(name, elts):
genstruct(name, elts, True, False)
resp = elts.find('reply')
if resp is not None:
+ writeln(iface, 'type {}seq = uint16', name.lower())
genstruct(name, resp, False, True)
gencallproto(name, elts)
gencallbody(name, elts)
@@ -561,10 +576,11 @@ def geneventunion(mods, elts):
writeln(iface, ';;')
for (k, v) in elts.items():
- writeln(impl, 'const get{} = {{dpy, evp, issent', k.lower())
+ writeln(impl, 'const get{} = {{buf, off, evp, issent', k.lower())
indent(impl)
writeln(impl, 'var v : {}', k.lower())
- writeln(impl, 'unpack{}(dpy, &v)', k.lower())
+ writeln(impl, '')
+ writeln(impl, 'unpack{}(buf, off, &v)', k.lower())
writeln(impl, 'v.issent = issent')
writeln(impl, 'evp# = `{} v', k)
outdent(impl)
@@ -573,15 +589,17 @@ def geneventunion(mods, elts):
writeln(iface, 'const event : (dpy : display#, evp : event# -> void)')
writeln(impl, 'const event = {{dpy, evp')
indent(impl)
- writeln(impl, 'var evcode, ext : byte, sequence : uint16, length : uint32, evtype : uint16')
+ writeln(impl, 'var buf, len, evcode')
writeln(impl, '')
- writeln(impl, 'unpackbyte(dpy, &evcode)')
+ writeln(impl, 'len = 0')
+ writeln(impl, 'buf = waitevent(dpy)')
+ writeln(impl, 'len += unpackbyte(buf, len, &evcode)')
writeln(impl, 'match evcode & 0x7f')
for (k, v) in elts.items():
- writeln(impl, '| {}: get{}(dpy, evp, (evcode & 0x80) != 0)', v.get('number'), k.lower())
+ writeln(impl, '| {}: get{}(buf, len, evp, (evcode & 0x80) != 0)', v.get('number'), k.lower())
writeln(impl, '| _: std.fatal("invalid event {{}}\\n", evcode)')
writeln(impl, ';;')
- writeln(impl, 'unpackalign(dpy, 32)')
+ writeln(impl, 'std.slfree(buf)')
outdent(impl)
writeln(impl, '}}')
outdent(iface)
diff --git a/types.myr b/types.myr
index 9bd56ec..1bf440f 100644
--- a/types.myr
+++ b/types.myr
@@ -5,6 +5,7 @@ pkg xmyrb =
type display = struct
nextid : xid
+ nextseq : uint16
num : int32
screen : int32
@@ -15,6 +16,9 @@ pkg xmyrb =
roff : std.size
rlen : std.size
rbound : std.size
+ resp : std.htab(uint16, byte[:])#
+ evhead : evnode#
+ evtail : evnode#
wbuf : byte[:]
woff : std.size
@@ -26,6 +30,11 @@ pkg xmyrb =
host : byte[:]
;;
+ type evnode = struct
+ next : evnode#
+ buf : byte[:]
+ ;;
+
const AuthfamLocal : uint16 = 256
const AuthfamWild : uint16 = 65535
const AuthfamNetname : uint16 = 254
diff --git a/xevdump.myr b/xevdump.myr
index 75b17de..afc2292 100644
--- a/xevdump.myr
+++ b/xevdump.myr
@@ -13,7 +13,6 @@ const main = {
xmyrb.EventMaskButtonPress | xmyrb.EventMaskButtonRelease | \
xmyrb.EventMaskStructureNotify | xmyrb.EventMaskExposure
win = xmyrb.createwin(dpy, 200, 200, xmyrb.white(dpy), evmask)
-
xmyrb.mapwindow(dpy, win)
xmyrb.flush(dpy)
@@ -32,8 +31,8 @@ const dumpdpy = {dpy
std.put("s.protocol_minor_version: {}\n", s.protocol_minor_version)
std.put("s.length: {}\n", s.length)
std.put("s.release_number: {}\n", s.release_number)
- std.put("s.resource_id_base: {}\n", s.resource_id_base)
- std.put("s.resource_id_mask: {}\n", s.resource_id_mask)
+ std.put("s.resource_id_base: 0x{x}\n", s.resource_id_base)
+ std.put("s.resource_id_mask: 0x{x}\n", s.resource_id_mask)
std.put("s.motion_buffer_size: {}\n", s.motion_buffer_size)
std.put("s.vendor_len: {}\n", s.vendor_len)
std.put("s.maximum_request_length: {}\n", s.maximum_request_length)
@@ -46,5 +45,8 @@ const dumpdpy = {dpy
std.put("s.min_keycode: {}\n", s.min_keycode)
std.put("s.max_keycode: {}\n", s.max_keycode)
std.put("s.vendor: {}\n", s.vendor)
+ std.put("s.n_pixmap_formats: \n\t{}\n", s.pixmap_formats.len)
std.put("s.pixmap_formats: \n\t{j=\n\t}\n", s.pixmap_formats)
+ std.put("s.screen[0].root: 0x{x}\n", s.roots[0].root)
+ std.put("s.screen[0].root_visual: 0x{x}\n", s.roots[0].root_visual)
}