From 62f31015fce027b5067cf5bce591214e3585873c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Fri, 23 Mar 2018 18:33:58 +0100 Subject: [PATCH] a11y: restore window:activate/deactivate emission 1b9aa1b708c2 ('a11y: drop the focus tracker') removed a bit too much. We still have to emit window:activate/deactivate events. They are easy to emit anyway. Fixes #127 --- gtk/a11y/gtkaccessibility.h | 9 ++++++--- gtk/a11y/gtkwindowaccessible.c | 15 +++++++++++++++ gtk/gtkwindow.c | 1 + 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gtk/a11y/gtkaccessibility.h b/gtk/a11y/gtkaccessibility.h index c3df055dec..a62a13f8b1 100644 --- a/gtk/a11y/gtkaccessibility.h +++ b/gtk/a11y/gtkaccessibility.h @@ -23,10 +23,13 @@ G_BEGIN_DECLS -void _gtk_accessibility_init (void); +void _gtk_accessibility_init (void); -gboolean _gtk_accessibility_key_snooper (GtkWidget *widget, - GdkEventKey *event); +gboolean _gtk_accessibility_key_snooper (GtkWidget *widget, + GdkEventKey *event); + +void _gtk_window_accessible_set_is_active (GtkWindow *window, + gboolean is_active); G_END_DECLS diff --git a/gtk/a11y/gtkwindowaccessible.c b/gtk/a11y/gtkwindowaccessible.c index aeb0ee961d..a05f5942cf 100644 --- a/gtk/a11y/gtkwindowaccessible.c +++ b/gtk/a11y/gtkwindowaccessible.c @@ -20,9 +20,11 @@ #include +#include "gtkaccessibility.h" #include "gtkwidgetaccessibleprivate.h" #include "gtkwindowaccessible.h" #include "gtktoplevelaccessible.h" +#include "gtkwidgetprivate.h" #include "gtkwindowprivate.h" /* atkcomponent.h */ @@ -442,6 +444,19 @@ gtk_window_accessible_get_size (AtkComponent *component, *height = rect.height; } +void +_gtk_window_accessible_set_is_active (GtkWindow *window, + gboolean is_active) +{ + AtkObject *accessible = _gtk_widget_peek_accessible (GTK_WIDGET (window)); + + if (accessible == NULL) + return; + + g_signal_emit_by_name (accessible, is_active ? "activate" : "deactivate"); +} + + static void atk_component_interface_init (AtkComponentIface *iface) { diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index c5ef1ec4f3..9e2cfc2363 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -10472,6 +10472,7 @@ _gtk_window_set_is_active (GtkWindow *window, } g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]); + _gtk_window_accessible_set_is_active (window, is_active); } }