Skip to content

Commit a106143

Browse files
fedejeanneHeikoKlare
authored andcommitted
Revert "Replace usages of new Image(device, width, height)..." #2162
This reverts commit 807b159. Add regression test. Fixes #2162
1 parent 9eb34bf commit a106143

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,8 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15541554
data.ps = ps;
15551555
data.hwnd = handle;
15561556
GC gc = GC.win32_new (this, data);
1557+
1558+
/* Get the system region for the paint HDC */
15571559
long sysRgn = 0;
15581560
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0 || (style & SWT.NO_MERGE_PAINTS) != 0) {
15591561
sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
@@ -1579,25 +1581,14 @@ LRESULT WM_PAINT (long wParam, long lParam) {
15791581
GC paintGC = null;
15801582
Image image = null;
15811583
if ((style & (SWT.DOUBLE_BUFFERED | SWT.TRANSPARENT)) != 0) {
1584+
image = new Image (display, width, height);
15821585
paintGC = gc;
1583-
int originalStyle = gc.getStyle();
1584-
ImageGcDrawer drawer = new ImageGcDrawer() {
1585-
@Override
1586-
public void drawOn(GC gc, int iWidth, int iHeight) {
1587-
GCData gcData = gc.getGCData ();
1588-
gcData.uiState = data.uiState;
1589-
gc.setForeground (getForeground ());
1590-
gc.setBackground (getBackground ());
1591-
gc.setFont (getFont ());
1592-
1593-
}
1594-
1595-
@Override
1596-
public int getGcStyle() {
1597-
return originalStyle & SWT.RIGHT_TO_LEFT;
1598-
}
1599-
};
1600-
image = new Image (display, drawer, width, height);
1586+
gc = new GC (image, paintGC.getStyle() & SWT.RIGHT_TO_LEFT);
1587+
GCData gcData = gc.getGCData ();
1588+
gcData.uiState = data.uiState;
1589+
gc.setForeground (getForeground ());
1590+
gc.setBackground (getBackground ());
1591+
gc.setFont (getFont ());
16011592
if ((style & SWT.TRANSPARENT) != 0) {
16021593
OS.BitBlt (gc.handle, 0, 0, width, height, paintGC.handle, ps.left, ps.top, OS.SRCCOPY);
16031594
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ public boolean setFocus() {
197197
button2.dispose();
198198
}
199199

200+
/*
201+
* See https://github.com/eclipse-platform/eclipse.platform.swt/issues/2162
202+
*/
203+
@Test
204+
public void test_bug2162_transparentStyle() {
205+
Composite c = new Composite(shell, SWT.TRANSPARENT);
206+
c.addPaintListener(e -> {});
207+
208+
shell.setLayout(new FillLayout());
209+
shell.open();
210+
}
211+
200212
protected Composite getElementExpectedToHaveFocusAfterSetFocusOnParent(Composite visibleChild) {
201213
return visibleChild;
202214
}

0 commit comments

Comments
 (0)