Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Shell Resizing Problem on Linux/GTK
SWT Shell Resizing Problem on Linux/GTK [message #489265] Fri, 02 October 2009 07:28 Go to next message
Matt Seashore is currently offline Matt SeashoreFriend
Messages: 58
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------040301020000080606050105
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm trying to create a borderless shell (NO_TRIM) with a minimum size on
Linux.

When I do this, resizing the window to be *larger* doesn't seem to work
(though resizing smaller works until it hits the minimum size). I've
attached a snippet which illustrates the problem I'm seeing.

Am I doing something wrong or is this a known issue?

FYI: I'm running SWT/GTK/x86 from Eclipse 3.5 SR1 (SWT version
3.5.1.v555a) under Ubuntu 9.04 with the default Gnome window manager.

Thanks,

Matt



------

package org.eclipse.riena.sample.snippets;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* Demonstrates apparent bug with borderless shells with a minimum size
set not
* being able to 'grow' (resize to a larger size) on Linux with GTK
*/
public class ResizeShellSnippet {

private static final int INITIAL_SIZE = 525;
public static final int MIN_SIZE = 500;

public ResizeShellSnippet(final Shell shell) {

Button grow = new Button(shell, SWT.PUSH);
grow.setText("Grow"); //$NON-NLS-1$
grow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Rectangle rect = shell.getBounds();
rect.height = rect.height + 5;
rect.width = rect.width + 5;
shell.setBounds(rect);
}
});

Button shrink = new Button(shell, SWT.PUSH);
shrink.setText("Shrink"); //$NON-NLS-1$
shrink.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
Rectangle rect = shell.getBounds();
rect.height = rect.height - 5;
rect.width = rect.width - 5;
shell.setBounds(rect);
}
});

Button close = new Button(shell, SWT.PUSH);
close.setText("Close"); //$NON-NLS-1$
close.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {
shell.close();
}
});
}

public static void main(String[] args) {
Display display = Display.getDefault();
try {
//The regular shell will be able to grow
final Shell shell = new Shell();

shell.setMinimumSize(MIN_SIZE, MIN_SIZE);

shell.setLayout(new GridLayout());
new ResizeShellSnippet(shell);
shell.pack();
shell.setBounds(0, 0, INITIAL_SIZE, INITIAL_SIZE);

shell.open();

//The borderless shell with a minimum size won't be able to grow
//(Though it can shrink to the minimum size)
final Shell shell2 = new Shell(SWT.NO_TRIM);

shell2.setMinimumSize(MIN_SIZE, MIN_SIZE);

shell2.setLayout(new GridLayout());
new ResizeShellSnippet(shell2);
shell2.pack();
shell2.setBounds(INITIAL_SIZE, 0, INITIAL_SIZE, INITIAL_SIZE);

shell2.open();

while (!shell.isDisposed() && !shell2.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} finally {
display.dispose();
}
}

}

--------------040301020000080606050105
Content-Type: text/x-java;
name="ResizeShellSnippet.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="ResizeShellSnippet.java"

cGFja2FnZSBvcmcuZWNsaXBzZS5yaWVuYS5zYW1wbGUuc25pcHBldHM7Cgpp bXBvcnQgb3Jn
LmVjbGlwc2Uuc3d0LlNXVDsKaW1wb3J0IG9yZy5lY2xpcHNlLnN3dC5ldmVu dHMuU2VsZWN0
aW9uQWRhcHRlcjsKaW1wb3J0IG9yZy5lY2xpcHNlLnN3dC5ldmVudHMuU2Vs ZWN0aW9uRXZl
bnQ7CmltcG9ydCBvcmcuZWNsaXBzZS5zd3QuZ3JhcGhpY3MuUmVjdGFuZ2xl OwppbXBvcnQg
b3JnLmVjbGlwc2Uuc3d0LmxheW91dC5HcmlkTGF5b3V0OwppbXBvcnQg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------040301020000080606050105--
Re: SWT Shell Resizing Problem on Linux/GTK [message #489410 is a reply to message #489265] Fri, 02 October 2009 20:48 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi Matt,

This looks like a bug so I've logged
https://bugs.eclipse.org/bugs/show_bug.cgi?id=291253 .

Grant


"Matt Seashore" <mseashore@gmail.com> wrote in message
news:ha4a2f$km0$1@build.eclipse.org...
> Hi,
>
> I'm trying to create a borderless shell (NO_TRIM) with a minimum size on
> Linux.
>
> When I do this, resizing the window to be *larger* doesn't seem to work
> (though resizing smaller works until it hits the minimum size). I've
> attached a snippet which illustrates the problem I'm seeing.
>
> Am I doing something wrong or is this a known issue?
>
> FYI: I'm running SWT/GTK/x86 from Eclipse 3.5 SR1 (SWT version
> 3.5.1.v555a) under Ubuntu 9.04 with the default Gnome window manager.
>
> Thanks,
>
> Matt
>
>
>
> ------
>
> package org.eclipse.riena.sample.snippets;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.graphics.Rectangle;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> /**
> * Demonstrates apparent bug with borderless shells with a minimum size
> set not
> * being able to 'grow' (resize to a larger size) on Linux with GTK
> */
> public class ResizeShellSnippet {
>
> private static final int INITIAL_SIZE = 525;
> public static final int MIN_SIZE = 500;
>
> public ResizeShellSnippet(final Shell shell) {
>
> Button grow = new Button(shell, SWT.PUSH);
> grow.setText("Grow"); //$NON-NLS-1$
> grow.addSelectionListener(new SelectionAdapter() {
> @Override
> public void widgetSelected(SelectionEvent e) {
> Rectangle rect = shell.getBounds();
> rect.height = rect.height + 5;
> rect.width = rect.width + 5;
> shell.setBounds(rect);
> }
> });
>
> Button shrink = new Button(shell, SWT.PUSH);
> shrink.setText("Shrink"); //$NON-NLS-1$
> shrink.addSelectionListener(new SelectionAdapter() {
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> Rectangle rect = shell.getBounds();
> rect.height = rect.height - 5;
> rect.width = rect.width - 5;
> shell.setBounds(rect);
> }
> });
>
> Button close = new Button(shell, SWT.PUSH);
> close.setText("Close"); //$NON-NLS-1$
> close.addSelectionListener(new SelectionAdapter() {
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> shell.close();
> }
> });
> }
>
> public static void main(String[] args) {
> Display display = Display.getDefault();
> try {
> //The regular shell will be able to grow
> final Shell shell = new Shell();
>
> shell.setMinimumSize(MIN_SIZE, MIN_SIZE);
>
> shell.setLayout(new GridLayout());
> new ResizeShellSnippet(shell);
> shell.pack();
> shell.setBounds(0, 0, INITIAL_SIZE, INITIAL_SIZE);
>
> shell.open();
>
> //The borderless shell with a minimum size won't be able to grow
> //(Though it can shrink to the minimum size)
> final Shell shell2 = new Shell(SWT.NO_TRIM);
>
> shell2.setMinimumSize(MIN_SIZE, MIN_SIZE);
>
> shell2.setLayout(new GridLayout());
> new ResizeShellSnippet(shell2);
> shell2.pack();
> shell2.setBounds(INITIAL_SIZE, 0, INITIAL_SIZE, INITIAL_SIZE);
>
> shell2.open();
>
> while (!shell.isDisposed() && !shell2.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> } finally {
> display.dispose();
> }
> }
>
> }
>


------------------------------------------------------------ ----------------
----


> package org.eclipse.riena.sample.snippets;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.graphics.Rectangle;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> /**
> * Demonstrates apparent bug with borderless shells with a minimum size
set not
> * being able to 'grow' (resize to a larger size) on Linux with GTK
> */
> public class ResizeShellSnippet {
>
> private static final int INITIAL_SIZE = 525;
> public static final int MIN_SIZE = 500;
>
> public ResizeShellSnippet(final Shell shell) {
>
> Button grow = new Button(shell, SWT.PUSH);
> grow.setText("Grow"); //$NON-NLS-1$
> grow.addSelectionListener(new SelectionAdapter() {
> @Override
> public void widgetSelected(SelectionEvent e) {
> Rectangle rect = shell.getBounds();
> rect.height = rect.height + 5;
> rect.width = rect.width + 5;
> shell.setBounds(rect);
> }
> });
>
> Button shrink = new Button(shell, SWT.PUSH);
> shrink.setText("Shrink"); //$NON-NLS-1$
> shrink.addSelectionListener(new SelectionAdapter() {
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> Rectangle rect = shell.getBounds();
> rect.height = rect.height - 5;
> rect.width = rect.width - 5;
> shell.setBounds(rect);
> }
> });
>
> Button close = new Button(shell, SWT.PUSH);
> close.setText("Close"); //$NON-NLS-1$
> close.addSelectionListener(new SelectionAdapter() {
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> shell.close();
> }
> });
> }
>
> public static void main(String[] args) {
> Display display = Display.getDefault();
> try {
> //The regular shell will be able to grow
> final Shell shell = new Shell();
>
> shell.setMinimumSize(MIN_SIZE, MIN_SIZE);
>
> shell.setLayout(new GridLayout());
> new ResizeShellSnippet(shell);
> shell.pack();
> shell.setBounds(0, 0, INITIAL_SIZE, INITIAL_SIZE);
>
> shell.open();
>
> //The borderless shell with a minimum size won't be able to grow
> //(Though it can shrink to the minimum size)
> final Shell shell2 = new Shell(SWT.NO_TRIM);
>
> shell2.setMinimumSize(MIN_SIZE, MIN_SIZE);
>
> shell2.setLayout(new GridLayout());
> new ResizeShellSnippet(shell2);
> shell2.pack();
> shell2.setBounds(INITIAL_SIZE, 0, INITIAL_SIZE, INITIAL_SIZE);
>
> shell2.open();
>
> while (!shell.isDisposed() && !shell2.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> } finally {
> display.dispose();
> }
> }
>
> }
Previous Topic:Problem with toolbar button activation
Next Topic:StackLayout in SashForm
Goto Forum:
  


Current Time: Thu Dec 18 04:17:49 GMT 2014

Powered by FUDForum. Page generated in 0.08719 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software