Skip to content

Commit 98d88d5

Browse files
author
jossonsmith
committed
Fixed a bug that moving a window will trim the window out of some 4x4 dimension.
1 parent b45804c commit 98d88d5

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/dnd/ShellFrameDND.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626
* 2006-3-15
2727
*/
2828
public class ShellFrameDND implements DragListener {
29-
int sourceX = 0;
30-
int sourceY = 0;
31-
int sourceWidth = 0;
32-
int sourceHeight = 0;
29+
protected int sourceX = 0;
30+
protected int sourceY = 0;
31+
protected int sourceWidth = 0;
32+
protected int sourceHeight = 0;
3333
String resize = null;
3434
Element frame = null;
3535
private Element overFrameHandle;
36+
3637
public boolean isDraggable(HTMLEventWrapper e) {
3738
String cssName = e.target.className;
3839
if (cssName != null) {
@@ -90,6 +91,7 @@ public boolean dragBegan(DragEvent e) {
9091
e.startX = e.currentX;
9192
e.startY = e.currentY;
9293
if (firstTime) {
94+
this.initFrameBounds(this.sourceX, this.sourceY, this.sourceWidth, this.sourceHeight);
9395
this.frame.style.width = this.sourceWidth + "px";
9496
this.frame.style.height = this.sourceHeight + "px";
9597
}
@@ -250,6 +252,12 @@ private void clean() {
250252
overFrameHandle = null;
251253
}
252254
};
255+
/**
256+
* To initialize bounds.
257+
*/
258+
public boolean initFrameBounds(int x, int y, int width, int height) {
259+
return true;
260+
};
253261
public boolean updateShellBounds(int x, int y, int width, int height) {
254262
return true;
255263
};

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ public void run() {
588588
if (DragAndDrop.class != null) {
589589
DragAndDrop dnd = new DragAndDrop();
590590
dnd.addDragListener(new ShellFrameDND() {
591+
protected int deltaWidth = 0;
592+
protected int deltaHeight = 0;
591593
public boolean isDraggable(HTMLEventWrapper e) {
592594
if (super.isDraggable(e) && !getMaximized()) {
593595
String cssName = e.target.className;
@@ -600,8 +602,16 @@ public boolean isDraggable(HTMLEventWrapper e) {
600602
return false;
601603
}
602604
}
605+
public boolean initFrameBounds(int x, int y, int width, int height) {
606+
Rectangle bs = getBounds();
607+
this.deltaWidth = this.sourceWidth - bs.width;
608+
this.deltaHeight = this.sourceHeight - bs.height;
609+
return true;
610+
}
603611
public boolean updateShellBounds(int x, int y, int w, int h) {
604612
boolean moved = (x != left || y != top);
613+
w -= deltaWidth;
614+
h -= deltaHeight;
605615
boolean resized = (w != width || h != height);
606616
setBounds(x, y, w, h);
607617
if (moved) {

0 commit comments

Comments
 (0)