From f019a325efe22e1c6ea6cbfba04fa1cc80f6867e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 18 Jan 2024 15:22:26 -0300 Subject: [PATCH 1/6] atcontext: Use size_t for loop iterator G_N_ELEMENTS() returns a division of two size_t values, which results in a size_t value. This is just a cleanup, no functional change. --- gtk/gtkatcontext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 1b925def66..4c4dd5a22f 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -663,7 +663,7 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, GtkATContext *res = NULL; - for (guint i = 0; i < G_N_ELEMENTS (a11y_backends); i++) + for (size_t i = 0; i < G_N_ELEMENTS (a11y_backends); i++) { if (a11y_backends[i].name == NULL) break; From c8299f5b3e35b7d6c54ed18b3b761ec6ae377b93 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 18 Jan 2024 15:23:35 -0300 Subject: [PATCH 2/6] atcontext: Move variable declaration to top This conforms better to the GTK C coding style. --- gtk/gtkatcontext.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 4c4dd5a22f..f5c487a974 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -634,6 +634,7 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, GdkDisplay *display) { static const char *gtk_a11y_env; + GtkATContext *res = NULL; if (gtk_a11y_env == NULL) { @@ -661,8 +662,6 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, if (g_ascii_strcasecmp (gtk_a11y_env, "none") == 0) return NULL; - GtkATContext *res = NULL; - for (size_t i = 0; i < G_N_ELEMENTS (a11y_backends); i++) { if (a11y_backends[i].name == NULL) From 9fb37229a164f04325e97057d6d186f9e563db4f Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 18 Jan 2024 15:24:09 -0300 Subject: [PATCH 3/6] atcontext: Remove end sentinel from array This array is iterated using G_N_ELEMENTS(), which means it always iterates a well known number of times. Remove the sentinel. --- gtk/gtkatcontext.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index f5c487a974..42260471b8 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -611,7 +611,6 @@ static const struct { { "AT-SPI (X11)", "atspi", gtk_at_spi_create_context }, #endif { "Test", "test", gtk_test_at_context_new }, - { NULL, NULL, NULL }, }; /** @@ -664,8 +663,7 @@ gtk_at_context_create (GtkAccessibleRole accessible_role, for (size_t i = 0; i < G_N_ELEMENTS (a11y_backends); i++) { - if (a11y_backends[i].name == NULL) - break; + g_assert (a11y_backends[i].name != NULL); if (a11y_backends[i].create_context != NULL && (*gtk_a11y_env == '0' || g_ascii_strcasecmp (a11y_backends[i].env_name, gtk_a11y_env) == 0)) From 4ce9f9b3ac1fd2ae4a19e8b786fdf502b99adb61 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 20 Jan 2024 11:28:59 -0300 Subject: [PATCH 4/6] gtk/atcontext: Cleanup a11y backends list Declaring a separate entry for Wayland and X11 is not very useful when both just end up calling the same constructor. Also, in theory, this can cause the Wayland entry to be picked up on X11 if both backends are enabled (which is the common case). Not that it matters, since the 'name' field is unused. Nonetheless, clean it up to be a single entry --- gtk/gtkatcontext.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 42260471b8..e1f6cd981a 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -604,11 +604,8 @@ static const struct { GtkAccessible *accessible, GdkDisplay *display); } a11y_backends[] = { -#if defined(GDK_WINDOWING_WAYLAND) - { "AT-SPI (Wayland)", "atspi", gtk_at_spi_create_context }, -#endif -#if defined(GDK_WINDOWING_X11) - { "AT-SPI (X11)", "atspi", gtk_at_spi_create_context }, +#if defined(GDK_WINDOWING_WAYLAND) || defined(GDK_WINDOWING_X11) + { "AT-SPI", "atspi", gtk_at_spi_create_context }, #endif { "Test", "test", gtk_test_at_context_new }, }; From 296d44159b899cf3f09c3ceacca833426856956e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 20 Jan 2024 16:16:33 -0300 Subject: [PATCH 5/6] a11y/atspi/root: Chain up to finalize The gtk_at_spi_root_finalize() function currently chains up to dispose(), which is probably a copy-paste mistake since gtk_at_spi_root_dispose() exists and also chains up to dispose(). Chain up to finalize(). --- gtk/a11y/gtkatspiroot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c index d3b488b0ae..8727851add 100644 --- a/gtk/a11y/gtkatspiroot.c +++ b/gtk/a11y/gtkatspiroot.c @@ -96,7 +96,7 @@ gtk_at_spi_root_finalize (GObject *gobject) g_free (self->desktop_name); g_free (self->desktop_path); - G_OBJECT_CLASS (gtk_at_spi_root_parent_class)->dispose (gobject); + G_OBJECT_CLASS (gtk_at_spi_root_parent_class)->finalize (gobject); } static void From d337eed6435d3d11d59bea48e84b30b9548aec56 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 23 Jan 2024 18:40:47 -0300 Subject: [PATCH 6/6] a11y/atspicontext: Remove empty constructed override It does nothing. --- gtk/a11y/gtkatspicontext.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 09fbc34cf4..e09b245e82 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -1401,14 +1401,6 @@ gtk_at_spi_context_finalize (GObject *gobject) G_OBJECT_CLASS (gtk_at_spi_context_parent_class)->finalize (gobject); } -static void -gtk_at_spi_context_constructed (GObject *gobject) -{ - GtkAtSpiContext *self G_GNUC_UNUSED = GTK_AT_SPI_CONTEXT (gobject); - - G_OBJECT_CLASS (gtk_at_spi_context_parent_class)->constructed (gobject); -} - static const char *get_bus_address (GdkDisplay *display); static void @@ -1516,7 +1508,6 @@ gtk_at_spi_context_class_init (GtkAtSpiContextClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkATContextClass *context_class = GTK_AT_CONTEXT_CLASS (klass); - gobject_class->constructed = gtk_at_spi_context_constructed; gobject_class->finalize = gtk_at_spi_context_finalize; context_class->realize = gtk_at_spi_context_realize;