|
16 | 16 |
|
17 | 17 |
|
18 | 18 | import java.util.*;
|
| 19 | +import java.util.stream.*; |
19 | 20 |
|
20 | 21 | import org.eclipse.swt.*;
|
21 | 22 | import org.eclipse.swt.accessibility.*;
|
| 23 | +import org.eclipse.swt.browser.*; |
22 | 24 | import org.eclipse.swt.events.*;
|
23 | 25 | import org.eclipse.swt.graphics.*;
|
24 | 26 | import org.eclipse.swt.internal.*;
|
25 | 27 | import org.eclipse.swt.internal.gdip.*;
|
26 | 28 | import org.eclipse.swt.internal.ole.win32.*;
|
27 | 29 | import org.eclipse.swt.internal.win32.*;
|
| 30 | +import org.eclipse.swt.ole.win32.*; |
28 | 31 |
|
29 | 32 | /**
|
30 | 33 | * Control is the abstract superclass of all windowed user interface classes.
|
@@ -3631,6 +3634,21 @@ boolean setRadioSelection (boolean value) {
|
3631 | 3634 | */
|
3632 | 3635 | public void setRedraw (boolean redraw) {
|
3633 | 3636 | 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 | + |
3634 | 3652 | /*
|
3635 | 3653 | * Feature in Windows. When WM_SETREDRAW is used to turn
|
3636 | 3654 | * off drawing in a widget, it clears the WS_VISIBLE bits
|
@@ -3667,6 +3685,25 @@ public void setRedraw (boolean redraw) {
|
3667 | 3685 | }
|
3668 | 3686 | }
|
3669 | 3687 |
|
| 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 | + |
3670 | 3707 | /**
|
3671 | 3708 | * Sets the shape of the control to the region specified
|
3672 | 3709 | * by the argument. When the argument is null, the
|
|
0 commit comments