Skip to content

Commit 1f5c07c

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 2ce8542 commit 1f5c07c

File tree

1 file changed

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

1 file changed

+42
-0
lines changed

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

Lines changed: 42 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,30 @@ public void setRedraw (boolean redraw) {
36673685
}
36683686
}
36693687

3688+
/**
3689+
* @return <code>true</code> if this component embeds a win32 control.
3690+
*/
3691+
private boolean embedsWin32Control () {
3692+
if (this instanceof Browser) {
3693+
// The Edge browser embeds webView2
3694+
System.out.println("Edge browser embeded!");
3695+
return (getStyle() & SWT.EDGE) != 0;
3696+
}
3697+
3698+
if (this instanceof OleClientSite) {
3699+
// OLE objects are always embedded by windows
3700+
System.out.println("OLE embeded!");
3701+
return true;
3702+
}
3703+
3704+
// This needs to be checked AFTER OleClientSite because OleClientSite itself is a Composite
3705+
if (this instanceof Composite comp) {
3706+
return Stream.of(comp.getChildren()).anyMatch(Control::embedsWin32Control);
3707+
}
3708+
3709+
return false;
3710+
}
3711+
36703712
/**
36713713
* Sets the shape of the control to the region specified
36723714
* by the argument. When the argument is null, the

0 commit comments

Comments
 (0)