Add more getters for event fields

This commit is contained in:
Matthias Clasen 2017-08-25 22:50:52 -04:00 committed by Carlos Garnacho
parent c7431f46b5
commit 5488009150
2 changed files with 216 additions and 0 deletions

View File

@ -1412,6 +1412,69 @@ gdk_event_get_keycode (const GdkEvent *event,
return fetched;
}
gboolean
gdk_event_get_key_group (const GdkEvent *event,
guint *group)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*group = event->key.group;
break;
default:
*group = 0;
fetched = FALSE;
break;
}
return fetched;
}
gboolean
gdk_event_get_string (const GdkEvent *event,
const char **string)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*string = event->key.string;
break;
default:
*string = NULL;
fetched = FALSE;
break;
}
return fetched;
}
gboolean
gdk_event_get_key_is_modifier (const GdkEvent *event,
gboolean *is_modifier)
{
gboolean fetched = TRUE;
switch (event->type)
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
*is_modifier = event->key.is_modifier;
break;
default:
*is_modifier = FALSE;
fetched = FALSE;
break;
}
return fetched;
}
/**
* gdk_event_get_scroll_direction:
* @event: a #GdkEvent
@ -2605,3 +2668,122 @@ gdk_event_get_user_data (const GdkEvent *event)
private = (GdkEventPrivate *) event;
return private->user_data;
}
gboolean
gdk_event_get_setting (const GdkEvent *event,
const char **setting)
{
if (event && event->type == GDK_SETTING)
{
*setting = event->setting.name;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_is_sent (const GdkEvent *event)
{
if (!event)
return FALSE;
return event->any.send_event;
}
gboolean
gdk_event_get_drag_context (const GdkEvent *event,
GdkDragContext **context)
{
if (!event)
return FALSE;
if (event->type == GDK_DRAG_ENTER ||
event->type == GDK_DRAG_LEAVE ||
event->type == GDK_DRAG_MOTION ||
event->type == GDK_DRAG_STATUS ||
event->type == GDK_DROP_START ||
event->type == GDK_DROP_FINISHED)
{
*context = event->dnd.context;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_crossing_mode (const GdkEvent *event,
GdkCrossingMode *mode)
{
if (!event)
return FALSE;
if (event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY)
{
*mode = event->crossing.mode;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_crossing_detail (const GdkEvent *event,
GdkNotifyType *detail)
{
if (!event)
return FALSE;
if (event->type == GDK_ENTER_NOTIFY ||
event->type == GDK_LEAVE_NOTIFY)
{
*detail = event->crossing.detail;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_touchpad_gesture_phase (const GdkEvent *event,
GdkTouchpadGesturePhase *phase)
{
if (!event)
return FALSE;
if (event->type == GDK_TOUCHPAD_PINCH)
{
*phase = event->touchpad_pinch.phase;
return TRUE;
}
else if (event->type == GDK_TOUCHPAD_SWIPE)
{
*phase = event->touchpad_swipe.phase;
return TRUE;
}
return FALSE;
}
gboolean
gdk_event_get_touchpad_gesture_n_fingers (const GdkEvent *event,
guint *n_fingers)
{
if (!event)
return FALSE;
if (event->type == GDK_TOUCHPAD_PINCH)
{
*n_fingers = event->touchpad_pinch.n_fingers;
return TRUE;
}
else if (event->type == GDK_TOUCHPAD_SWIPE)
{
*n_fingers = event->touchpad_swipe.n_fingers;
return TRUE;
}
return FALSE;
}

View File

@ -639,6 +639,16 @@ gboolean gdk_event_get_keyval (const GdkEvent *event,
GDK_AVAILABLE_IN_3_2
gboolean gdk_event_get_keycode (const GdkEvent *event,
guint16 *keycode);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_key_is_modifier (const GdkEvent *event,
gboolean *is_modifier);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_key_group (const GdkEvent *event,
guint *group);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_string (const GdkEvent *event,
const char **string);
GDK_AVAILABLE_IN_3_2
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
GdkScrollDirection *direction);
@ -729,6 +739,30 @@ GDK_AVAILABLE_IN_3_92
void gdk_event_set_user_data (GdkEvent *event,
GObject *user_data);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_setting (const GdkEvent *event,
const char **setting);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_is_sent (const GdkEvent *event);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_drag_context (const GdkEvent *event,
GdkDragContext **context);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_crossing_mode (const GdkEvent *event,
GdkCrossingMode *mode);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_crossing_detail (const GdkEvent *event,
GdkNotifyType *detail);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_touchpad_gesture_phase (const GdkEvent *event,
GdkTouchpadGesturePhase *phase);
GDK_AVAILABLE_IN_3_92
gboolean gdk_event_get_touchpad_gesture_n_fingers(const GdkEvent *event,
guint *n_fingers);
G_END_DECLS
#endif /* __GDK_EVENTS_H__ */