[java-atk-wrapper] The set extents method only sets points x and y when AtkCoordType.SCREEN returns true. It is necessa
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] The set extents method only sets points x and y when AtkCoordType.SCREEN returns true. It is necessa
- Date: Wed, 7 Jan 2015 18:41:45 +0000 (UTC)
commit ffed31498d0a897418bd71ef7c2802631ead20aa
Author: Magdalen Berns <m berns thismagpie com>
Date: Wed Jan 7 18:01:15 2015 +0000
The set extents method only sets points x and y when
AtkCoordType.SCREEN returns true. It is necessary to set them
for AtkCoordType.WINDOW too.
Bug https://bugzilla.gnome.org/show_bug.cgi?id=742540
jni/src/jawcomponent.c | 169 +++++++++++++--------
wrapper/org/GNOME/Accessibility/AtkComponent.java | 12 +-
2 files changed, 110 insertions(+), 71 deletions(-)
---
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index cebd7fd..d018f95 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;
@@ -191,6 +202,97 @@ jaw_component_ref_accessible_at_point (AtkComponent *component, gint x, gint y,
return ATK_OBJECT(jaw_impl);
}
+static void
+jaw_component_get_extents (AtkComponent *component,
+ gint *x,
+ gint *y,
+ gint *width,
+ gint *height,
+ AtkCoordType coord_type)
+{
+ jaw_component_get_position (component, x, y, coord_type);
+ jaw_component_get_size (component, width, height);
+}
+
+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,
+ 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_position",
+ "(I)Ljava/awt/Point;");
+ jobject jpoint = (*jniEnv)->CallObjectMethod(jniEnv,
+ atk_component,
+ jmid, (jint)coord_type);
+
+ 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 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
jaw_component_set_extents (AtkComponent *component,
gint x,
@@ -262,73 +364,6 @@ jaw_component_set_extents (AtkComponent *component,
return TRUE;
}
-static void
-jaw_component_get_extents (AtkComponent *component,
- gint *x,
- gint *y,
- gint *width,
- gint *height,
- AtkCoordType coord_type)
-{
- if (x == NULL || y == NULL || width == NULL || height == NULL)
- {
- return;
- }
-
- 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_extents",
- "()Ljava/awt/Rectangle;");
-
- jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
-
- if (jcomponent == NULL)
- {
- (*width) = 0;
- (*height) = 0;
- (*x) = 0;
- (*y) = 0;
- }
- jclass componentClass = (*jniEnv)->FindClass(jniEnv, "java/awt/Rectangle");
-
- // Get Field IDs
- jfieldID jfidX = (*jniEnv)->GetFieldID(jniEnv,
- componentClass,
- "x",
- "I");
- jfieldID jfidY = (*jniEnv)->GetFieldID(jniEnv,
- componentClass,
- "y",
- "I");
- jfieldID jfidWidth = (*jniEnv)->GetFieldID(jniEnv,
- componentClass,
- "width",
- "I");
- jfieldID jfidHeight = (*jniEnv)->GetFieldID(jniEnv,
- componentClass,
- "height",
- "I");
-
- // Get Field int Fields
- jint jx = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidX);
- jint jy = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidY);
- jint jwidth = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidWidth);
- jint jheight = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidHeight);
-
- (*width) = (gint)jwidth;
- (*height) = (gint)jheight;
- (*x) = (gint)jx;
- (*y) = (gint)jy;
-}
-
static gboolean
jaw_component_grab_focus (AtkComponent *component)
{
diff --git a/wrapper/org/GNOME/Accessibility/AtkComponent.java
b/wrapper/org/GNOME/Accessibility/AtkComponent.java
index 5152cc9..d4cc2eb 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -29,6 +29,7 @@ public class AtkComponent {
AccessibleContext ac;
AccessibleComponent acc_component;
private int x, y, width, height;
+ private Rectangle extents;
public AtkComponent (AccessibleContext ac) {
super();
@@ -80,19 +81,22 @@ public class AtkComponent {
public Dimension get_size () {
return acc_component.getSize();
}
- public void set_extents(int x, int y, int width, int height, int coord_type) {
+ public Rectangle set_extents(int x, int y, int width, int height, int coord_type) {
this.width = width;
this.height = height;
if (coord_type == AtkCoordType.SCREEN) {
Point p = acc_component.getLocationOnScreen();
+ } else {
+ Point p = acc_component.getLocation();
this.x -= p.x;
this.y -= p.y;
}
+ this.extents = new Rectangle(x, y, width, height);
+ return extents;
}
-
- public Rectangle get_extents(int x, int y, int width, int height, int coord_type) {
- return acc_component.getBounds();
+ public Rectangle get_extents(int x, int y, int width, int height, int coord_type){
+ return set_extents(x, y, width, height, coord_type);
}
public int get_layer () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]