Skip to content

Commit 5725570

Browse files
amartya4256fedejeanne
authored andcommitted
Reduce flickering in embedded controls
Ignore calls to Control::setRedraw(boolean) if the control contains any embedded application as a child. This change does not completely get rid of the flickering but it reduces it drastically. Contributes to #1122
1 parent fa71076 commit 5725570

File tree

1 file changed

+39
-0
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ 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+
5860
/**
5961
* the handle to the OS resource
6062
* (Warning: This field is platform dependent)
@@ -711,6 +713,9 @@ void createWidget () {
711713
if ((state & PARENT_BACKGROUND) != 0) {
712714
setBackground ();
713715
}
716+
if((style & SWT.EMBEDDED) != 0) {
717+
embeddedControls.add(this);
718+
}
714719
}
715720

716721
int defaultBackground () {
@@ -2494,6 +2499,9 @@ void releaseParent () {
24942499
@Override
24952500
void releaseWidget () {
24962501
super.releaseWidget ();
2502+
if((style & SWT.EMBEDDED) != 0) {
2503+
embeddedControls.remove(this);
2504+
}
24972505
if (toolTipText != null) {
24982506
setToolTipText (getShell (), null);
24992507
}
@@ -3606,6 +3614,23 @@ boolean setRadioSelection (boolean value) {
36063614
return false;
36073615
}
36083616

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+
36093634
/**
36103635
* If the argument is <code>false</code>, causes subsequent drawing
36113636
* operations in the receiver to be ignored. No drawing of any kind
@@ -3631,6 +3656,20 @@ boolean setRadioSelection (boolean value) {
36313656
*/
36323657
public void setRedraw (boolean redraw) {
36333658
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 on/off is disabled in these cases.
3666+
*
3667+
* https://github.com/eclipse-platform/eclipse.platform.swt/issues/1122
3668+
*/
3669+
if(hasEmbeddedChildren()) {
3670+
return;
3671+
}
3672+
36343673
/*
36353674
* Feature in Windows. When WM_SETREDRAW is used to turn
36363675
* off drawing in a widget, it clears the WS_VISIBLE bits

0 commit comments

Comments
 (0)