Skip to content

Commit ef2f1c3

Browse files
committed
Fix GTK4 shell location.
We cannot determine the location of the shell using Window Handle on GTK4. Instead store the user set location in case of GTK4 and returns the same values when client asks for location. Note that setting location itself works fine on GTK4. see #2498
1 parent d9e3302 commit ef2f1c3

File tree

1 file changed

+40
-0
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets

1 file changed

+40
-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
}

0 commit comments

Comments
 (0)