Skip to content

Commit 7300cb4

Browse files
amartya4256fedejeanneHeikoKlare
committed
Reduce flickering in embedded controls
Ignore calls to Control::setRedraw(false) 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 Co-authored-by: Federico Jeanne <[email protected]> Co-authored-by: Heiko Klare <[email protected]>
1 parent 485f9db commit 7300cb4

File tree

1 file changed

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

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616

1717

1818
import java.util.*;
19+
import java.util.stream.*;
1920

2021
import org.eclipse.swt.*;
2122
import org.eclipse.swt.accessibility.*;
23+
import org.eclipse.swt.browser.*;
2224
import org.eclipse.swt.events.*;
2325
import org.eclipse.swt.graphics.*;
2426
import org.eclipse.swt.internal.*;
2527
import org.eclipse.swt.internal.gdip.*;
2628
import org.eclipse.swt.internal.ole.win32.*;
2729
import org.eclipse.swt.internal.win32.*;
30+
import org.eclipse.swt.ole.win32.*;
2831

2932
/**
3033
* Control is the abstract superclass of all windowed user interface classes.
@@ -3631,6 +3634,21 @@ boolean setRadioSelection (boolean value) {
36313634
*/
36323635
public void setRedraw (boolean redraw) {
36333636
checkWidget ();
3637+
3638+
/*
3639+
* Some embedded applications like webview2 (Edge), Excel, etc have a renderer
3640+
* that will draw the whole application white when setting redraw to false and
3641+
* will repaint it completely when setting it to true. This causes flickering,
3642+
* which is why turning redraw off is not allowed in case this control has an
3643+
* embedded application as a child.
3644+
*
3645+
* https://github.com/eclipse-platform/eclipse.platform.swt/issues/1122
3646+
*/
3647+
boolean isShown = isVisible() && !isDisposed();
3648+
if (!redraw && isShown && embedsWin32Control()) {
3649+
return;
3650+
}
3651+
36343652
/*
36353653
* Feature in Windows. When WM_SETREDRAW is used to turn
36363654
* off drawing in a widget, it clears the WS_VISIBLE bits
@@ -3667,6 +3685,25 @@ public void setRedraw (boolean redraw) {
36673685
}
36683686
}
36693687

3688+
private boolean embedsWin32Control () {
3689+
if (this instanceof Browser) {
3690+
// The Edge browser embeds webView2
3691+
return (getStyle() & SWT.EDGE) != 0;
3692+
}
3693+
3694+
if (this instanceof OleClientSite) {
3695+
// OLE objects are always embedded by windows
3696+
return true;
3697+
}
3698+
3699+
// This needs to be checked AFTER OleClientSite because OleClientSite itself is a Composite
3700+
if (this instanceof Composite comp) {
3701+
return Stream.of(comp.getChildren()).anyMatch(Control::embedsWin32Control);
3702+
}
3703+
3704+
return false;
3705+
}
3706+
36703707
/**
36713708
* Sets the shape of the control to the region specified
36723709
* by the argument. When the argument is null, the

0 commit comments

Comments
 (0)