Skip to content

Commit cf39518

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 cfa74b4 commit cf39518

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,14 @@ public int getStyle () {
729729
return super.getStyle () | (userStyle & SWT.BORDER);
730730
}
731731

732+
/**
733+
* @since 3.129
734+
*/
735+
@Override
736+
protected boolean win32_embeds() {
737+
// The Edge browser embeds webView2
738+
return (getStyle() & SWT.EDGE) != 0;
739+
}
732740
/**
733741
* Returns a string with HTML that represents the content of the current page.
734742
*

bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,15 @@ private boolean isOffice2007(boolean program) {
916916
if (programID.equals("PowerPoint.Show.12")) return true; //$NON-NLS-1$
917917
return false;
918918
}
919+
920+
/**
921+
* @since 3.129
922+
*/
923+
@Override
924+
protected boolean win32_embeds() {
925+
// OLE objects are always embedded by windows
926+
return true;
927+
}
919928
private int OnClose() {
920929
return COM.S_OK;
921930
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,6 +4148,15 @@ public void setRedraw (boolean redraw) {
41484148
}
41494149
}
41504150

4151+
/**
4152+
* @return <code>true</code> if this component embeds a win32 component.
4153+
* @since 3.129
4154+
*/
4155+
protected boolean win32_embeds() {
4156+
// Default implementation. It should be rewritten by sub-classes that embed windows components.
4157+
return false;
4158+
}
4159+
41514160
/**
41524161
* Sets the shape of the control to the region specified
41534162
* by the argument. When the argument is null, the

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5968,6 +5968,15 @@ public void setRedraw (boolean redraw) {
59685968
}
59695969
}
59705970

5971+
/**
5972+
* @return <code>true</code> if this component embeds a win32 component.
5973+
* @since 3.129
5974+
*/
5975+
protected boolean win32_embeds() {
5976+
// Default implementation. It should be rewritten by sub-classes that embed windows components.
5977+
return false;
5978+
}
5979+
59715980
@Override
59725981
boolean setTabItemFocus (boolean next) {
59735982
if (!isShowing ()) return false;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package org.eclipse.swt.widgets;
1515

1616

17+
import java.util.stream.*;
18+
1719
import org.eclipse.swt.*;
1820
import org.eclipse.swt.graphics.*;
1921
import org.eclipse.swt.internal.*;
@@ -1183,6 +1185,16 @@ void setResizeChildren (boolean resize) {
11831185
}
11841186
}
11851187

1188+
/**
1189+
* @return <code>true</code> if this component or any of its children embeds a win32 component
1190+
* @since 3.129
1191+
*/
1192+
@Override
1193+
protected boolean win32_embeds() {
1194+
return super.win32_embeds() ||
1195+
Stream.of(getChildren()).anyMatch(Control::win32_embeds);
1196+
}
1197+
11861198
@Override
11871199
boolean setTabGroupFocus () {
11881200
if (isTabItem ()) return setTabItemFocus ();

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,21 @@ boolean setRadioSelection (boolean value) {
36313631
*/
36323632
public void setRedraw (boolean redraw) {
36333633
checkWidget ();
3634+
3635+
/*
3636+
* Some embedded applications like webview2 (Edge), Excel, etc have a renderer
3637+
* that will draw the whole application white when setting redraw to false and
3638+
* will repaint it completely when setting it to true. This causes flickering,
3639+
* which is why turning redraw off is not allowed in case this control has an
3640+
* embedded application as a child.
3641+
*
3642+
* https://github.com/eclipse-platform/eclipse.platform.swt/issues/1122
3643+
*/
3644+
boolean isShown = isVisible() && !isDisposed();
3645+
if (!redraw && isShown && win32_embeds()) {
3646+
return;
3647+
}
3648+
36343649
/*
36353650
* Feature in Windows. When WM_SETREDRAW is used to turn
36363651
* off drawing in a widget, it clears the WS_VISIBLE bits
@@ -3667,6 +3682,15 @@ public void setRedraw (boolean redraw) {
36673682
}
36683683
}
36693684

3685+
/**
3686+
* @return <code>true</code> if this component embeds a win32 component.
3687+
* @since 3.129
3688+
*/
3689+
protected boolean win32_embeds() {
3690+
// Default implementation. It should be rewritten by sub-classes that embed windows components.
3691+
return false;
3692+
}
3693+
36703694
/**
36713695
* Sets the shape of the control to the region specified
36723696
* by the argument. When the argument is null, the

0 commit comments

Comments
 (0)