[gtk/a11y/atspi] atspi: Fix collecting states



commit 61474b5a94e0ab10f54176ed1c398e27206eae37
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 12 21:16:03 2020 -0400

    atspi: Fix collecting states
    
    This is somewhat embarrassing.

 gtk/a11y/gtkatspicontext.c | 59 +++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index 32abb7e17e..348c794917 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -98,17 +98,17 @@ static GParamSpec *obj_props[N_PROPS];
 G_DEFINE_TYPE (GtkAtSpiContext, gtk_at_spi_context, GTK_TYPE_AT_CONTEXT)
 
 static void
-set_atspi_state (guint64        states,
-                 AtspiStateType state)
+set_atspi_state (guint64        *states,
+                 AtspiStateType  state)
 {
-  states |= (G_GUINT64_CONSTANT (1) << state);
+  *states |= (G_GUINT64_CONSTANT (1) << state);
 }
 
 static void
-unset_atspi_state (guint64        states,
-                   AtspiStateType state)
+unset_atspi_state (guint64        *states,
+                   AtspiStateType  state)
 {
-  states &= ~(G_GUINT64_CONSTANT (1) << state);
+  *states &= ~(G_GUINT64_CONSTANT (1) << state);
 }
 
 static void
@@ -122,55 +122,56 @@ collect_states (GtkAtSpiContext    *self,
 
   widget = GTK_WIDGET (gtk_at_context_get_accessible (ctx));
 
-  set_atspi_state (states, ATSPI_STATE_VISIBLE);
+  set_atspi_state (&states, ATSPI_STATE_VISIBLE);
 
-  if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX)
-    set_atspi_state (states, ATSPI_STATE_EDITABLE);
+  if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX ||
+      ctx->accessible_role == GTK_ACCESSIBLE_ROLE_SEARCH_BOX)
+    set_atspi_state (&states, ATSPI_STATE_EDITABLE);
 
   if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_READ_ONLY))
     {
       value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_READ_ONLY);
       if (gtk_boolean_accessible_value_get (value))
         {
-          set_atspi_state (states, ATSPI_STATE_READ_ONLY);
-          unset_atspi_state (states, ATSPI_STATE_EDITABLE);
+          set_atspi_state (&states, ATSPI_STATE_READ_ONLY);
+          unset_atspi_state (&states, ATSPI_STATE_EDITABLE);
         }
     }
 
   if (gtk_widget_get_focusable (widget))
-    set_atspi_state (states, ATSPI_STATE_FOCUSABLE);
+    set_atspi_state (&states, ATSPI_STATE_FOCUSABLE);
 
   if (gtk_widget_has_focus (widget))
-    set_atspi_state (states, ATSPI_STATE_FOCUSED);
+    set_atspi_state (&states, ATSPI_STATE_FOCUSED);
 
   if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_ORIENTATION))
     {
       value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_ORIENTATION);
       if (gtk_orientation_accessible_value_get (value) == GTK_ORIENTATION_HORIZONTAL)
-        set_atspi_state (states, ATSPI_STATE_HORIZONTAL);
+        set_atspi_state (&states, ATSPI_STATE_HORIZONTAL);
       else
-        set_atspi_state (states, ATSPI_STATE_VERTICAL);
+        set_atspi_state (&states, ATSPI_STATE_VERTICAL);
     }
 
   if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MODAL))
     {
       value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MODAL);
       if (gtk_boolean_accessible_value_get (value))
-        set_atspi_state (states, ATSPI_STATE_MODAL);
+        set_atspi_state (&states, ATSPI_STATE_MODAL);
     }
 
   if (gtk_at_context_has_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MULTI_LINE))
     {
       value = gtk_at_context_get_accessible_property (ctx, GTK_ACCESSIBLE_PROPERTY_MULTI_LINE);
       if (gtk_boolean_accessible_value_get (value))
-        set_atspi_state (states, ATSPI_STATE_MULTI_LINE);
+        set_atspi_state (&states, ATSPI_STATE_MULTI_LINE);
     }
 
   if (gtk_at_context_has_accessible_state (ctx, GTK_ACCESSIBLE_STATE_BUSY))
     {
       value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_BUSY);
       if (gtk_boolean_accessible_value_get (value))
-        set_atspi_state (states, ATSPI_STATE_BUSY);
+        set_atspi_state (&states, ATSPI_STATE_BUSY);
     }
 
   if (gtk_at_context_has_accessible_state (ctx, GTK_ACCESSIBLE_STATE_CHECKED))
@@ -179,10 +180,10 @@ collect_states (GtkAtSpiContext    *self,
       switch (gtk_tristate_accessible_value_get (value))
         {
         case GTK_ACCESSIBLE_TRISTATE_TRUE:
-          set_atspi_state (states, ATSPI_STATE_CHECKED);
+          set_atspi_state (&states, ATSPI_STATE_CHECKED);
           break;
         case GTK_ACCESSIBLE_TRISTATE_MIXED:
-          set_atspi_state (states, ATSPI_STATE_INDETERMINATE);
+          set_atspi_state (&states, ATSPI_STATE_INDETERMINATE);
           break;
         case GTK_ACCESSIBLE_TRISTATE_FALSE:
         default:
@@ -194,19 +195,19 @@ collect_states (GtkAtSpiContext    *self,
     {
       value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_DISABLED);
       if (!gtk_boolean_accessible_value_get (value))
-        set_atspi_state (states, ATSPI_STATE_SENSITIVE);
+        set_atspi_state (&states, ATSPI_STATE_SENSITIVE);
     }
   else
-    set_atspi_state (states, ATSPI_STATE_SENSITIVE);
+    set_atspi_state (&states, ATSPI_STATE_SENSITIVE);
 
   if (gtk_at_context_has_accessible_state (ctx, GTK_ACCESSIBLE_STATE_EXPANDED))
     {
       value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_EXPANDED);
       if (value->value_class->type == GTK_ACCESSIBLE_VALUE_TYPE_BOOLEAN)
         {
-          set_atspi_state (states, ATSPI_STATE_EXPANDABLE);
+          set_atspi_state (&states, ATSPI_STATE_EXPANDABLE);
           if (gtk_boolean_accessible_value_get (value))
-            set_atspi_state (states, ATSPI_STATE_EXPANDED);
+            set_atspi_state (&states, ATSPI_STATE_EXPANDED);
         }
     }
 
@@ -218,7 +219,7 @@ collect_states (GtkAtSpiContext    *self,
         case GTK_ACCESSIBLE_INVALID_TRUE:
         case GTK_ACCESSIBLE_INVALID_GRAMMAR:
         case GTK_ACCESSIBLE_INVALID_SPELLING:
-          set_atspi_state (states, ATSPI_STATE_INVALID);
+          set_atspi_state (&states, ATSPI_STATE_INVALID);
           break;
         case GTK_ACCESSIBLE_INVALID_FALSE:
         default:
@@ -232,10 +233,10 @@ collect_states (GtkAtSpiContext    *self,
       switch (gtk_tristate_accessible_value_get (value))
         {
         case GTK_ACCESSIBLE_TRISTATE_TRUE:
-          set_atspi_state (states, ATSPI_STATE_PRESSED);
+          set_atspi_state (&states, ATSPI_STATE_PRESSED);
           break;
         case GTK_ACCESSIBLE_TRISTATE_MIXED:
-          set_atspi_state (states, ATSPI_STATE_INDETERMINATE);
+          set_atspi_state (&states, ATSPI_STATE_INDETERMINATE);
           break;
         case GTK_ACCESSIBLE_TRISTATE_FALSE:
         default:
@@ -248,9 +249,9 @@ collect_states (GtkAtSpiContext    *self,
       value = gtk_at_context_get_accessible_state (ctx, GTK_ACCESSIBLE_STATE_SELECTED);
       if (value->value_class->type == GTK_ACCESSIBLE_VALUE_TYPE_BOOLEAN)
         {
-          set_atspi_state (states, ATSPI_STATE_SELECTABLE);
+          set_atspi_state (&states, ATSPI_STATE_SELECTABLE);
           if (gtk_boolean_accessible_value_get (value))
-            set_atspi_state (states, ATSPI_STATE_SELECTED);
+            set_atspi_state (&states, ATSPI_STATE_SELECTED);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]