sidorares/node-x11

Parsing of ShapeNotify event not implemented

jdomenechb opened this issue · 3 comments

Looking at the xcore.js file, seems that the parsing of the ShapeNotify event attributes (type = 64) is not implemented - it only parses up until event 32.

It would be nice to have it, as I am using the Shape extension to detect changes in the shape of the window. This way. the same event callback handler execution I would be able to obtain the geometry, area, and other useful data, instead of using a workaround like using the Damage extension.

@jdomenechb it seems to me ShapeNotify does not belong to core but it's defined by the shape extension. So this should be probably be implemented in https://github.com/sidorares/node-x11/blob/master/lib/ext/shape.js. Would you be up to sending a PR implementing it?

I might... I first have to understand how .unpack() works and what is exactly unpacking, as if I compare the calls against the xlib structs it seems not to follow the same order of parameters. Any hist you could gave me, @santigimeno ?

unpack should follow the order defined in the x11 protocol. For example for the ShapeNotify event I would look to the Encoding section:

ShapeNotify
     1     CARD8               type (0 + extension event base)
     1     SHAPE_KIND          shape kind
     2     CARD16              sequence number
     4     WINDOW              affected window
     2     INT16               x value of extents
     2     INT16               y value of extents
     2     CARD16              width of extents
     2     CARD16              height of extents
     4     TIMESTAMP           server time
     1     BOOL                shaped
     11                        unused

For how to implement it. Look at how DamageNotify is done, where the parameters would be:
type --> 1 CARD8 type (0 + extension event base)
seq --> 2 CARD16 sequence number
code --> 1 SHAPE_KIND shape kind
extra should not be used.
raw starts from 4 WINDOW affected window. You should unpack this!

Maybe code and extra might be switched but this can get you going