[java-atk-wrapper] Fix component extents manipulations
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [java-atk-wrapper] Fix component extents manipulations
- Date: Mon, 8 Jul 2019 22:26:11 +0000 (UTC)
commit 9bb070eb17ed2181deac62e53e5666757687533a
Author: Giuseppe <giuseppecapaldo93 gmail com>
Date: Tue Jul 9 00:26:02 2019 +0200
Fix component extents manipulations
jni/src/jawcomponent.c | 69 ++--------------
wrapper/org/GNOME/Accessibility/AtkComponent.java | 98 +++++++++++++----------
2 files changed, 64 insertions(+), 103 deletions(-)
---
diff --git a/jni/src/jawcomponent.c b/jni/src/jawcomponent.c
index 59f4905..c4d6651 100644
--- a/jni/src/jawcomponent.c
+++ b/jni/src/jawcomponent.c
@@ -224,74 +224,19 @@ jaw_component_set_extents (AtkComponent *component,
gint height,
AtkCoordType coord_type)
{
-
JawObject *jaw_obj = JAW_OBJECT(component);
+ if (!jaw_obj)
+ return FALSE;
ComponentData *data = jaw_object_get_interface_data(jaw_obj, INTERFACE_COMPONENT);
JNIEnv *jniEnv = jaw_util_get_jni_env();
jobject atk_component = (*jniEnv)->NewGlobalRef(jniEnv, data->atk_component);
- if (!atk_component) {
+ if (!atk_component)
return FALSE;
- }
-
- jclass classAtkComponent = (*jniEnv)->FindClass(jniEnv,
- "org/GNOME/Accessibility/AtkComponent");
-
- jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv,
- classAtkComponent,
- "set_extents",
- "(IIIII)Ljava/awt/Rectangle;");
-
- jobject jcomponent = (*jniEnv)->CallObjectMethod(jniEnv,
- atk_component,
- jmid,
- (jint)x,
- (jint)y,
- (jint)width,
- (jint)height,
- (jint)coord_type);
-
- if (jcomponent == NULL)
- {
- width = 0;
- height = 0;
- x = 0;
- y = 0;
- (*jniEnv)->DeleteGlobalRef(jniEnv, atk_component);
- return FALSE;
- }
-
- jclass classRectangle = (*jniEnv)->FindClass(jniEnv, "java/awt/Rectangle");
-
- // Get Field IDs
- jfieldID jfidX = (*jniEnv)->GetFieldID(jniEnv,
- atk_component,
- "x",
- "I");
- jfieldID jfidY = (*jniEnv)->GetFieldID(jniEnv,
- atk_component,
- "y",
- "I");
- jfieldID jfidWidth = (*jniEnv)->GetFieldID(jniEnv,
- atk_component,
- "width",
- "I");
- jfieldID jfidHeight = (*jniEnv)->GetFieldID(jniEnv,
- atk_component,
- "height",
- "I");
+ jclass classAtkComponent = (*jniEnv)->FindClass(jniEnv, "org/GNOME/Accessibility/AtkComponent");
+ jmethodID jmid = (*jniEnv)->GetMethodID(jniEnv, classAtkComponent, "set_extents", "(IIIII)Z");
+ jboolean assigned = (*jniEnv)->CallBooleanMethod(jniEnv, atk_component, jmid, (jint)x, (jint)y,
(jint)width, (jint)height, (jint)coord_type);
(*jniEnv)->DeleteGlobalRef(jniEnv, atk_component);
-
- jint jwidth = (*jniEnv)->GetIntField(jniEnv, classRectangle, jfidWidth);
- jint jheight = (*jniEnv)->GetIntField(jniEnv, classRectangle, jfidHeight);
- jint jx = (*jniEnv)->GetIntField(jniEnv, classRectangle, jfidX);
- jint jy = (*jniEnv)->GetIntField(jniEnv, classRectangle, jfidY);
-
- width = (gint)jwidth;
- height = (gint)jheight;
- x = (gint)jx;
- y = (gint)jy;
-
- return TRUE;
+ return assigned;
}
static gboolean
diff --git a/wrapper/org/GNOME/Accessibility/AtkComponent.java
b/wrapper/org/GNOME/Accessibility/AtkComponent.java
index 8866cce..dcfdab0 100644
--- a/wrapper/org/GNOME/Accessibility/AtkComponent.java
+++ b/wrapper/org/GNOME/Accessibility/AtkComponent.java
@@ -29,8 +29,6 @@ public class AtkComponent {
AccessibleContext ac;
AccessibleComponent acc_component;
- private int x, y, width, height;
- private Rectangle extents;
public AtkComponent (AccessibleContext ac) {
super();
@@ -44,26 +42,44 @@ public class AtkComponent {
public boolean contains (int x, int y, int coord_type) {
return AtkUtil.invokeInSwing ( () -> {
- if (coord_type == AtkCoordType.SCREEN) {
- Point p = acc_component.getLocationOnScreen();
- this.x -= p.x;
- this.y -= p.y;
+ if(!acc_component.isVisible()){
+ final int rightX;
+ final int rightY;
+ if (coord_type == AtkCoordType.SCREEN) {
+ Point p = acc_component.getLocationOnScreen();
+ rightX = x - p.x;
+ rightY = y - p.y;
+ }
+ else{
+ rightX = x;
+ rightY = y;
+ }
+ return acc_component.contains(new Point(rightX, rightY));
}
- return acc_component.contains(new Point(x, y));
+ return false;
}, false);
}
public AccessibleContext get_accessible_at_point (int x, int y, int coord_type) {
return AtkUtil.invokeInSwing ( () -> {
- if (coord_type == AtkCoordType.SCREEN) {
- Point p = acc_component.getLocationOnScreen();
- this.x -= p.x;
- this.y -= p.y;
+ if(acc_component.isVisible()){
+ final int rightX;
+ final int rightY;
+ if (coord_type == AtkCoordType.SCREEN) {
+ Point p = acc_component.getLocationOnScreen();
+ rightX = x - p.x;
+ rightY = y - p.y;
+ }
+ else{
+ rightX = x;
+ rightY = y;
+ }
+ Accessible accessible = acc_component.getAccessibleAt(new Point(rightX, rightY));
+ if (accessible == null)
+ return null;
+ return accessible.getAccessibleContext();
}
- Accessible accessible = acc_component.getAccessibleAt(new Point(x, y));
- if (accessible == null)
- return null;
- return accessible.getAccessibleContext();
+ return null;
}, null);
}
@@ -76,37 +92,37 @@ public class AtkComponent {
}, false);
}
- public Point get_position (int coord_type) {
- return AtkUtil.invokeInSwing ( () -> {
- if (coord_type == AtkCoordType.SCREEN)
- return acc_component.getLocationOnScreen();
- return acc_component.getLocation();
- }, null);
- }
-
- public Rectangle set_extents(int x, int y, int width, int height, int coord_type) {
- return AtkUtil.invokeInSwing ( () -> {
- Point p;
- this.width = (int)acc_component.getSize().getWidth();
- this.height = (int)acc_component.getSize().getHeight();
- if (coord_type == AtkCoordType.SCREEN)
- p = acc_component.getLocationOnScreen();
- else {
- p = acc_component.getLocation();
- this.x -= p.x;
- this.y -= p.y;
+ public boolean set_extents(int x, int y, int width, int height, int coord_type) {
+ AtkUtil.invokeInSwing( () -> {
+ if(acc_component.isVisible()){
+ final int rightX;
+ final int rightY;
+ if (coord_type == AtkCoordType.SCREEN) {
+ Point p = acc_component.getLocationOnScreen();
+ rightX = x - p.x;
+ rightY = y - p.y;
+ }
+ else{
+ rightX = x;
+ rightY = y;
+ }
+ acc_component.setBounds(new Rectangle(rightX, rightY, width, height));
+ return true;
}
- return new Rectangle(x, y, width, height);
- }, null);
+ return false;
+ }, false);
}
public Rectangle get_extents() {
return AtkUtil.invokeInSwing ( () -> {
- Rectangle rect = acc_component.getBounds();
- Point p = acc_component.getLocationOnScreen();
- rect.x = p.x;
- rect.y = p.y;
- return rect;
+ if(acc_component.isVisible()){
+ Rectangle rect = acc_component.getBounds();
+ Point p = acc_component.getLocationOnScreen();
+ rect.x = p.x;
+ rect.y = p.y;
+ return rect;
+ }
+ return null;
},null);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]