mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-10 04:30:11 +00:00
a11y: Use GdkEvent API in some places
More work needed.
This commit is contained in:
parent
853602bf63
commit
efd287feb3
@ -148,6 +148,7 @@ gail_focus_watcher (GSignalInvocationHint *ihint,
|
|||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GdkEvent *event;
|
GdkEvent *event;
|
||||||
GdkEventType event_type;
|
GdkEventType event_type;
|
||||||
|
gboolean focus_in;
|
||||||
|
|
||||||
object = g_value_get_object (param_values + 0);
|
object = g_value_get_object (param_values + 0);
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);
|
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);
|
event = g_value_get_boxed (param_values + 1);
|
||||||
widget = GTK_WIDGET (object);
|
widget = GTK_WIDGET (object);
|
||||||
event_type = gdk_event_get_event_type (event);
|
event_type = gdk_event_get_event_type (event);
|
||||||
|
gdk_event_get_focus_in (event, &focus_in);
|
||||||
|
|
||||||
if (event_type == GDK_FOCUS_CHANGE)
|
if (event_type == GDK_FOCUS_CHANGE)
|
||||||
{
|
{
|
||||||
if (event->focus_change.in)
|
if (focus_in)
|
||||||
{
|
{
|
||||||
if (GTK_IS_WINDOW (widget))
|
if (GTK_IS_WINDOW (widget))
|
||||||
{
|
{
|
||||||
@ -802,8 +804,9 @@ state_event_watcher (GSignalInvocationHint *hint,
|
|||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
AtkObject *atk_obj;
|
AtkObject *atk_obj;
|
||||||
AtkObject *parent;
|
AtkObject *parent;
|
||||||
GdkEventWindowState *event;
|
GdkEvent *event;
|
||||||
const char *signal_name;
|
const char *signal_name;
|
||||||
|
GdkWindowState changed, new_state;
|
||||||
|
|
||||||
object = g_value_get_object (param_values + 0);
|
object = g_value_get_object (param_values + 0);
|
||||||
if (!GTK_IS_WINDOW (object))
|
if (!GTK_IS_WINDOW (object))
|
||||||
@ -814,11 +817,13 @@ state_event_watcher (GSignalInvocationHint *hint,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
widget = GTK_WIDGET (object);
|
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";
|
signal_name = "maximize";
|
||||||
else if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)
|
else if (new_state & GDK_WINDOW_STATE_ICONIFIED)
|
||||||
signal_name = "minimize";
|
signal_name = "minimize";
|
||||||
else if (event->new_window_state == 0)
|
else if (new_state == 0)
|
||||||
signal_name = "restore";
|
signal_name = "restore";
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -889,11 +894,13 @@ window_focus (GtkWidget *widget,
|
|||||||
GdkEventFocus *event)
|
GdkEventFocus *event)
|
||||||
{
|
{
|
||||||
AtkObject *atk_obj;
|
AtkObject *atk_obj;
|
||||||
|
gboolean focus_in;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
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);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -112,25 +112,37 @@ static void
|
|||||||
atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
atk_key_event_from_gdk_event_key (GdkEventKey *key,
|
||||||
AtkKeyEventStruct *event)
|
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;
|
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;
|
event->type = ATK_KEY_EVENT_RELEASE;
|
||||||
else
|
else
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
|
||||||
event->state = key->state;
|
event->state = state;
|
||||||
event->keyval = key->keyval;
|
event->keyval = keyval;
|
||||||
event->length = key->length;
|
if (string && string[0] &&
|
||||||
if (key->string && key->string[0] &&
|
(state & GDK_CONTROL_MASK ||
|
||||||
(key->state & GDK_CONTROL_MASK ||
|
g_unichar_isgraph (g_utf8_get_char (string))))
|
||||||
g_unichar_isgraph (g_utf8_get_char (key->string))))
|
event->string = string;
|
||||||
event->string = key->string;
|
|
||||||
else
|
else
|
||||||
event->string = gdk_keyval_name (key->keyval);
|
event->string = gdk_keyval_name (keyval);
|
||||||
|
|
||||||
event->keycode = key->hardware_keycode;
|
event->length = strlen (string);
|
||||||
event->timestamp = key->time;
|
event->keycode = keycode;
|
||||||
|
event->timestamp = gdk_event_get_time ((GdkEvent *)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user