diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index f96470750..392f1b2df 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -1594,3 +1594,35 @@ clutter_event_get_angle (const ClutterEvent *source, return angle; } + +/** + * clutter_event_has_shift_modifier: + * @event: a #ClutterEvent + * + * Checks whether @event has the Shift modifier mask set. + * + * Return value: %TRUE if the event has the Shift modifier mask set + * + * Since: 1.12 + */ +gboolean +clutter_event_has_shift_modifier (const ClutterEvent *event) +{ + return (clutter_event_get_state (event) & CLUTTER_SHIFT_MASK) != FALSE; +} + +/** + * clutter_event_has_control_modifier: + * @event: a #ClutterEvent + * + * Checks whether @event has the Control modifier mask set. + * + * Return value: %TRUE if the event has the Control modifier mask set + * + * Since: 1.12 + */ +gboolean +clutter_event_has_control_modifier (const ClutterEvent *event) +{ + return (clutter_event_get_state (event) & CLUTTER_CONTROL_MASK) != FALSE; +} diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h index 7a3685cc4..1fe60c0f5 100644 --- a/clutter/clutter-event.h +++ b/clutter/clutter-event.h @@ -466,6 +466,11 @@ double clutter_event_get_angle (const ClutterEv gdouble * clutter_event_get_axes (const ClutterEvent *event, guint *n_axes); +CLUTTER_AVAILABLE_IN_1_12 +gboolean clutter_event_has_shift_modifier (const ClutterEvent *event); +CLUTTER_AVAILABLE_IN_1_12 +gboolean clutter_event_has_control_modifier (const ClutterEvent *event); + void clutter_event_set_key_symbol (ClutterEvent *event, guint key_sym); guint clutter_event_get_key_symbol (const ClutterEvent *event); diff --git a/clutter/clutter.symbols b/clutter/clutter.symbols index 7b819185a..ef0477d11 100644 --- a/clutter/clutter.symbols +++ b/clutter/clutter.symbols @@ -652,6 +652,8 @@ clutter_event_get_state clutter_event_get_type clutter_event_get_time clutter_event_get +clutter_event_has_control_modifier +clutter_event_has_shift_modifier clutter_event_new clutter_event_peek clutter_event_put diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index d1e2cdeac..78918ddce 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1088,6 +1088,8 @@ clutter_event_get_event_sequence clutter_event_get_angle clutter_event_get_distance clutter_event_get_position +clutter_event_has_control_modifier +clutter_event_has_shift_modifier clutter_event_get diff --git a/tests/interactive/test-text-field.c b/tests/interactive/test-text-field.c index b1738c3af..74d712085 100644 --- a/tests/interactive/test-text-field.c +++ b/tests/interactive/test-text-field.c @@ -34,10 +34,8 @@ on_captured_event (ClutterText *text, c = clutter_event_get_key_unicode (event); keyval = clutter_event_get_key_symbol (event); - if (keyval == CLUTTER_KEY_u) + if (keyval == CLUTTER_KEY_U) { - ClutterModifierType mods = clutter_event_get_state (event); - if (is_unicode_mode) { GString *str = g_object_get_data (G_OBJECT (text), "unicode-str"); @@ -54,8 +52,7 @@ on_captured_event (ClutterText *text, return FALSE; } - if ((mods & CLUTTER_CONTROL_MASK) && - (mods & CLUTTER_SHIFT_MASK)) + if (clutter_event_has_control_modifier (event)) { PangoAttrList *attrs; PangoAttribute *a; @@ -99,7 +96,7 @@ on_captured_event (ClutterText *text, g_string_append (str, buf); - g_print ("added '%s' to '%s' (len:%d)", + g_print ("added '%s' to '%s' (len:%d)\n", buf, str->str, (int) str->len);