Bug 37052 - Shells assuming SWT.RESIZE on GTK and Motif (BBAWT)
Summary: Shells assuming SWT.RESIZE on GTK and Motif (BBAWT)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.1   Edit
Hardware: PC Linux
: P1 major (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 55370 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-04-29 10:23 EDT by David Whiteman CLA
Modified: 2004-04-19 15:02 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Whiteman CLA 2003-04-29 10:23:33 EDT
On Windows, if you create a Shell without the SWT.RESIZE flag, the shell is
*not* resizeable.  However, on GTK *and* Motif, the shell is resizeable.

SWT version 3.002

In the following testcase, click on the "open dialog" button.  The child shell
should not be resizeable since RESIZE was not used, but both Motif and GTK use a
resizeable shell.

=== testcase ===

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;

public class TestSWTDialog {

	public static void main(String[] args) {

		Display disp = new Display();
		final Shell sh = new Shell(disp);
		sh.setLayout(new GridLayout());

		Button but = new Button(sh, SWT.BORDER);
		but.setText("open dialog");
		but.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {

				final Shell dialogShell =
					new Shell(sh, SWT.BORDER | SWT.CLOSE | SWT.TITLE);
				dialogShell.setText("test");
				dialogShell.setBounds(300, 300, 300, 150);

				Button b = new Button(dialogShell, SWT.BORDER);

				final Label label = new Label(dialogShell, SWT.CENTER);
				label.setText("this is a test label");
				label.setBounds(10, 20, 280, 60);
				b.setText("button 1");
				b.setBounds(80, 100, 60, 20);

				dialogShell.setVisible(true);
				dialogShell.pack();
				dialogShell.open();
			}
		});

		sh.pack();
		sh.open();

		while (!sh.isDisposed()) {
			if (!disp.readAndDispatch()) {
				disp.sleep();
			}
		}

	}

}
Comment 1 Steve Northover CLA 2003-04-29 11:29:20 EDT
This is an issue with the Window Manager, not SWT.  Please reopen this PR, 
(specifying the Window Manager) if you can find another application on the 
desktop that has the dialogs with the trim you expect.  Thanks.

A faster but less conclusive test is to run the SWT ControlExample and see if 
any of the native dialogs have the right trim (MessageBox, FileDialog etc).  
This should be the same as running another application as we don't play with 
the trim on the native dialogs but you never know ...
Comment 2 David Whiteman CLA 2003-04-30 13:09:52 EDT
I have confirmed that MessageBox instances are also resizable on Motif and 
GTK.  My WindowManager is Gnome on RH 8.0, and I suppose you're implying that 
Gnome doesn't support prevention of resizing.  Is it possible that there are 
special Gnome APIs to enable this, either currently unexposed by SWT, or 
provided by the libswt-gnome-motif*.so and libswt-gnome-gtk*.so files?
Comment 3 David Whiteman CLA 2004-03-19 16:49:52 EST
I'm not convinced this can't be fixed.  Try the following testcase on the IBM
JDK on RedHat Linux.  The window is *not* resizeable when setResizeable is set
to false; when you try to do so, you never get the resize handle/cursor.  

Note: the JDK uses the Motif toolkit on Linux.

testcase:
========
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class TestAwt {
	public static void main(String[] args) {
		final Frame f = new Frame("Hello World");
		f.setSize(300, 300);
		f.setLayout(new GridLayout());
		Label label = new Label("Hello World");
		f.add(label);
		f.setVisible(true);
		f.setResizable(false);
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				f.dispose();
				System.exit(0);
			}
		});
	}
}
Comment 4 David Whiteman CLA 2004-03-22 15:26:24 EST
In the GTK codebase, the following code change to Shell.createHandle() would be
helpful.  It would allow the style of RESIZE to be omitted effectively.

	if ((style & SWT.RESIZE) != 0) {
/* begin previous default code path */
		OS.gtk_widget_set_size_request (shellHandle, 0, 0);
		OS.gtk_window_set_resizable (shellHandle, true);
/* end previous default code path */
	} else {
		OS.gtk_window_set_resizable (shellHandle, false);
	}

Would this not be a reasonable change on the GTK platform?

Comment 5 Grant Gayed CLA 2004-03-22 16:25:39 EST
I looked at this with SN and SSQ, and it's not a safe change to make at the
beginning of a milestone week.  Further investigation is needed, as there has
been much pain in this area in the past.
Comment 6 Grant Gayed CLA 2004-03-22 16:26:22 EST
ping (bugzilla didn't send notification on the last comment change).
Comment 7 Grant Gayed CLA 2004-03-22 16:30:34 EST
*** Bug 55370 has been marked as a duplicate of this bug. ***
Comment 8 David Whiteman CLA 2004-03-22 16:43:20 EST
Do you think that something can probably be done in this area after your 
milestone has passed?  We don't mind making the change in our own copy of SWT 
in the short term, but would like to have a "good feeling" that some code to 
block resizing could be implemented in SWT on the GTK platform in the future, 
since we like our builds to correspond with actual SWT versions from 
eclipse.org.
Comment 9 Steve Northover CLA 2004-03-30 09:09:47 EST
SSQ has been working on this.  Did you release the code?
Comment 10 David Whiteman CLA 2004-03-30 09:15:30 EST
FWIW, in doing our builds based on SWT, we have been making the change I 
suggested in our local copy of SWT/GTK, and it seems to be working well.  We 
were able to pass all the certification tests we had previously been failing 
due to lack of fixed size functionality.
Comment 11 Steve Northover CLA 2004-03-30 09:36:08 EST
Good for testing but not a good idea to ship like this.  There were some 
problems with "windows that grew and grew until they filled the entire 
desktop".  This possibly doesn't happen in BBAWT because you never create a 
Shell with the offending style?
Comment 12 Silenio Quarti CLA 2004-03-30 11:17:01 EST
Fixed > 20030330.
Comment 13 David Whiteman CLA 2004-04-19 15:02:51 EDT
I can verify that this is fixed on GTK.  If someone else can check out MOTIF, we
can mark this as VERIFIED.