[java-atk-wrapper] Revert "Wrapper: remove state ARMED condition"
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] Revert "Wrapper: remove state ARMED condition"
- Date: Fri, 27 Feb 2015 21:06:42 +0000 (UTC)
commit 443947db509039c4d029ad23ad22a2e0b8557536
Author: Magdalen Berns <m berns thismagpie com>
Date: Fri Feb 27 21:06:04 2015 +0000
Revert "Wrapper: remove state ARMED condition"
This reverts commit 82d33514d415f581d3ad91604f05e5b1b97ed08c.
accidentally did a commit -a
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, 107 insertions(+), 56 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index 553d76e..440daef 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -792,8 +792,7 @@ signal_emit_handler (gpointer p)
if (jaw_impl == NULL)
{
g_warning("\n *** signal_emit_handler: jaw_impl == NULL *** \n");
- //free_callback_para(para);
- jaw_util_detach();
+ free_callback_para(para);
return FALSE;
}
@@ -1032,7 +1031,6 @@ signal_emit_handler (gpointer p)
break;
}
free_callback_para(para);
- jaw_util_detach();
return FALSE;
}
@@ -1294,7 +1292,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, 0);
+ event->string = (gchar*)(*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL);
// keycode
jfieldID jfidKeycode = (*jniEnv)->GetFieldID(jniEnv, classAtkKeyEvent, "keycode", "I");
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index b6f4827..bf1697f 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -51,6 +51,15 @@ 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);
@@ -66,6 +75,8 @@ 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;
@@ -199,11 +210,20 @@ jaw_component_get_extents (AtkComponent *component,
gint *height,
AtkCoordType coord_type)
{
- if (x == NULL || y == NULL || width == NULL || height == NULL)
- return;
+ jaw_component_get_position (component, x, y, coord_type);
+ jaw_component_get_size (component, width, height);
+}
- if (component == NULL)
+static void
+jaw_component_get_position (AtkComponent *component,
+ gint *x,
+ gint *y,
+ AtkCoordType coord_type)
+{
+ if (x == NULL || y == NULL)
+ {
return;
+ }
JawObject *jaw_obj = JAW_OBJECT(component);
ComponentData *data = jaw_object_get_interface_data(jaw_obj,
@@ -215,30 +235,62 @@ jaw_component_get_extents (AtkComponent *component,
"org/GNOME/Accessibility/AtkComponent");
jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
classAtkComponent,
- "get_extents",
- "()Ljava/awt/Rectangle;");
-
- jobject jrectangle = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
+ "get_position",
+ "(I)Ljava/awt/Point;");
+ jobject jpoint = (*jniEnv)->CallObjectMethod(jniEnv,
+ atk_component,
+ jmid, (jint)coord_type);
- if (jrectangle == NULL)
+ if (jpoint == 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 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();
+ 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;
}
static gboolean
@@ -263,14 +315,7 @@ jaw_component_set_extents (AtkComponent *component,
"set_extents",
"()Ljava/awt/Rectangle;");
- jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv,
- atk_component,
- jmid,
- (jint)x,
- (jint)y,
- (jint)width,
- (jint)height,
- (jint)coord_type);
+ jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
if (jcomponent == NULL)
{
diff --git a/jni/src/jawimpl.c b/jni/src/jawimpl.c
index 347c67e..348043a 100644
--- a/jni/src/jawimpl.c
+++ b/jni/src/jawimpl.c
@@ -263,15 +263,19 @@ 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 700e00e..fa0d5f3 100644
--- a/jni/src/jawutil.c
+++ b/jni/src/jawutil.c
@@ -490,15 +490,6 @@ 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 36872c2..fceb182 100644
--- a/jni/src/jawutil.h
+++ b/jni/src/jawutil.h
@@ -66,8 +66,6 @@ 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 202635f..97e0ce8 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -78,8 +78,11 @@ 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();
@@ -90,14 +93,9 @@ 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 34cbc7c..c5ba31d 100644
--- a/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
+++ b/wrapper/org/GNOME/Accessibility/AtkWrapper.java.in
@@ -28,6 +28,7 @@ import javax.accessibility.*;
import java.awt.Toolkit;
public class AtkWrapper {
+ public native void AtkWrapper();
static boolean accessibilityEnabled = false;
static {
try {
@@ -449,7 +450,6 @@ 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,14 +524,31 @@ public class AtkWrapper {
if (parent != null) {
parent_role = parent.getAccessibleContext().getAccessibleRole();
}
- if (role != null) {
- if (newValue == javax.accessibility.AccessibleState.FOCUSED ||
- newValue == javax.accessibility.AccessibleState.SELECTED) {
- dispatchFocusEvent(o);
+
+ 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);
+ }
}
+ } 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 = false;
+ boolean value;
if (newValue != null) {
state = (AccessibleState)newValue;
value = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]