Skip to content

Commit 1f08dec

Browse files
author
zhourenjian
committed
Fixed bug on "new Display()" will create another layer of TaskBar, QuickLaunch and others
Fixed bug that clicking on taskbar's item does not bring window to top
1 parent 99224d4 commit 1f08dec

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Decorations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
385385
if ((style & SWT.NO_TRIM) == 0) {
386386
if ((style & (SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX)) != 0) {
387387
//height += 20;
388-
height += OS.getContainerHeight(titleBar);
388+
height += Math.max(OS.getContainerHeight(titleBar), 19);
389389
if (width < 105) {
390390
width = 105;
391391
}
@@ -922,7 +922,7 @@ public Rectangle getClientArea () {
922922
int h = height;
923923
if ((style & (SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX)) != 0) {
924924
//h -= 20;
925-
h -= OS.getContainerHeight(titleBar);
925+
h -= Math.max(OS.getContainerHeight(titleBar), 19);
926926
w -= 8;
927927
//h -= 8;
928928
h -= 5;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Display.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,11 +2438,23 @@ protected void init () {
24382438
if (document.onclick == null) {
24392439
bringShellToTop();
24402440
}
2441-
2441+
24422442
initializeDekstop();
24432443
}
24442444

24452445
void initializeDekstop() {
2446+
for (int i = 0; i < Displays.length; i++) {
2447+
Display disp = Displays[i];
2448+
if (disp != this && disp != null && !disp.isDisposed()) {
2449+
taskBar = disp.taskBar;
2450+
topBar = disp.topBar;
2451+
shortcutBar = disp.shortcutBar;
2452+
trayCorner = disp.trayCorner;
2453+
desktopItems = disp.desktopItems;
2454+
return;
2455+
}
2456+
}
2457+
24462458
if (desktopItems != null) return;
24472459

24482460
desktopItems = new DesktopItem[] {
@@ -3354,6 +3366,18 @@ protected void release () {
33543366
}
33553367

33563368
void releaseDesktop () {
3369+
boolean existed = false;
3370+
for (int i = 0; i < Displays.length; i++) {
3371+
Display disp = Displays[i];
3372+
if (disp != this && disp != null && !disp.isDisposed()) {
3373+
existed = true;
3374+
break;
3375+
}
3376+
}
3377+
if (existed) {
3378+
return;
3379+
}
3380+
33573381
for (int i = 0; i < desktopItems.length; i++) {
33583382
desktopItems[i].releaseWidget();
33593383
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/TaskBar.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void run() {
161161
*/ { }
162162
si.appendChild(div);
163163
div.appendChild(document.createTextNode(text));
164-
int w = OS.getStringStyledWidth(text, "shell-item-text", "");
164+
int w = OS.getStringStyledWidth(text, "shell-item-text", "") + 8;
165165
if (w > 120) {
166166
w = 120;
167167
}
@@ -173,6 +173,7 @@ public void run() {
173173
@Override
174174
public void run() {
175175
if (shell.getMinimized()) {
176+
shell.setMinimized(false);
176177
shell.bringToTop();
177178
} else {
178179
Shell lastShell = Display.getTopShell();

0 commit comments

Comments
 (0)