[java-atk-wrapper] Wrapper: remove state ARMED condition



commit 82d33514d415f581d3ad91604f05e5b1b97ed08c
Author: Magdalen Berns <m berns thismagpie com>
Date:   Fri Feb 27 20:38:16 2015 +0000

    Wrapper: remove state ARMED condition
    
    Only dispatch focus when the state is selected or focused
    
    Bug:https://bugzilla.gnome.org/show_bug.cgi?id=745309

 jni/src/AtkWrapper.c                               |    6 +-
 jni/src/jawcomponent.c                             |   97 +++++--------------
 jni/src/jawimpl.c                                  |   10 +--
 jni/src/jawutil.c                                  |    9 ++
 jni/src/jawutil.h                                  |    2 +
 wrapper/org/GNOME/Accessibility/AtkComponent.java  |   10 +-
 wrapper/org/GNOME/Accessibility/AtkWrapper.java.in |   29 +-----
 7 files changed, 56 insertions(+), 107 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index 440daef..553d76e 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -792,7 +792,8 @@ signal_emit_handler (gpointer p)
   if (jaw_impl == NULL)
   {
     g_warning("\n *** signal_emit_handler: jaw_impl == NULL *** \n");
-    free_callback_para(para);
+    //free_callback_para(para);
+    jaw_util_detach();
     return FALSE;
   }
 
@@ -1031,6 +1032,7 @@ signal_emit_handler (gpointer p)
     break;
   }
   free_callback_para(para);
+  jaw_util_detach();
   return FALSE;
 }
 
@@ -1292,7 +1294,7 @@ key_dispatch_handler (gpointer p)
   jfieldID jfidString = (*jniEnv)->GetFieldID(jniEnv, classAtkKeyEvent, "string", "Ljava/lang/String;");
   jstring jstr = (jstring)(*jniEnv)->GetObjectField(jniEnv, jAtkKeyEvent, jfidString);
   event->length = (gint)(*jniEnv)->GetStringLength(jniEnv, jstr);
-  event->string = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL);
+  event->string = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, jstr, 0);
 
   // keycode
   jfieldID jfidKeycode = (*jniEnv)->GetFieldID(jniEnv, classAtkKeyEvent, "keycode", "I");
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index bf1697f..b6f4827 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -51,15 +51,6 @@ static gboolean jaw_component_set_extents(AtkComponent *component,
                                           gint         height,
                                           AtkCoordType coord_type);
 
-static void jaw_component_get_position(AtkComponent *component,
-                                       gint         *x,
-                                       gint         *y,
-                                       AtkCoordType coord_type);
-
-static void jaw_component_get_size(AtkComponent *component,
-                                   gint         *width,
-                                   gint         *height);
-
 static gboolean jaw_component_grab_focus(AtkComponent *component);
 static AtkLayer jaw_component_get_layer(AtkComponent *component);
 /*static gint          jaw_component_get_mdi_zorder            (AtkComponent           *component);
@@ -75,8 +66,6 @@ jaw_component_interface_init (AtkComponentIface *iface)
   iface->contains = jaw_component_contains;
   iface->ref_accessible_at_point = jaw_component_ref_accessible_at_point;
   iface->get_extents = jaw_component_get_extents;
-  iface->get_position = jaw_component_get_position;
-  iface->get_size = jaw_component_get_size;
   iface->grab_focus = jaw_component_grab_focus;
   iface->add_focus_handler = NULL;
   iface->remove_focus_handler = NULL;
@@ -210,20 +199,11 @@ jaw_component_get_extents (AtkComponent *component,
                            gint         *height,
                            AtkCoordType coord_type)
 {
-  jaw_component_get_position (component, x, y, coord_type);
-  jaw_component_get_size (component, width, height);
-}
+  if (x == NULL || y == NULL || width == NULL || height == NULL)
+    return;
 
-static void
-jaw_component_get_position (AtkComponent *component,
-                            gint         *x,
-                            gint         *y,
-                            AtkCoordType coord_type)
-{
-  if (x == NULL || y == NULL)
-  {
+  if (component == NULL)
     return;
-  }
 
   JawObject *jaw_obj = JAW_OBJECT(component);
   ComponentData *data = jaw_object_get_interface_data(jaw_obj,
@@ -235,62 +215,30 @@ jaw_component_get_position (AtkComponent *component,
                                                   "org/GNOME/Accessibility/AtkComponent");
   jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
                                           classAtkComponent,
-                                          "get_position",
-                                          "(I)Ljava/awt/Point;");
-  jobject jpoint = (*jniEnv)->CallObjectMethod(jniEnv,
-                                               atk_component,
-                                               jmid, (jint)coord_type);
+                                          "get_extents",
+                                          "()Ljava/awt/Rectangle;");
+
+  jobject jrectangle = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
 
-  if (jpoint == NULL)
+  if (jrectangle == NULL)
   {
     (*x) = 0;
     (*y) = 0;
-    return;
-  }
-
-  jclass classPoint = (*jniEnv)->FindClass(jniEnv, "java/awt/Point");
-  jfieldID jfidX = (*jniEnv)->GetFieldID(jniEnv, classPoint, "x", "I");
-  jfieldID jfidY = (*jniEnv)->GetFieldID(jniEnv, classPoint, "y", "I");
-  jint jx = (*jniEnv)->GetIntField(jniEnv, jpoint, jfidX);
-  jint jy = (*jniEnv)->GetIntField(jniEnv, jpoint, jfidY);
-
-  (*x) = (gint)jx;
-  (*y) = (gint)jy;
-}
-
-static void
-jaw_component_get_size (AtkComponent *component, gint *width, gint *height)
-{
-  JawObject *jaw_obj = JAW_OBJECT(component);
-  ComponentData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_COMPONENT);
-  jobject atk_component = data->atk_component;
-
-  JNIEnv *jniEnv = jaw_util_get_jni_env();
-  jclass classAtkComponent = (*jniEnv)->FindClass(jniEnv,
-                                                  "org/GNOME/Accessibility/AtkComponent");
-
-  jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
-                                          classAtkComponent,
-                                          "get_size",
-                                          "()Ljava/awt/Dimension;");
-
-  jobject jdimension = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
-
-  if (jdimension == NULL)
-  {
     (*width) = 0;
     (*height) = 0;
     return;
   }
 
-  jclass classDimension = (*jniEnv)->FindClass(jniEnv, "java/awt/Dimension");
-  jfieldID jfidWidth = (*jniEnv)->GetFieldID(jniEnv, classDimension, "width", "I");
-  jfieldID jfidHeight = (*jniEnv)->GetFieldID(jniEnv, classDimension, "height", "I");
-  jint jwidth = (*jniEnv)->GetIntField(jniEnv, jdimension, jfidWidth);
-  jint jheight = (*jniEnv)->GetIntField(jniEnv, jdimension, jfidHeight);
-
-  (*width) = (gint)jwidth;
-  (*height) = (gint)jheight;
+  jclass classRectangle = (*jniEnv)->FindClass(jniEnv, "java/awt/Rectangle");
+  jfieldID jfidX = (*jniEnv)->GetFieldID(jniEnv, classRectangle, "x", "I");
+  jfieldID jfidY = (*jniEnv)->GetFieldID(jniEnv, classRectangle, "y", "I");
+  jfieldID jfidW = (*jniEnv)->GetFieldID(jniEnv, classRectangle, "width", "I");
+  jfieldID jfidH = (*jniEnv)->GetFieldID(jniEnv, classRectangle, "height", "I");
+  (*x)      = (gint)(*jniEnv)->GetIntField(jniEnv, jrectangle, jfidX);
+  (*y)      = (gint)(*jniEnv)->GetIntField(jniEnv, jrectangle, jfidY);
+  (*width)  = (gint)(*jniEnv)->GetIntField(jniEnv, jrectangle, jfidW);
+  (*height) = (gint)(*jniEnv)->GetIntField(jniEnv, jrectangle, jfidH);
+  jaw_util_detach();
 }
 
 static gboolean
@@ -315,7 +263,14 @@ jaw_component_set_extents (AtkComponent *component,
                                           "set_extents",
                                           "()Ljava/awt/Rectangle;");
 
-  jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
+  jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv,
+                                                   atk_component,
+                                                   jmid,
+                                                   (jint)x,
+                                                   (jint)y,
+                                                   (jint)width,
+                                                   (jint)height,
+                                                   (jint)coord_type);
 
   if (jcomponent == NULL)
   {
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 348043a..347c67e 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -263,19 +263,15 @@ jaw_impl_get_instance (JNIEnv *jniEnv, jobject ac)
           printf("\n *** JAW_OBJECT == NULL *** jaw_impl_get_instance: %s \n",
                  (char *) (ATK_OBJECT(jaw_obj)));
         }
-      } else {
-        printf("\n *** JAW_IMPL == NULL ***  jaw_impl_get_instance: %s \n",
-               (char *) ATK_OBJECT(jaw_impl));
       }
+    } else {
+      printf("\n *** jaw_impl_get_instance: global_ac == NULL ***");
     }
   }
   if (jaw_impl != NULL)
-  {
     return jaw_impl;
-  }
-  else {
+  else
     printf("\n *** JAW_IMPL == NULL *** jaw_impl_get_instance\n");
-  }
   return NULL;
 }
 
diff --git a/jni/src/jawutil.c b/jni/src/jawutil.c
index fa0d5f3..700e00e 100644
--- a/jni/src/jawutil.c
+++ b/jni/src/jawutil.c
@@ -490,6 +490,15 @@ jaw_util_get_jni_env(void)
   return NULL;
 }
 
+
+void
+jaw_util_detach(void)
+{
+  JavaVM* jvm;
+  jvm = cachedJVM;
+  (*jvm)->DetachCurrentThread(jvm);
+}
+
 static jobject
 jaw_util_get_java_acc_role (JNIEnv *jniEnv, const gchar* roleName)
 {
diff --git a/jni/src/jawutil.h b/jni/src/jawutil.h
index fceb182..36872c2 100644
--- a/jni/src/jawutil.h
+++ b/jni/src/jawutil.h
@@ -66,6 +66,8 @@ struct _JawUtilClass
 guint jaw_util_get_tflag_from_jobj(JNIEnv *jniEnv, jobject jObj);
 gboolean jaw_util_is_same_jobject(gconstpointer a, gconstpointer b);
 JNIEnv* jaw_util_get_jni_env(void);
+void jaw_util_detach(void);
+
 AtkRole jaw_util_get_atk_role_from_jobj(jobject jobj);
 AtkStateType jaw_util_get_atk_state_type_from_java_state(JNIEnv *jniEnv, jobject jobj);
 void jaw_util_get_rect_info(JNIEnv *jniEnv,
diff --git a/wrapper/org/GNOME/Accessibility/AtkComponent.java 
b/wrapper/org/GNOME/Accessibility/AtkComponent.java
index 97e0ce8..202635f 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -78,11 +78,8 @@ public class AtkComponent {
     return acc_component.getLocation();
   }
 
-  public Dimension get_size () {
-    return acc_component.getSize();
-  }
-
   public Rectangle set_extents(int x, int y, int width, int height, int coord_type) {
+       
     this.width  = (int)acc_component.getSize().getWidth();
     this.height = (int)acc_component.getSize().getHeight();
 
@@ -93,9 +90,14 @@ public class AtkComponent {
       this.x -= p.x;
       this.y -= p.y;
     }
+    acc_component.setBounds(new Rectangle(x, y, width, height));
     return new Rectangle(x, y, width, height);
   }
 
+  public Rectangle get_extents() {
+    return acc_component.getBounds();
+  }
+
   public int get_layer () {
     AccessibleRole role = ac.getAccessibleRole();
 
diff --git a/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in 
b/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
index c5ba31d..34cbc7c 100644
--- a/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
+++ b/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
@@ -28,7 +28,6 @@ import javax.accessibility.*;
 import java.awt.Toolkit;
 
 public class AtkWrapper {
-  public native void AtkWrapper();
   static boolean accessibilityEnabled = false;
   static {
     try {
@@ -450,6 +449,7 @@ public class AtkWrapper {
         } else if( propertyName.equals(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY) ) {
           boolean isTextEvent = false;
           AccessibleRole role = ac.getAccessibleRole();
+          System.out.println(role);
           if ((role == AccessibleRole.TEXT) ||
               role.toDisplayString(java.util.Locale.US).equalsIgnoreCase("paragraph")) {
             isTextEvent = true;
@@ -524,31 +524,14 @@ public class AtkWrapper {
         if (parent != null) {
           parent_role = parent.getAccessibleContext().getAccessibleRole();
         }
-
-        if (newValue == javax.accessibility.AccessibleState.ARMED) {
-          if (role != null) {
-            if (role == javax.accessibility.AccessibleRole.MENU_ITEM ||
-                role == javax.accessibility.AccessibleRole.MENU) {
-              dispatchFocusEvent(o);
-            } else if (parent_role != null &&
-              (parent_role == javax.accessibility.AccessibleRole.MENU &&
-               (role == javax.accessibility.AccessibleRole.CHECK_BOX ||
-                role == javax.accessibility.AccessibleRole.RADIO_BUTTON ||
-                role == javax.accessibility.AccessibleRole.PUSH_BUTTON ||
-                role == javax.accessibility.AccessibleRole.TOGGLE_BUTTON))) {
-              dispatchFocusEvent(o);
-            }
+        if (role != null) {
+          if (newValue == javax.accessibility.AccessibleState.FOCUSED ||
+              newValue == javax.accessibility.AccessibleState.SELECTED) {
+            dispatchFocusEvent(o);
           }
-        } else if (newValue == javax.accessibility.AccessibleState.SELECTED &&
-                               o instanceof AccessibleContext &&
-                               role == javax.accessibility.AccessibleRole.MENU) {
-          dispatchFocusEvent(o);
-        } else if (newValue == javax.accessibility.AccessibleState.FOCUSED) {
-          dispatchFocusEvent(o);
         }
-
         AccessibleState state;
-        boolean value;
+        boolean value = false;
         if (newValue != null) {
           state = (AccessibleState)newValue;
           value = true;


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