diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java index ed6ca58..5fff895 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/SashLayout.java @@ -16,8 +16,6 @@ import org.eclipse.e4.ui.model.application.ui.MGenericTile; import org.eclipse.e4.ui.model.application.ui.MUIElement; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; @@ -25,7 +23,9 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class SashLayout extends Layout { @@ -36,7 +36,7 @@ public class SashLayout extends Layout { int marginRight = 0; int marginTop = 0; int marginBottom = 0; - int sashWidth = 4; + int sashWidth = 0; MUIElement root; private Composite host; @@ -79,11 +79,17 @@ public class SashLayout extends Layout { } }); - host.addMouseMoveListener(new MouseMoveListener() { - public void mouseMove(final MouseEvent e) { + host.getDisplay().addFilter(SWT.MouseMove, new Listener() { + public void handleEvent(Event event) { + if (!(event.widget instanceof Control)) { + return; + } + Control control = (Control) event.widget; + Point displayLocation = control.toDisplay(event.x, event.y); + Point locationInHost = host.toControl(displayLocation); if (!draggingSashes) { - // Set the cursor feedback - List sashList = getSashRects(e.x, e.y); + List sashList = getSashRects(locationInHost.x, + locationInHost.y); if (sashList.size() == 0) { host.setCursor(host.getDisplay().getSystemCursor( SWT.CURSOR_ARROW)); @@ -101,7 +107,8 @@ public class SashLayout extends Layout { } else { try { layoutUpdateInProgress = true; - adjustWeights(sashesToDrag, e.x, e.y); + adjustWeights(sashesToDrag, locationInHost.x, + locationInHost.y); host.layout(); host.update(); } finally { @@ -111,24 +118,26 @@ public class SashLayout extends Layout { } }); - host.addMouseListener(new MouseListener() { - public void mouseUp(MouseEvent e) { - host.setCapture(false); - draggingSashes = false; - } - - public void mouseDown(MouseEvent e) { - if (e.button != 1) + host.getDisplay().addFilter(SWT.MouseDown, new Listener() { + public void handleEvent(Event event) { + if (event.button != 1) return; - - sashesToDrag = getSashRects(e.x, e.y); - if (sashesToDrag.size() > 0) { - draggingSashes = true; - host.setCapture(true); + if (event.widget instanceof Control) { + Control control = (Control) event.widget; + Point displayLocation = control.toDisplay(event.x, event.y); + Point locationInHost = host.toControl(displayLocation); + sashesToDrag = getSashRects(locationInHost.x, + locationInHost.y); + if (sashesToDrag.size() > 0) { + draggingSashes = true; + } } } + }); - public void mouseDoubleClick(MouseEvent e) { + host.getDisplay().addFilter(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + draggingSashes = false; } }); @@ -286,9 +295,9 @@ public class SashLayout extends Layout { // Add a 'sash' between this node and the 'prev' if (prev != null) { Rectangle sashRect = sashContainer.isHorizontal() ? new Rectangle( - tilePos, bounds.y, sashWidth, bounds.height) - : new Rectangle(bounds.x, tilePos, bounds.width, - sashWidth); + tilePos - 1, bounds.y, sashWidth + 4, bounds.height) + : new Rectangle(bounds.x, tilePos - 2, bounds.width, + sashWidth + 2); sashes.add(new SashRect(sashRect, sashContainer, prev, subNode)); host.redraw(sashRect.x, sashRect.y, sashRect.width, sashRect.height, false);