summaryrefslogtreecommitdiff
path: root/src/eventcomm.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-03-20 10:33:57 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-03-31 15:26:02 +1000
commit3277733209180d94f67be8019178424dbe17fc5b (patch)
treee88bb0e64c2e372d1edca1d2e6089676aced0bd8 /src/eventcomm.c
parent810423b51706ea26c6794eaf6cd51fcbb56386ad (diff)
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 <peter.hutterer@who-t.net>
Diffstat (limited to 'src/eventcomm.c')
-rw-r--r--src/eventcomm.c35
1 files changed, 22 insertions, 13 deletions
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);
}