a11y: Use GdkEvent API in some places

More work needed.
This commit is contained in:
Matthias Clasen 2017-08-26 14:26:30 -04:00 committed by Carlos Garnacho
parent 853602bf63
commit efd287feb3
2 changed files with 37 additions and 18 deletions

View File

@ -148,6 +148,7 @@ gail_focus_watcher (GSignalInvocationHint *ihint,
GtkWidget *widget;
GdkEvent *event;
GdkEventType event_type;
gboolean focus_in;
object = g_value_get_object (param_values + 0);
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
@ -155,10 +156,11 @@ gail_focus_watcher (GSignalInvocationHint *ihint,
event = g_value_get_boxed (param_values + 1);
widget = GTK_WIDGET (object);
event_type = gdk_event_get_event_type (event);
gdk_event_get_focus_in (event, &focus_in);
if (event_type == GDK_FOCUS_CHANGE)
{
if (event->focus_change.in)
if (focus_in)
{
if (GTK_IS_WINDOW (widget))
{
@ -802,8 +804,9 @@ state_event_watcher (GSignalInvocationHint *hint,
GtkWidget *widget;
AtkObject *atk_obj;
AtkObject *parent;
GdkEventWindowState *event;
GdkEvent *event;
const char *signal_name;
GdkWindowState changed, new_state;
object = g_value_get_object (param_values + 0);
if (!GTK_IS_WINDOW (object))
@ -814,11 +817,13 @@ state_event_watcher (GSignalInvocationHint *hint,
return FALSE;
widget = GTK_WIDGET (object);
if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
gdk_event_get_window_state (event, &changed, &new_state);
if (new_state & GDK_WINDOW_STATE_MAXIMIZED)
signal_name = "maximize";
else if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)
else if (new_state & GDK_WINDOW_STATE_ICONIFIED)
signal_name = "minimize";
else if (event->new_window_state == 0)
else if (new_state == 0)
signal_name = "restore";
else
return TRUE;
@ -889,11 +894,13 @@ window_focus (GtkWidget *widget,
GdkEventFocus *event)
{
AtkObject *atk_obj;
gboolean focus_in;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
gdk_event_get_focus_in ((GdkEvent *)event, &focus_in);
atk_obj = gtk_widget_get_accessible (widget);
g_signal_emit_by_name (atk_obj, event->in ? "activate" : "deactivate");
g_signal_emit_by_name (atk_obj, focus_in ? "activate" : "deactivate");
return FALSE;
}

View File

@ -112,25 +112,37 @@ static void
atk_key_event_from_gdk_event_key (GdkEventKey *key,
AtkKeyEventStruct *event)
{
if (key->type == GDK_KEY_PRESS)
GdkEventType type;
GdkModifierType state;
guint keyval;
guint16 keycode;
const char *string;
type = gdk_event_get_event_type ((GdkEvent *)key);
gdk_event_get_state ((GdkEvent *)key, &state);
gdk_event_get_keyval ((GdkEvent *)key, &keyval);
gdk_event_get_keycode ((GdkEvent *)key, &keycode);
gdk_event_get_string ((GdkEvent *)key, &string);
if (type == GDK_KEY_PRESS)
event->type = ATK_KEY_EVENT_PRESS;
else if (key->type == GDK_KEY_RELEASE)
else if (type == GDK_KEY_RELEASE)
event->type = ATK_KEY_EVENT_RELEASE;
else
g_assert_not_reached ();
event->state = key->state;
event->keyval = key->keyval;
event->length = key->length;
if (key->string && key->string[0] &&
(key->state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (key->string))))
event->string = key->string;
event->state = state;
event->keyval = keyval;
if (string && string[0] &&
(state & GDK_CONTROL_MASK ||
g_unichar_isgraph (g_utf8_get_char (string))))
event->string = string;
else
event->string = gdk_keyval_name (key->keyval);
event->string = gdk_keyval_name (keyval);
event->keycode = key->hardware_keycode;
event->timestamp = key->time;
event->length = strlen (string);
event->keycode = keycode;
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
}
gboolean