Skip to content

Commit 40d0d06

Browse files
committed
Fix GTK4 shell location tests.
We cannot set/determine the location of the shell using Window Handle on GTK4. So fix the test not to test the set and get location on GTK4. see #2498
1 parent 79e69bb commit 40d0d06

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public class Shell extends Decorations {
133133
boolean ignoreFocusOut, ignoreFocusIn;
134134
boolean ignoreFocusOutAfterGrab, grabbedFocus;
135135
Region originalRegion;
136+
private final Point location = new Point(0, 0);
136137

137138
static final int MAXIMUM_TRIM = 128;
138139
static final int BORDER = 3;
@@ -3461,4 +3462,43 @@ Point getSurfaceOrigin () {
34613462
return super.getSurfaceOrigin( );
34623463
}
34633464

3465+
@Override
3466+
public void setLocation(int x, int y) {
3467+
super.setLocation(x, y);
3468+
if (GTK.GTK4) {
3469+
this.location.x = x;
3470+
this.location.y = y;
3471+
}
3472+
}
3473+
@Override
3474+
public void setLocation(Point location) {
3475+
super.setLocation(location);
3476+
if (GTK.GTK4) {
3477+
this.location.x = location.x;
3478+
this.location.y = location.y;
3479+
}
3480+
}
3481+
3482+
@Override
3483+
void setLocationInPixels(int x, int y) {
3484+
super.setLocationInPixels(x, y);
3485+
if (GTK.GTK4) {
3486+
this.location.x = x;
3487+
this.location.y = y;
3488+
}
3489+
}
3490+
3491+
@Override
3492+
void setLocationInPixels(Point location) {
3493+
super.setLocationInPixels(location);
3494+
if (GTK.GTK4) {
3495+
this.location.x = location.x;
3496+
this.location.y = location.y;
3497+
}
3498+
}
3499+
3500+
@Override
3501+
public Point getLocation() {
3502+
return GTK.GTK4 ? location : super.getLocation();
3503+
}
34643504
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.eclipse.swt.graphics.Point;
3535
import org.eclipse.swt.graphics.Rectangle;
3636
import org.eclipse.swt.graphics.Region;
37+
import org.eclipse.swt.internal.gtk.GTK;
3738
import org.eclipse.swt.layout.FillLayout;
3839
import org.eclipse.swt.layout.GridLayout;
3940
import org.eclipse.swt.widgets.Button;
@@ -457,6 +458,10 @@ public void test_getImeInputMode() {
457458
@Override
458459
@Test
459460
public void test_getLocation() {
461+
//Setting location for Windows is not supported in GTK4
462+
if (GTK.GTK4) {
463+
return;
464+
}
460465
shell.setLocation(10,15);
461466
assertEquals(":a:", 10, shell.getLocation().x);
462467
assertEquals(":b:", 15, shell.getLocation().y);
@@ -999,4 +1004,22 @@ public void test_Issue450_NoShellActivateOnSetFocus() {
9991004
}
10001005
}
10011006
}
1007+
1008+
@Override
1009+
public void test_setLocationLorg_eclipse_swt_graphics_Point() {
1010+
//Setting location for Windows is not supported in GTK4
1011+
if (GTK.GTK4) {
1012+
return;
1013+
}
1014+
super.test_setLocationLorg_eclipse_swt_graphics_Point();
1015+
}
1016+
1017+
@Override
1018+
public void test_setLocationII() {
1019+
//Setting location for Windows is not supported in GTK4
1020+
if (GTK.GTK4) {
1021+
return;
1022+
}
1023+
super.test_setLocationII();
1024+
}
10021025
}

0 commit comments

Comments
 (0)