Skip to content

Commit 130befe

Browse files
committed
Temporary commit: do the check in Composite instead of Control
1 parent 2bcb4ed commit 130befe

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,40 @@ void setResizeChildren (boolean resize) {
11831183
}
11841184
}
11851185

1186+
@Override
1187+
public void setRedraw(boolean redraw) {
1188+
/*
1189+
* Some embedded applications like webview2 (Edge), Excel, etc have a renderer
1190+
* that will draw the whole application white when setting redraw to false and
1191+
* will repaint it completely when setting it to true. This causes flickering,
1192+
* which is why turning redraw off is not allowed in case this control has an
1193+
* embedded application as a child.
1194+
*
1195+
* https://github.com/eclipse-platform/eclipse.platform.swt/issues/1122
1196+
*/
1197+
boolean isEmbedded = (style & SWT.EMBEDDED) != 0;
1198+
if (!redraw && (isEmbedded || hasEmbeddedChildren())) {
1199+
return;
1200+
}
1201+
super.setRedraw(redraw);
1202+
}
1203+
1204+
private boolean hasEmbeddedChildren() {
1205+
for (Control child : getChildren()) {
1206+
if (!child.isDisposed() && child.isVisible()) {
1207+
1208+
if ((child.style & SWT.EMBEDDED) != 0)
1209+
return true;
1210+
1211+
// if it's a composite, check its children too
1212+
if (child instanceof Composite comp && comp.hasEmbeddedChildren())
1213+
return true;
1214+
}
1215+
}
1216+
1217+
return false;
1218+
}
1219+
11861220
@Override
11871221
boolean setTabGroupFocus () {
11881222
if (isTabItem ()) return setTabItemFocus ();

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public abstract class Control extends Widget implements Drawable {
5555
DPIZoomChangeRegistry.registerHandler(Control::handleDPIChange, Control.class);
5656
}
5757

58-
private static Set<Control> embeddedControls = new HashSet<>();
59-
6058
/**
6159
* the handle to the OS resource
6260
* (Warning: This field is platform dependent)
@@ -713,9 +711,6 @@ void createWidget () {
713711
if ((state & PARENT_BACKGROUND) != 0) {
714712
setBackground ();
715713
}
716-
if((style & SWT.EMBEDDED) != 0) {
717-
embeddedControls.add(this);
718-
}
719714
}
720715

721716
int defaultBackground () {
@@ -2499,9 +2494,6 @@ void releaseParent () {
24992494
@Override
25002495
void releaseWidget () {
25012496
super.releaseWidget ();
2502-
if((style & SWT.EMBEDDED) != 0) {
2503-
embeddedControls.remove(this);
2504-
}
25052497
if (toolTipText != null) {
25062498
setToolTipText (getShell (), null);
25072499
}
@@ -3614,23 +3606,6 @@ boolean setRadioSelection (boolean value) {
36143606
return false;
36153607
}
36163608

3617-
private boolean hasEmbeddedChildren() {
3618-
for (Control ec : embeddedControls) {
3619-
if (!ec.isDisposed() && ec.isVisible() && ec.isChildOf(this)) return true;
3620-
}
3621-
return false;
3622-
}
3623-
3624-
private boolean isChildOf(Control parent) {
3625-
Control c = this;
3626-
while (c != null) {
3627-
if (c == parent) return true;
3628-
3629-
c = c.getParent();
3630-
}
3631-
return false;
3632-
}
3633-
36343609
/**
36353610
* If the argument is <code>false</code>, causes subsequent drawing
36363611
* operations in the receiver to be ignored. No drawing of any kind
@@ -3656,21 +3631,6 @@ private boolean isChildOf(Control parent) {
36563631
*/
36573632
public void setRedraw (boolean redraw) {
36583633
checkWidget ();
3659-
3660-
/*
3661-
* Some embedded applications like webview2 (Edge), Excel, etc
3662-
* have a renderer that will draw the whole application white
3663-
* when setting redraw to false and will repaint it completely
3664-
* when setting it to true. This causes flickering, which is why
3665-
* turning redraw off is not allowed in case this control has an
3666-
* embedded application as a child.
3667-
*
3668-
* https://github.com/eclipse-platform/eclipse.platform.swt/issues/1122
3669-
*/
3670-
if(!redraw && hasEmbeddedChildren()) {
3671-
return;
3672-
}
3673-
36743634
/*
36753635
* Feature in Windows. When WM_SETREDRAW is used to turn
36763636
* off drawing in a widget, it clears the WS_VISIBLE bits

0 commit comments

Comments
 (0)