From 3277733209180d94f67be8019178424dbe17fc5b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sun, 20 Mar 2011 10:33:57 +1000 Subject: eventcomm: move need_grab into a proto-specific struct. Don't just assign a BOOL to proto_data, use a struct for readability. This changes nothing in the code, especially since need_grab is always false. The current code assumes that if a proto_data field is present, we respect the need_grab from this field. Otherwise, we always try to grab. need_grab is however always FALSE, so all this is mostly for readability, if not necessarily understandability... Signed-off-by: Peter Hutterer --- src/eventcomm.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/eventcomm.c') diff --git a/src/eventcomm.c b/src/eventcomm.c index 50b6083..5db47ae 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -48,20 +48,29 @@ #define LONG_BITS (sizeof(long) * 8) #define NBITS(x) (((x) + LONG_BITS - 1) / LONG_BITS) -/***************************************************************************** - * Function Definitions - ****************************************************************************/ +/** + * Protocol-specific data. + */ +struct eventcomm_proto_data +{ + /** + * Do we need to grab the event device? + * Note that in the current flow, this variable is always false and + * exists for readability of the code. + */ + BOOL need_grab; +}; static void EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para) { SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; - BOOL *need_grab; - - if (!priv->proto_data) - priv->proto_data = calloc(1, sizeof(BOOL)); + struct eventcomm_proto_data *proto_data = (struct eventcomm_proto_data*)priv->proto_data; - need_grab = (BOOL*)priv->proto_data; + if (!proto_data) { + proto_data = calloc(1, sizeof(struct eventcomm_proto_data)); + priv->proto_data = proto_data; + } if (para->grab_event_device) { /* Try to grab the event device so that data don't leak to /dev/input/mice */ @@ -73,7 +82,7 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para) } } - *need_grab = FALSE; + proto_data->need_grab = FALSE; } /** @@ -324,9 +333,9 @@ static Bool EventQueryHardware(InputInfoPtr pInfo) { SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; - BOOL *need_grab = (BOOL*)priv->proto_data; + struct eventcomm_proto_data *proto_data = priv->proto_data; - if (!event_query_is_touchpad(pInfo->fd, (need_grab) ? *need_grab : TRUE)) + if (!event_query_is_touchpad(pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE)) return FALSE; xf86Msg(X_PROBED, "%s: touchpad found\n", pInfo->name); @@ -487,9 +496,9 @@ static void EventReadDevDimensions(InputInfoPtr pInfo) { SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; - BOOL *need_grab = (BOOL*)priv->proto_data; + struct eventcomm_proto_data *proto_data = priv->proto_data; - if (event_query_is_touchpad(pInfo->fd, (need_grab) ? *need_grab : TRUE)) + if (event_query_is_touchpad(pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE)) event_query_axis_ranges(pInfo); event_query_model(pInfo->fd, &priv->model); } -- cgit v1.2.3