mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
API: add accessors for GdkEvent fields
Add accessors for the following fields: button, keyval, keycode, scroll direction, click count. https://bugzilla.gnome.org/show_bug.cgi?id=657384
This commit is contained in:
parent
5cc1318279
commit
f7c188c019
@ -761,11 +761,16 @@ gdk_event_put
|
||||
gdk_event_new
|
||||
gdk_event_copy
|
||||
gdk_event_free
|
||||
gdk_event_get_time
|
||||
gdk_event_get_state
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_button
|
||||
gdk_event_get_click_count
|
||||
gdk_event_get_coords
|
||||
gdk_event_get_keycode
|
||||
gdk_event_get_keyval
|
||||
gdk_event_get_root_coords
|
||||
gdk_event_get_scroll_direction
|
||||
gdk_event_get_state
|
||||
gdk_event_get_time
|
||||
gdk_event_request_motions
|
||||
gdk_events_get_angle
|
||||
gdk_events_get_center
|
||||
|
@ -156,10 +156,15 @@ gdk_event_copy
|
||||
gdk_event_free
|
||||
gdk_event_get
|
||||
gdk_event_get_axis
|
||||
gdk_event_get_button
|
||||
gdk_event_get_click_count
|
||||
gdk_event_get_coords
|
||||
gdk_event_get_device
|
||||
gdk_event_get_keycode
|
||||
gdk_event_get_keyval
|
||||
gdk_event_get_root_coords
|
||||
gdk_event_get_screen
|
||||
gdk_event_get_scroll_direction
|
||||
gdk_event_get_source_device
|
||||
gdk_event_get_state
|
||||
gdk_event_get_time
|
||||
|
186
gdk/gdkevents.c
186
gdk/gdkevents.c
@ -949,6 +949,192 @@ gdk_event_get_root_coords (const GdkEvent *event,
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_button:
|
||||
* @event: a #GdkEvent
|
||||
* @button: (out): location to store mouse button number
|
||||
*
|
||||
* Extract the button number from an event.
|
||||
*
|
||||
* Return value: %TRUE if the event delivered a button number
|
||||
*
|
||||
* Since: 3.2
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_button (const GdkEvent *event,
|
||||
guint *button)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
guint number = 0;
|
||||
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_2BUTTON_PRESS:
|
||||
case GDK_3BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
number = event->button.button;
|
||||
break;
|
||||
default:
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (button)
|
||||
*button = number;
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_click_count:
|
||||
* @event: a #GdkEvent
|
||||
* @click_count: (out): location to store click count
|
||||
*
|
||||
* Extracts the click count from an event.
|
||||
*
|
||||
* Return value: %TRUE if the event delivered a click count
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gboolean
|
||||
gdk_event_get_click_count (const GdkEvent *event,
|
||||
guint *click_count)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
guint number = 0;
|
||||
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_BUTTON_PRESS:
|
||||
case GDK_BUTTON_RELEASE:
|
||||
number = 1;
|
||||
break;
|
||||
case GDK_2BUTTON_PRESS:
|
||||
number = 2;
|
||||
break;
|
||||
case GDK_3BUTTON_PRESS:
|
||||
number = 3;
|
||||
break;
|
||||
default:
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (click_count)
|
||||
*click_count = number;
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_keyval:
|
||||
* @event: a #GdkEvent
|
||||
* @keyval: (out): location to store the keyval
|
||||
*
|
||||
* Extracts the keyval from an event.
|
||||
*
|
||||
* Return value: %TRUE if the event delivered a key symbol
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gboolean
|
||||
gdk_event_get_keyval (const GdkEvent *event,
|
||||
guint *keyval)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
guint number = 0;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
number = event->key.keyval;
|
||||
break;
|
||||
default:
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (keyval)
|
||||
*keyval = number;
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_keycode:
|
||||
* @event: a #GdkEvent
|
||||
* @keycode: (out): location to store the keycode
|
||||
*
|
||||
* Extracts the hardware keycode from an event.
|
||||
*
|
||||
* Return value: %TRUE if the event delivered a hardware keycode
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gboolean
|
||||
gdk_event_get_keycode (const GdkEvent *event,
|
||||
guint16 *keycode)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
guint16 number = 0;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_KEY_PRESS:
|
||||
case GDK_KEY_RELEASE:
|
||||
number = event->key.hardware_keycode;
|
||||
break;
|
||||
default:
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (keycode)
|
||||
*keycode = number;
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_scroll_direction:
|
||||
* @event: a #GdkEvent
|
||||
* @direction: (out): location to store the scroll direction
|
||||
*
|
||||
* Extracts the scroll direction from an event.
|
||||
*
|
||||
* Return value: %TRUE if the event delivered a scroll direction
|
||||
*
|
||||
* Since: 3.2
|
||||
*/
|
||||
gboolean
|
||||
gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
GdkScrollDirection *direction)
|
||||
{
|
||||
gboolean fetched = TRUE;
|
||||
GdkScrollDirection dir = 0;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_SCROLL:
|
||||
dir = event->scroll.direction;
|
||||
break;
|
||||
default:
|
||||
fetched = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (direction)
|
||||
*direction = dir;
|
||||
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_axis:
|
||||
* @event: a #GdkEvent
|
||||
|
@ -1054,9 +1054,19 @@ gboolean gdk_event_get_state (const GdkEvent *event,
|
||||
gboolean gdk_event_get_coords (const GdkEvent *event,
|
||||
gdouble *x_win,
|
||||
gdouble *y_win);
|
||||
gboolean gdk_event_get_root_coords (const GdkEvent *event,
|
||||
gdouble *x_root,
|
||||
gdouble *y_root);
|
||||
gboolean gdk_event_get_root_coords (const GdkEvent *event,
|
||||
gdouble *x_root,
|
||||
gdouble *y_root);
|
||||
gboolean gdk_event_get_button (const GdkEvent *event,
|
||||
guint *button);
|
||||
gboolean gdk_event_get_click_count (const GdkEvent *event,
|
||||
guint *click_count);
|
||||
gboolean gdk_event_get_keyval (const GdkEvent *event,
|
||||
guint *keyval);
|
||||
gboolean gdk_event_get_keycode (const GdkEvent *event,
|
||||
guint16 *keycode);
|
||||
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
GdkScrollDirection *direction);
|
||||
gboolean gdk_event_get_axis (const GdkEvent *event,
|
||||
GdkAxisUse axis_use,
|
||||
gdouble *value);
|
||||
|
Loading…
Reference in New Issue
Block a user