Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 441148

Summary: [GTK3] Shell#setSize() in RTL shell sets x-coordinate of contained control to invalid value
Product: [Eclipse Project] Platform Reporter: Sravan Kumar Lakkimsetti <sravankumarl>
Component: SWTAssignee: Sravan Kumar Lakkimsetti <sravankumarl>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: arunkumar.thondapu, markus.kell.r
Version: 4.4Flags: sravankumarl: review? (arunkumar.thondapu)
markus.kell.r: review+
Target Milestone: 4.5 M2   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 441566    

Description Sravan Kumar Lakkimsetti CLA 2014-08-05 05:14:45 EDT
Here is the use case

1. Create a shell
2. Set the orientation to RTL
3. add a button with size 100x100 at location 0,0
4. resize the shell to with 400 height 400.
5. verify the location of the button

in GTK3 we get -600,0 and GTK2 we get 0,0.

in gtk3 the button is going out of bounds of the shell
Comment 1 Sravan Kumar Lakkimsetti CLA 2014-08-05 05:16:01 EDT
This problem is observed while testing 434772
Comment 2 Markus Keller CLA 2014-08-20 10:49:07 EDT
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.*;

public class Snippet {
	public static void main(String[] args) {
//		System.setProperty("SWT_GTK3", "0");
		
		Display display = new Display();
		System.out.println(System.getProperty("org.eclipse.swt.internal.gtk.version"));
		
		Shell shell = new Shell(display, SWT.NO_TRIM);
		shell.setOrientation(SWT.RIGHT_TO_LEFT);
		Button button = new Button(shell, SWT.PUSH);
		button.setBounds(0,0,100,100);
		System.out.println(button.getBounds());
		System.out.println(shell.getSize());
		shell.setSize(400, 400);
		System.out.println(button.getBounds());
	}
}

When I run the snippet with GTK2 (2.24.10), the last line is as expected:
Rectangle {0, 0, 100, 100}

But with GTK3 (libgtk-3-0 3.4.2-0ubuntu0.8 / Ubuntu 12.04), the last lines are:
Point {1050, 656}
Rectangle {-650, 0, 100, 100}

=> The x-coordinate is off by the difference between the original and the new size of the shell.
Comment 3 Sravan Kumar Lakkimsetti CLA 2014-09-02 05:09:31 EDT
Differing to 4.5. It require more in depth changes in Native custom code(gtk3 specific) and in java code as well.
Comment 4 Sravan Kumar Lakkimsetti CLA 2014-09-08 14:03:27 EDT
potential path has been uploaded to https://git.eclipse.org/r/33063
Comment 5 Markus Keller CLA 2014-09-10 10:34:47 EDT
Looks good, also works with repeated calls to Shell#setOrientation(int), and fixes the previously failing tests on GTK3:
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display.test_map*

Released with http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=8ca3e0288320ea5a604a1d351fe0b9cda6bce09f