Skip to content

Commit c6b0af0

Browse files
committed
Make DPI_CHANGED event handling async
With this commit, all the widgets scale themselves asynchronously independent of the order saving the wait time over their children to scale. # Conflicts: # bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
1 parent 7021113 commit c6b0af0

File tree

13 files changed

+33
-16
lines changed

13 files changed

+33
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ public String toString() {
19771977
void handleDPIChange(Event event, float scalingFactor) {
19781978
super.handleDPIChange(event, scalingFactor);
19791979
for (Control child : getChildren()) {
1980-
child.notifyListeners(SWT.ZoomChanged, event);
1980+
child.sendZoomChangedEvent(event, getShell());
19811981
}
19821982
}
19831983
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,7 +4758,7 @@ public boolean setParent (Composite parent) {
47584758
if (parent.nativeZoom != nativeZoom) {
47594759
int newZoom = parent.nativeZoom;
47604760
Event zoomChangedEvent = createZoomChangedEvent(newZoom);
4761-
notifyListeners(SWT.ZoomChanged, zoomChangedEvent);
4761+
sendZoomChangedEvent(zoomChangedEvent, getShell());
47624762
}
47634763
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
47644764
OS.SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);
@@ -4954,7 +4954,7 @@ LRESULT WM_DESTROY (long wParam, long lParam) {
49544954
void handleMonitorSpecificDpiChange(int newNativeZoom, Rectangle newBoundsInPixels) {
49554955
DPIUtil.setDeviceZoom (newNativeZoom);
49564956
Event zoomChangedEvent = createZoomChangedEvent(newNativeZoom);
4957-
notifyListeners(SWT.ZoomChanged, zoomChangedEvent);
4957+
sendZoomChangedEvent(zoomChangedEvent, getShell());
49584958
this.setBoundsInPixels(newBoundsInPixels.x, newBoundsInPixels.y, newBoundsInPixels.width, newBoundsInPixels.height);
49594959
}
49604960

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ void handleDPIChange(Event event, float scalingFactor) {
12211221

12221222
Control control = item.control;
12231223
if (control != null) {
1224-
control.notifyListeners(SWT.ZoomChanged, event);
1224+
control.sendZoomChangedEvent(event, getShell());
12251225
item.setControl(control);
12261226
}
12271227

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,13 +1720,13 @@ void handleDPIChange(Event event, float scalingFactor) {
17201720

17211721
Menu menuBar = getMenuBar();
17221722
if (menuBar != null) {
1723-
menuBar.notifyListeners(SWT.ZoomChanged, event);
1723+
menuBar.sendZoomChangedEvent(event, getShell());
17241724
}
17251725

17261726
if (menus != null) {
17271727
for (Menu menu : menus) {
17281728
if (menu != null) {
1729-
menu.notifyListeners(SWT.ZoomChanged, event);
1729+
menu.sendZoomChangedEvent(event, getShell());
17301730
}
17311731
}
17321732
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ LRESULT wmScroll (ScrollBar bar, boolean update, long hwnd, int msg, long wParam
871871
void handleDPIChange(Event event, float scalingFactor) {
872872
super.handleDPIChange(event, scalingFactor);
873873
for (ExpandItem item : getItems()) {
874-
item.notifyListeners(SWT.ZoomChanged, event);
874+
item.sendZoomChangedEvent(event, getShell());
875875
}
876876
layoutItems(0, true);
877877
redraw();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ LRESULT wmTimer (long wParam, long lParam) {
13661366
void handleDPIChange(Event event, float scalingFactor) {
13671367
super.handleDPIChange(event, scalingFactor);
13681368
for (MenuItem item : getItems()) {
1369-
item.notifyListeners(SWT.ZoomChanged, event);
1369+
item.sendZoomChangedEvent(event, getShell());
13701370
}
13711371
}
13721372
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ void handleDPIChange(Event event, float scalingFactor) {
14631463
// Refresh the sub menu
14641464
Menu subMenu = getMenu();
14651465
if (subMenu != null) {
1466-
subMenu.notifyListeners(SWT.ZoomChanged, event);
1466+
subMenu.sendZoomChangedEvent(event, subMenu.getShell());
14671467
}
14681468
}
14691469
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ void handleDPIChange(Event event, float scalingFactor) {
11361136
imageList = null;
11371137
}
11381138
for (int i = 0; i < getItemCount(); i++) {
1139-
items[i].notifyListeners(SWT.ZoomChanged, event);
1139+
items[i].sendZoomChangedEvent(event, getShell());
11401140
}
11411141
layout(true, true);
11421142
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7365,10 +7365,10 @@ void handleDPIChange(Event event, float scalingFactor) {
73657365
setItemHeight(-1);
73667366

73677367
for (TableItem item : getItems()) {
7368-
item.notifyListeners(SWT.ZoomChanged, event);
7368+
item.sendZoomChangedEvent(event, getShell());
73697369
}
73707370
for (TableColumn tableColumn : getColumns()) {
7371-
tableColumn.notifyListeners(SWT.ZoomChanged, event);
7371+
tableColumn.sendZoomChangedEvent(event, getShell());
73727372
}
73737373

73747374
if (getColumns().length == 0 && scrollWidth != 0) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ record ToolItemData(ToolItem toolItem, TBBUTTON button) {
17701770
// at the end
17711771
seperatorWidth[i] = item.getWidth();
17721772
}
1773-
item.notifyListeners(SWT.ZoomChanged, event);
1773+
item.sendZoomChangedEvent(event, getShell());
17741774
buttondata.push(new ToolItemData(item, lpButton));
17751775
OS.SendMessage(handle, OS.TB_DELETEBUTTON, i, 0);
17761776
}

0 commit comments

Comments
 (0)