st/entry: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2860>
This commit is contained in:
parent
75c92afa31
commit
ca383acff6
@ -611,7 +611,7 @@ clutter_text_button_press_event (ClutterActor *actor,
|
|||||||
{
|
{
|
||||||
StEntryPrivate *priv = ST_ENTRY_PRIV (user_data);
|
StEntryPrivate *priv = ST_ENTRY_PRIV (user_data);
|
||||||
|
|
||||||
if (event->button == 2 &&
|
if (clutter_event_get_button ((ClutterEvent *) event) == 2 &&
|
||||||
clutter_text_get_editable (CLUTTER_TEXT (priv->entry)))
|
clutter_text_get_editable (CLUTTER_TEXT (priv->entry)))
|
||||||
{
|
{
|
||||||
StSettings *settings;
|
StSettings *settings;
|
||||||
@ -646,18 +646,23 @@ st_entry_key_press_event (ClutterActor *actor,
|
|||||||
ClutterKeyEvent *event)
|
ClutterKeyEvent *event)
|
||||||
{
|
{
|
||||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||||
|
ClutterModifierType state;
|
||||||
|
uint32_t keyval;
|
||||||
|
|
||||||
/* This is expected to handle events that were emitted for the inner
|
/* This is expected to handle events that were emitted for the inner
|
||||||
ClutterText. They only reach this function if the ClutterText
|
ClutterText. They only reach this function if the ClutterText
|
||||||
didn't handle them */
|
didn't handle them */
|
||||||
|
|
||||||
/* paste */
|
/* paste */
|
||||||
if (((event->modifier_state & CLUTTER_CONTROL_MASK)
|
state = clutter_event_get_state ((ClutterEvent *) event);
|
||||||
&& event->keyval == CLUTTER_KEY_v) ||
|
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
|
||||||
((event->modifier_state & CLUTTER_CONTROL_MASK)
|
|
||||||
&& event->keyval == CLUTTER_KEY_V) ||
|
if (((state & CLUTTER_CONTROL_MASK)
|
||||||
((event->modifier_state & CLUTTER_SHIFT_MASK)
|
&& keyval == CLUTTER_KEY_v) ||
|
||||||
&& event->keyval == CLUTTER_KEY_Insert))
|
((state & CLUTTER_CONTROL_MASK)
|
||||||
|
&& keyval == CLUTTER_KEY_V) ||
|
||||||
|
((state & CLUTTER_SHIFT_MASK)
|
||||||
|
&& keyval == CLUTTER_KEY_Insert))
|
||||||
{
|
{
|
||||||
StClipboard *clipboard;
|
StClipboard *clipboard;
|
||||||
|
|
||||||
@ -672,8 +677,8 @@ st_entry_key_press_event (ClutterActor *actor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy */
|
/* copy */
|
||||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
|
if ((state & CLUTTER_CONTROL_MASK)
|
||||||
&& (event->keyval == CLUTTER_KEY_c || event->keyval == CLUTTER_KEY_C) &&
|
&& (keyval == CLUTTER_KEY_c || keyval == CLUTTER_KEY_C) &&
|
||||||
clutter_text_get_password_char ((ClutterText*) priv->entry) == 0)
|
clutter_text_get_password_char ((ClutterText*) priv->entry) == 0)
|
||||||
{
|
{
|
||||||
StClipboard *clipboard;
|
StClipboard *clipboard;
|
||||||
@ -695,8 +700,8 @@ st_entry_key_press_event (ClutterActor *actor,
|
|||||||
|
|
||||||
|
|
||||||
/* cut */
|
/* cut */
|
||||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
|
if ((state & CLUTTER_CONTROL_MASK)
|
||||||
&& (event->keyval == CLUTTER_KEY_x || event->keyval == CLUTTER_KEY_X) &&
|
&& (keyval == CLUTTER_KEY_x || keyval == CLUTTER_KEY_X) &&
|
||||||
clutter_text_get_password_char ((ClutterText*) priv->entry) == 0)
|
clutter_text_get_password_char ((ClutterText*) priv->entry) == 0)
|
||||||
{
|
{
|
||||||
StClipboard *clipboard;
|
StClipboard *clipboard;
|
||||||
@ -723,8 +728,8 @@ st_entry_key_press_event (ClutterActor *actor,
|
|||||||
|
|
||||||
|
|
||||||
/* delete to beginning of line */
|
/* delete to beginning of line */
|
||||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK) &&
|
if ((state & CLUTTER_CONTROL_MASK) &&
|
||||||
(event->keyval == CLUTTER_KEY_u || event->keyval == CLUTTER_KEY_U))
|
(keyval == CLUTTER_KEY_u || keyval == CLUTTER_KEY_U))
|
||||||
{
|
{
|
||||||
int pos = clutter_text_get_cursor_position ((ClutterText *)priv->entry);
|
int pos = clutter_text_get_cursor_position ((ClutterText *)priv->entry);
|
||||||
clutter_text_delete_text ((ClutterText *)priv->entry, 0, pos);
|
clutter_text_delete_text ((ClutterText *)priv->entry, 0, pos);
|
||||||
@ -734,8 +739,8 @@ st_entry_key_press_event (ClutterActor *actor,
|
|||||||
|
|
||||||
|
|
||||||
/* delete to end of line */
|
/* delete to end of line */
|
||||||
if ((event->modifier_state & CLUTTER_CONTROL_MASK) &&
|
if ((state & CLUTTER_CONTROL_MASK) &&
|
||||||
(event->keyval == CLUTTER_KEY_k || event->keyval == CLUTTER_KEY_K))
|
(keyval == CLUTTER_KEY_k || keyval == CLUTTER_KEY_K))
|
||||||
{
|
{
|
||||||
ClutterTextBuffer *buffer = clutter_text_get_buffer ((ClutterText *)priv->entry);
|
ClutterTextBuffer *buffer = clutter_text_get_buffer ((ClutterText *)priv->entry);
|
||||||
int pos = clutter_text_get_cursor_position ((ClutterText *)priv->entry);
|
int pos = clutter_text_get_cursor_position ((ClutterText *)priv->entry);
|
||||||
@ -792,10 +797,11 @@ st_entry_enter_event (ClutterActor *actor,
|
|||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
ClutterActor *target;
|
ClutterActor *target;
|
||||||
|
|
||||||
stage = clutter_event_get_stage ((ClutterEvent *) event);
|
stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
|
||||||
target = clutter_stage_get_event_actor (stage, (ClutterEvent *) event);
|
target = clutter_stage_get_event_actor (stage, (ClutterEvent *) event);
|
||||||
|
|
||||||
if (target == priv->entry && event->related != NULL)
|
if (target == priv->entry &&
|
||||||
|
clutter_event_get_related ((ClutterEvent *) event) != NULL)
|
||||||
st_entry_set_cursor (ST_ENTRY (actor), TRUE);
|
st_entry_set_cursor (ST_ENTRY (actor), TRUE);
|
||||||
|
|
||||||
return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->enter_event (actor, event);
|
return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->enter_event (actor, event);
|
||||||
|
Loading…
Reference in New Issue
Block a user