Skip to content

Commit cd7cd6b

Browse files
committed
Correct contracts of Control#[get|set]Location() #790
The Control#getLocation() and Control#setLocation(...) operations currently claim to always work (i.e., yield reasonable values or actually change the location). This specification is incorrect when executing these methods in shells on a platform that uses the Wayland protocol. Since there is currently no fix to make the implementation fulfill the specification, this adds an according warning to the specification in order to avoid that clients rely on the specification to be fulfilled. Contributes to #790
1 parent bdd0195 commit cd7cd6b

File tree

3 files changed

+75
-42
lines changed

3 files changed

+75
-42
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java

+25-14
Original file line numberDiff line numberDiff line change
@@ -1726,10 +1726,15 @@ public Object getLayoutData () {
17261726
}
17271727

17281728
/**
1729-
* Returns a point describing the receiver's location relative
1730-
* to its parent in points (or its display if its parent is null), unless
1731-
* the receiver is a shell. In this case, the point is
1732-
* relative to the display.
1729+
* Returns a point describing the receiver's location relative to its parent in
1730+
* points (or its display if its parent is null), unless the receiver is a
1731+
* shell. In this case, the point is usually relative to the display.
1732+
* <p>
1733+
* <b>Warning:</b> When executing this operation on a shell, it may not yield a
1734+
* value with the expected meaning on some platforms. For example, executing
1735+
* this operation on a shell when the environment uses the Wayland protocol, the
1736+
* result is <b>not</b> a coordinate relative to the display. It will not change
1737+
* when moving the shell.
17331738
*
17341739
* @return the receiver's location
17351740
*
@@ -3974,11 +3979,14 @@ public void setLayoutData (Object layoutData) {
39743979
}
39753980

39763981
/**
3977-
* Sets the receiver's location to the point specified by
3978-
* the arguments which are relative to the receiver's
3979-
* parent (or its display if its parent is null), unless
3980-
* the receiver is a shell. In this case, the point is
3981-
* relative to the display.
3982+
* Sets the receiver's location to the point specified by the arguments which
3983+
* are relative to the receiver's parent (or its display if its parent is null),
3984+
* unless the receiver is a shell. In this case, the point is relative to the
3985+
* display.
3986+
* <p>
3987+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
3988+
* intended effect on some platforms. For example, executing this operation on a
3989+
* shell when the environment uses the Wayland protocol, nothing will happen.
39823990
*
39833991
* @param x the new x coordinate for the receiver
39843992
* @param y the new y coordinate for the receiver
@@ -3994,11 +4002,14 @@ public void setLocation (int x, int y) {
39944002
}
39954003

39964004
/**
3997-
* Sets the receiver's location to the point specified by
3998-
* the arguments which are relative to the receiver's
3999-
* parent (or its display if its parent is null), unless
4000-
* the receiver is a shell. In this case, the point is
4001-
* relative to the display.
4005+
* Sets the receiver's location to the point specified by the argument which
4006+
* is relative to the receiver's parent (or its display if its parent is null),
4007+
* unless the receiver is a shell. In this case, the point is relative to the
4008+
* display.
4009+
* <p>
4010+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
4011+
* intended effect on some platforms. For example, executing this operation on a
4012+
* shell when the environment uses the Wayland protocol, nothing will happen.
40024013
*
40034014
* @param location the new location for the receiver
40044015
*

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

+25-14
Original file line numberDiff line numberDiff line change
@@ -1215,10 +1215,15 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
12151215
}
12161216

12171217
/**
1218-
* Returns a point describing the receiver's location relative
1219-
* to its parent in points (or its display if its parent is null), unless
1220-
* the receiver is a shell. In this case, the point is
1221-
* relative to the display.
1218+
* Returns a point describing the receiver's location relative to its parent in
1219+
* points (or its display if its parent is null), unless the receiver is a
1220+
* shell. In this case, the point is usually relative to the display.
1221+
* <p>
1222+
* <b>Warning:</b> When executing this operation on a shell, it may not yield a
1223+
* value with the expected meaning on some platforms. For example, executing
1224+
* this operation on a shell when the environment uses the Wayland protocol, the
1225+
* result is <b>not</b> a coordinate relative to the display. It will not change
1226+
* when moving the shell.
12221227
*
12231228
* @return the receiver's location
12241229
*
@@ -1247,11 +1252,14 @@ Point getLocationInPixels () {
12471252
}
12481253

12491254
/**
1250-
* Sets the receiver's location to the point specified by
1251-
* the arguments which are relative to the receiver's
1252-
* parent (or its display if its parent is null), unless
1253-
* the receiver is a shell. In this case, the point is
1254-
* relative to the display.
1255+
* Sets the receiver's location to the point specified by the argument which
1256+
* is relative to the receiver's parent (or its display if its parent is null),
1257+
* unless the receiver is a shell. In this case, the point is relative to the
1258+
* display.
1259+
* <p>
1260+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
1261+
* intended effect on some platforms. For example, executing this operation on a
1262+
* shell when the environment uses the Wayland protocol, nothing will happen.
12551263
*
12561264
* @param location the new location for the receiver
12571265
*
@@ -1274,11 +1282,14 @@ void setLocationInPixels (Point location) {
12741282
}
12751283

12761284
/**
1277-
* Sets the receiver's location to the point specified by
1278-
* the arguments which are relative to the receiver's
1279-
* parent (or its display if its parent is null), unless
1280-
* the receiver is a shell. In this case, the point is
1281-
* relative to the display.
1285+
* Sets the receiver's location to the point specified by the arguments which
1286+
* are relative to the receiver's parent (or its display if its parent is null),
1287+
* unless the receiver is a shell. In this case, the point is relative to the
1288+
* display.
1289+
* <p>
1290+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
1291+
* intended effect on some platforms. For example, executing this operation on a
1292+
* shell when the environment uses the Wayland protocol, nothing will happen.
12821293
*
12831294
* @param x the new x coordinate for the receiver
12841295
* @param y the new y coordinate for the receiver

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java

+25-14
Original file line numberDiff line numberDiff line change
@@ -1353,10 +1353,15 @@ public Object getLayoutData () {
13531353
}
13541354

13551355
/**
1356-
* Returns a point describing the receiver's location relative
1357-
* to its parent in points (or its display if its parent is null), unless
1358-
* the receiver is a shell. In this case, the point is
1359-
* relative to the display.
1356+
* Returns a point describing the receiver's location relative to its parent in
1357+
* points (or its display if its parent is null), unless the receiver is a
1358+
* shell. In this case, the point is usually relative to the display.
1359+
* <p>
1360+
* <b>Warning:</b> When executing this operation on a shell, it may not yield a
1361+
* value with the expected meaning on some platforms. For example, executing
1362+
* this operation on a shell when the environment uses the Wayland protocol, the
1363+
* result is <b>not</b> a coordinate relative to the display. It will not change
1364+
* when moving the shell.
13601365
*
13611366
* @return the receiver's location
13621367
*
@@ -3488,11 +3493,14 @@ public void setLayoutData (Object layoutData) {
34883493
}
34893494

34903495
/**
3491-
* Sets the receiver's location to the point specified by
3492-
* the arguments which are relative to the receiver's
3493-
* parent (or its display if its parent is null), unless
3494-
* the receiver is a shell. In this case, the point is
3495-
* relative to the display.
3496+
* Sets the receiver's location to the point specified by the arguments which
3497+
* are relative to the receiver's parent (or its display if its parent is null),
3498+
* unless the receiver is a shell. In this case, the point is relative to the
3499+
* display.
3500+
* <p>
3501+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
3502+
* intended effect on some platforms. For example, executing this operation on a
3503+
* shell when the environment uses the Wayland protocol, nothing will happen.
34963504
*
34973505
* @param x the new x coordinate for the receiver
34983506
* @param y the new y coordinate for the receiver
@@ -3516,11 +3524,14 @@ void setLocationInPixels (int x, int y) {
35163524
}
35173525

35183526
/**
3519-
* Sets the receiver's location to the point specified by
3520-
* the arguments which are relative to the receiver's
3521-
* parent (or its display if its parent is null), unless
3522-
* the receiver is a shell. In this case, the point is
3523-
* relative to the display.
3527+
* Sets the receiver's location to the point specified by the argument which
3528+
* is relative to the receiver's parent (or its display if its parent is null),
3529+
* unless the receiver is a shell. In this case, the point is relative to the
3530+
* display.
3531+
* <p>
3532+
* <b>Warning:</b> When executing this operation on a shell, it may not have the
3533+
* intended effect on some platforms. For example, executing this operation on a
3534+
* shell when the environment uses the Wayland protocol, nothing will happen.
35243535
*
35253536
* @param location the new location for the receiver
35263537
*

0 commit comments

Comments
 (0)