Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321803 - pack() on dialog with table doesn't take task bar into account when sizing
Summary: pack() on dialog with table doesn't take task bar into account when sizing
Status: CLOSED NOT_ECLIPSE
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-04 18:21 EDT by Larry Colson CLA
Modified: 2010-11-01 10:15 EDT (History)
2 users (show)

See Also:


Attachments
Test case (2.33 KB, application/octet-stream)
2010-08-04 18:22 EDT, Larry Colson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Colson CLA 2010-08-04 18:21:19 EDT
Build Identifier: M20100211-1343

I have a dialog box with a Table and a Button.  There are enough rows in the table to cause pack() to size the box to it's vertical maximum.  However, when the box is sized vertically, the screen space taken up by the Windows task bar is not taken into account, so there is a space at the bottom of the dialog that is hidden underneath the task bar.  If the dialog is moved slightly above the top of the screen, you can see part of the bottom of the dialog, but most users simply get frustrated.

Pack() should assume that the vertical (or horizontal, if the task bar is on the right or left edge) is not part of the visible area when computing the maximum size.

This behavior happens on XP, Vista and Windows 7.  

Reproducible: Always

Steps to Reproduce:
1. run test case
2. press open button
3. note that dialog, even when moved to the top, is not completely visible.
Comment 1 Larry Colson CLA 2010-08-04 18:22:25 EDT
Created attachment 175898 [details]
Test case
Comment 2 Larry Colson CLA 2010-10-29 14:53:40 EDT
I reported this a couple of months ago.  I'm starting to get a lot of customer complaints since they often have to resize dialog boxes to be able to see the buttons on the bottom.  I wanted to see if someone could take a look at it.
Comment 3 Felipe Heidrich CLA 2010-11-01 10:15:03 EDT
Hi, sorry for the delayed answer. Things are pretty busy around here.

I finally had a change to take a lot at your snippet. The problem is in the application code. You can't expect shell.pack() to cap the size of the shell to the client area of the display. That is not what it does.
The table in the shell has 1000 items it forces pack size of the shell to be over 1400px in height (windows caps the size of the shell to the bounds of the display, but that is platform behaviour - you should not relie on that neither).

For your code to work as you expect you should, remove:
shell.pack();

and add:
Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Rectangle maxSize = shell.getDisplay().getClientArea();
if (size.x > maxSize.width) size.x = maxSize.width;
if (size.y > maxSize.height) size.y = maxSize.height;
shell.setSize(size);