events: Add proximity events

These events will be sent on tool proximity of tablet events.
This commit is contained in:
Carlos Garnacho 2015-01-14 14:31:13 +01:00
parent 3602b49a30
commit b63e73e422
5 changed files with 64 additions and 1 deletions

View File

@ -761,6 +761,10 @@ typedef enum { /*< flags prefix=CLUTTER_EVENT >*/
* determined by its phase field; event added in 1.24
* @CLUTTER_TOUCHPAD_SWIPE: A swipe gesture event, the current state is
* determined by its phase field; event added in 1.24
* @CLUTTER_PROXIMITY_IN: A tool entered in proximity to a tablet;
* event added in 1.28
* @CLUTTER_PROXIMITY_OUT: A tool left from the proximity area of a tablet;
* event added in 1.28
* @CLUTTER_EVENT_LAST: Marks the end of the #ClutterEventType enumeration;
* added in 1.10
*
@ -788,6 +792,8 @@ typedef enum { /*< prefix=CLUTTER >*/
CLUTTER_TOUCH_CANCEL,
CLUTTER_TOUCHPAD_PINCH,
CLUTTER_TOUCHPAD_SWIPE,
CLUTTER_PROXIMITY_IN,
CLUTTER_PROXIMITY_OUT,
CLUTTER_EVENT_LAST /* helper */
} ClutterEventType;

View File

@ -411,6 +411,8 @@ clutter_event_get_position (const ClutterEvent *event,
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
clutter_point_init (position, 0.f, 0.f);
break;
@ -479,6 +481,8 @@ clutter_event_set_coords (ClutterEvent *event,
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
break;
case CLUTTER_ENTER:
@ -1124,6 +1128,11 @@ clutter_event_set_device (ClutterEvent *event,
case CLUTTER_TOUCHPAD_SWIPE:
/* Rely on priv data for these */
break;
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
event->proximity.device = device;
break;
}
}
@ -1203,6 +1212,11 @@ clutter_event_get_device (const ClutterEvent *event)
case CLUTTER_TOUCHPAD_SWIPE:
/* Rely on priv data for these */
break;
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
device = event->proximity.device;
break;
}
return device;
@ -1668,6 +1682,8 @@ clutter_event_get_axes (const ClutterEvent *event,
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
case CLUTTER_EVENT_LAST:
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
break;
case CLUTTER_SCROLL:

View File

@ -117,6 +117,7 @@ typedef struct _ClutterCrossingEvent ClutterCrossingEvent;
typedef struct _ClutterTouchEvent ClutterTouchEvent;
typedef struct _ClutterTouchpadPinchEvent ClutterTouchpadPinchEvent;
typedef struct _ClutterTouchpadSwipeEvent ClutterTouchpadSwipeEvent;
typedef struct _ClutterProximityEvent ClutterProximityEvent;
/**
* ClutterAnyEvent:
@ -213,6 +214,30 @@ struct _ClutterButtonEvent
ClutterInputDevice *device;
};
/**
* ClutterProximityEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor
* @device: the device that originated the event. If you want the physical
* device the event originated from, use clutter_event_get_source_device()
*
* Event for tool proximity in tablet devices
*
* Since: 1.28
*/
struct _ClutterProximityEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;
ClutterInputDevice *device;
};
/**
* ClutterCrossingEvent:
* @type: event type
@ -490,6 +515,7 @@ union _ClutterEvent
ClutterTouchEvent touch;
ClutterTouchpadPinchEvent touchpad_pinch;
ClutterTouchpadSwipeEvent touchpad_swipe;
ClutterProximityEvent proximity;
};
/**

View File

@ -2487,6 +2487,19 @@ _clutter_process_event_details (ClutterActor *stage,
break;
}
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
if (_clutter_event_process_filters (event))
break;
if (!clutter_actor_event (stage, event, TRUE))
{
/* and bubbling phase */
clutter_actor_event (stage, event, FALSE);
}
break;
case CLUTTER_STAGE_STATE:
/* fullscreen / focus - forward to stage */
event->any.source = stage;

View File

@ -930,7 +930,9 @@ _clutter_stage_queue_event (ClutterStage *stage,
* event processing function
*/
device = clutter_event_get_device (event);
if (device != NULL)
if (device != NULL &&
event->type != CLUTTER_PROXIMITY_IN &&
event->type != CLUTTER_PROXIMITY_OUT)
{
ClutterModifierType event_state = clutter_event_get_state (event);
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);