add support for eventstruct
eventstruct allows to use events as part of requests. This is, e.g., needed by xcb_input_send_extension_event. Signed-off-by: Christian Linhart <chris@demorecorder.com>
This commit is contained in:
parent
0c2c5d50f8
commit
ee9dfc9a76
|
@ -437,7 +437,11 @@ def _c_type_setup(self, name, postfix):
|
||||||
first_field_after_varsized = None
|
first_field_after_varsized = None
|
||||||
|
|
||||||
for field in self.fields:
|
for field in self.fields:
|
||||||
field.c_field_type = _t(field.field_type)
|
if field.type.is_event:
|
||||||
|
field.c_field_type = _t(field.field_type + ('event',))
|
||||||
|
else:
|
||||||
|
field.c_field_type = _t(field.field_type)
|
||||||
|
|
||||||
field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type
|
field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type
|
||||||
field.c_field_name = _cpp(field.field_name)
|
field.c_field_name = _cpp(field.field_name)
|
||||||
field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb and field.type.nmemb > 1) else ''
|
field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb and field.type.nmemb > 1) else ''
|
||||||
|
@ -3156,6 +3160,28 @@ def c_request(self, name):
|
||||||
# TODO: what about aux helpers?
|
# TODO: what about aux helpers?
|
||||||
_man_request(self, name, void=not self.reply, aux=False)
|
_man_request(self, name, void=not self.reply, aux=False)
|
||||||
|
|
||||||
|
|
||||||
|
def c_eventstruct(self, name):
|
||||||
|
#add fields that are needed to get the event-type in a generic way
|
||||||
|
self.fields.append( Field( tevent, tevent.name, 'event_header', False, True, True) )
|
||||||
|
|
||||||
|
if self.contains_ge_events:
|
||||||
|
#TODO: add header of ge-events as an extra field
|
||||||
|
raise Exception( 'eventstructs with ge-events are not yet supported' )
|
||||||
|
|
||||||
|
_c_type_setup(self, name, ())
|
||||||
|
|
||||||
|
#correct the format of the field names
|
||||||
|
for field in self.fields:
|
||||||
|
field.c_field_name = _n_item(field.c_field_name).lower()
|
||||||
|
|
||||||
|
_c_complex(self)
|
||||||
|
_c_iterator(self, name)
|
||||||
|
|
||||||
|
if not self.fixed_size():
|
||||||
|
#TODO: Create sizeof function (and maybe other accessors) for var-sized eventstructs
|
||||||
|
raise Exception( 'var sized eventstructs are not yet supported' )
|
||||||
|
|
||||||
def c_event(self, name):
|
def c_event(self, name):
|
||||||
'''
|
'''
|
||||||
Exported function that handles event declarations.
|
Exported function that handles event declarations.
|
||||||
|
@ -3253,6 +3279,7 @@ output = {'open' : c_open,
|
||||||
'struct' : c_struct,
|
'struct' : c_struct,
|
||||||
'union' : c_union,
|
'union' : c_union,
|
||||||
'request' : c_request,
|
'request' : c_request,
|
||||||
|
'eventstruct' : c_eventstruct,
|
||||||
'event' : c_event,
|
'event' : c_event,
|
||||||
'error' : c_error,
|
'error' : c_error,
|
||||||
}
|
}
|
||||||
|
@ -3296,6 +3323,9 @@ Refer to the README file in xcb/proto for more info.
|
||||||
''')
|
''')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
# predefined datatype globals.
|
||||||
|
tevent = SimpleType(('xcb_raw_generic_event_t',), 32)
|
||||||
|
|
||||||
# Ensure the man subdirectory exists
|
# Ensure the man subdirectory exists
|
||||||
try:
|
try:
|
||||||
os.mkdir('man')
|
os.mkdir('man')
|
||||||
|
|
12
src/xcb.h
12
src/xcb.h
|
@ -142,6 +142,18 @@ typedef struct {
|
||||||
uint32_t full_sequence; /**< full sequence */
|
uint32_t full_sequence; /**< full sequence */
|
||||||
} xcb_generic_event_t;
|
} xcb_generic_event_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Raw Generic event.
|
||||||
|
*
|
||||||
|
* A generic event structure as used on the wire, i.e., without the full_sequence field
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t response_type; /**< Type of the response */
|
||||||
|
uint8_t pad0; /**< Padding */
|
||||||
|
uint16_t sequence; /**< Sequence number */
|
||||||
|
uint32_t pad[7]; /**< Padding */
|
||||||
|
} xcb_raw_generic_event_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GE event
|
* @brief GE event
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue