[gtk+] a11y: Use GdkEvent API in some places
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] a11y: Use GdkEvent API in some places
- Date: Tue, 19 Sep 2017 17:18:06 +0000 (UTC)
commit efd287feb32d2ffbb50c2504c8c3c2f6fa2c491d
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 26 14:26:30 2017 -0400
a11y: Use GdkEvent API in some places
More work needed.
gtk/a11y/gtkaccessibility.c | 19 +++++++++++++------
gtk/a11y/gtkaccessibilityutil.c | 36 ++++++++++++++++++++++++------------
2 files changed, 37 insertions(+), 18 deletions(-)
---
diff --git a/gtk/a11y/gtkaccessibility.c b/gtk/a11y/gtkaccessibility.c
index 7f25442..928f866 100644
--- a/gtk/a11y/gtkaccessibility.c
+++ b/gtk/a11y/gtkaccessibility.c
@@ -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;
}
diff --git a/gtk/a11y/gtkaccessibilityutil.c b/gtk/a11y/gtkaccessibilityutil.c
index df6deb8..926e390 100644
--- a/gtk/a11y/gtkaccessibilityutil.c
+++ b/gtk/a11y/gtkaccessibilityutil.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]