mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
event: Add convenience functions for Shift and Ctrl modifiers
Instead of going through clutter_event_get_state() and checking if the modifier mask is set, we can provide simple convenience functions to do it for us.
This commit is contained in:
parent
0230f97f60
commit
129752e560
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
<SUBSECTION>
|
||||
clutter_event_get
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user