[java-atk-wrapper] fixes for get and set extent methods
- From: Magdalen Berns <mberns src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] fixes for get and set extent methods
- Date: Wed, 7 Jan 2015 00:33:38 +0000 (UTC)
commit 7da1a77584c7c8e9207e1e8e6fd9b1e2ffc77e84
Author: Magdalen Berns <m berns thismagpie com>
Date: Wed Jan 7 00:32:53 2015 +0000
fixes for get and set extent methods
bug: https://bugzilla.gnome.org/show_bug.cgi?id=742495
jni/src/AtkWrapper.c | 4 +-
jni/src/jawcomponent.c | 86 ++++++++++++++-------
wrapper/org/GNOME/Accessibility/AtkComponent.java | 25 +++++-
3 files changed, 82 insertions(+), 33 deletions(-)
---
diff --git a/jni/src/AtkWrapper.c b/jni/src/AtkWrapper.c
index f685d18..f184724 100644
--- a/jni/src/AtkWrapper.c
+++ b/jni/src/AtkWrapper.c
@@ -875,8 +875,8 @@ signal_emit_handler (gpointer p)
gint newValue = get_int_value(jniEnv,
(*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
- gint prevCount = (gint)g_hash_table_lookup(jaw_obj->storedData,
- "Previous_Count");
+ gint prevCount = *(gint*)g_hash_table_lookup(jaw_obj->storedData,
+ "Previous_Count");
gint curCount = atk_text_get_character_count(ATK_TEXT(jaw_obj));
g_hash_table_insert(jaw_obj->storedData,
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index e276c2a..cebd7fd 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -19,6 +19,7 @@
#include <atk/atk.h>
#include <glib.h>
+#include <glib-object.h>
#include "jawimpl.h"
#include "jawutil.h"
@@ -217,9 +218,9 @@ jaw_component_set_extents (AtkComponent *component,
"set_extents",
"()Ljava/awt/Rectangle;");
- jobject jrectangle = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
+ jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
- if (jrectangle == NULL)
+ if (jcomponent == NULL)
{
width = 0;
height = 0;
@@ -228,29 +229,30 @@ jaw_component_set_extents (AtkComponent *component,
return FALSE;
}
- jclass rectangle_class = (*jniEnv)->FindClass(jniEnv, "java/awt/Rectangle");
- jfieldID jfidWidth = (*jniEnv)->GetFieldID(jniEnv,
- rectangle_class,
- "width",
- "I");
- jfieldID jfidHeight = (*jniEnv)->GetFieldID(jniEnv,
- rectangle_class,
- "height",
- "I");
- jfieldID jfidX = (*jniEnv)->GetFieldID(jniEnv,
- rectangle_class,
- "x",
- "I");
-
- jfieldID jfidY = (*jniEnv)->GetFieldID(jniEnv,
- rectangle_class,
- "y",
- "I");
-
- jint jwidth = (*jniEnv)->GetIntField(jniEnv, rectangle_class, jfidWidth);
- jint jheight = (*jniEnv)->GetIntField(jniEnv, rectangle_class, jfidHeight);
- jint jx = (*jniEnv)->GetIntField(jniEnv, rectangle_class, jfidX);
- jint jy = (*jniEnv)->GetIntField(jniEnv, rectangle_class, jfidY);
+ 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");
+
+ jint jwidth = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidWidth);
+ jint jheight = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidHeight);
+ jint jx = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidX);
+ jint jy = (*jniEnv)->GetIntField(jniEnv, componentClass, jfidY);
width = (gint)jwidth;
height = (gint)jheight;
@@ -286,15 +288,45 @@ jaw_component_get_extents (AtkComponent *component,
"get_extents",
"()Ljava/awt/Rectangle;");
- jobject jrectangle = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
+ jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv, atk_component, jmid);
- if (jrectangle == NULL)
+ 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
diff --git a/wrapper/org/GNOME/Accessibility/AtkComponent.java
b/wrapper/org/GNOME/Accessibility/AtkComponent.java
index de88b0e..5152cc9 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -28,7 +28,7 @@ public class AtkComponent {
AccessibleContext ac;
AccessibleComponent acc_component;
- private int x, y;
+ private int x, y, width, height;
public AtkComponent (AccessibleContext ac) {
super();
@@ -70,11 +70,28 @@ public class AtkComponent {
return true;
}
- public void set_extents(Rectangle r) {
- acc_component.setBounds(r);
+ public Point get_position (int coord_type) {
+ if (coord_type == AtkCoordType.SCREEN)
+ return acc_component.getLocationOnScreen();
+
+ return acc_component.getLocation();
+ }
+
+ public Dimension get_size () {
+ return acc_component.getSize();
+ }
+ public void 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();
+ this.x -= p.x;
+ this.y -= p.y;
+ }
}
- public Rectangle get_extents() {
+ public Rectangle get_extents(int x, int y, int width, int height, int coord_type) {
return acc_component.getBounds();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]