Skip to content

Commit b9d76f4

Browse files
author
zhourenjian
committed
1. Adjust window location.
2. Fixed bug that menu bar's location is wrong when title is null 3. Fixed bug that disposing Display instance does not dispose timer threads.
1 parent 5b20daf commit b9d76f4

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ void bringToTop () {
235235
&& (style.height == null || style.height.length() == 0)){
236236
setSize(this.width, this.height);
237237
}
238+
setLocation(this.left, this.top);
238239
/**
239240
* @j2sNative
240241
* var title = this.getText();
@@ -571,7 +572,18 @@ public void run() {
571572
handle = document.createElement("DIV");
572573
handle.className = "shell-default shell-trim";
573574
handle.style.visibility = "hidden";
574-
nextWindowLocation();
575+
576+
//nextWindowLocation();
577+
578+
if (window.defaultWindowWidth == null) {
579+
window.defaultWindowWidth = "768";
580+
}
581+
if (window.defaultWindowHeight == null) {
582+
window.defaultWindowHeight = "557";
583+
}
584+
width = Integer.parseInt(window.defaultWindowWidth);
585+
height = Integer.parseInt(window.defaultWindowHeight);
586+
575587
this.width = 768;
576588
this.height = 557;
577589
// if ((style & SWT.NO_TRIM) == 0 & (style & SWT.RESIZE) != 0) {
@@ -668,44 +680,36 @@ public void run() {
668680

669681
}
670682

671-
private void nextWindowLocation() {
683+
void nextWindowLocation(int wHint, int hHint) {
684+
int delta = OS.getStringPlainHeight("A") + 4 + 6 + 1;
672685
if (window.defaultWindowLeft == null) {
673-
window.defaultWindowLeft = "132";
686+
window.defaultWindowLeft = "64";
674687
} else {
675688
int num = Integer.parseInt("" + window.defaultWindowLeft);
676-
if (this.parent == null) num += 32;
677-
if (num > getMonitor().clientWidth) {
678-
num = 32;
689+
if (this.parent == null) num += delta;
690+
if (num + wHint > getMonitor().clientWidth) {
691+
num = delta;
679692
}
680693
window.defaultWindowLeft = "" + num;
681694
}
682695
if (window.defaultWindowTop == null) {
683-
window.defaultWindowTop = "32";
696+
window.defaultWindowTop = "64";
684697
} else {
685698
int num = Integer.parseInt("" + window.defaultWindowTop);
686-
if (this.parent == null) num += 32;
687-
if (num > getMonitor().clientHeight) {
688-
num = 32;
699+
if (this.parent == null) num += delta;
700+
if (num + hHint > getMonitor().clientHeight) {
701+
num = delta;
689702
}
690703
window.defaultWindowTop = "" + num;
691704
}
692-
if (window.defaultWindowWidth == null) {
693-
window.defaultWindowWidth = "768";
694-
}
695-
if (window.defaultWindowHeight == null) {
696-
window.defaultWindowHeight = "557";
697-
}
698705
left = Integer.parseInt(window.defaultWindowLeft);
699706
top = Integer.parseInt(window.defaultWindowTop);
700707
if (parent != null) {
701-
left += 32;
702-
top += 32;
708+
left += delta;
709+
top += delta;
703710
}
704711
left += OS.getFixedBodyOffsetLeft ();
705712
top += OS.getFixedBodyOffsetTop ();
706-
707-
width = Integer.parseInt(window.defaultWindowWidth);
708-
height = Integer.parseInt(window.defaultWindowHeight);
709713
}
710714

711715
void addModalLayer() {
@@ -2156,6 +2160,7 @@ public void run() {
21562160
}
21572161
shellTitle = document.createElement("DIV");
21582162
shellTitle.className = "shell-title-text";
2163+
shellTitle.appendChild(document.createTextNode("" + (char) 160));
21592164

21602165
/**
21612166
* Ubuntu's Firefox has different active caption background color!

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,6 +3265,18 @@ protected void release () {
32653265
}
32663266
}
32673267
disposeList = null;
3268+
if (timerIds != null) {
3269+
for (int i=0; i<timerIds.length; i++) {
3270+
if (timerIds [i] != 0) window.clearInterval(timerIds[i]);
3271+
}
3272+
}
3273+
timerIds = null;
3274+
if (timerList != null) {
3275+
for (int i=0; i<timerList.length; i++) {
3276+
if (timerList [i] != null) timerList[i] = null;
3277+
}
3278+
}
3279+
timerList = null;
32683280
// synchronizer.releaseSynchronizer ();
32693281
// synchronizer = null;
32703282
releaseDisplay ();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ int hwndMDIClient () {
888888
*/
889889
public void open () {
890890
checkWidget ();
891+
nextWindowLocation(width, height);
891892
bringToTop ();
892893
if (isDisposed ()) return;
893894
/*

0 commit comments

Comments
 (0)