Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ private DPITestUtil() {

public static void changeDPIZoom (Shell shell, int nativeZoom) {
DPIUtil.setDeviceZoom(nativeZoom);
Event event = shell.createZoomChangedEvent(nativeZoom, true);
DPIChangeExecution dpiChangeExecution = new DPIChangeExecution(true, null);
Event event = shell.createZoomChangedEvent(nativeZoom, dpiChangeExecution);
shell.sendZoomChangedEvent(event, shell);
DPIChangeExecution data = (DPIChangeExecution) event.data;
waitForDPIChange(shell, TIMEOUT_MILLIS, data.taskCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4791,7 +4791,8 @@ public boolean setParent (Composite parent) {
// If parent changed, zoom level might need to be adjusted
int newZoom = parent.nativeZoom;
if (newZoom != nativeZoom) {
Event zoomChangedEvent = createZoomChangedEvent(newZoom, false);
DPIChangeExecution dpiChangeExecution = new DPIChangeExecution(false, null);
Event zoomChangedEvent = createZoomChangedEvent(newZoom, dpiChangeExecution);
sendZoomChangedEvent(zoomChangedEvent, getShell());
}
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
Expand Down Expand Up @@ -5009,14 +5010,12 @@ LRESULT WM_DESTROY (long wParam, long lParam) {
return null;
}

Event createZoomChangedEvent(int zoom, boolean asyncExec) {
Event createZoomChangedEvent(int zoom, DPIChangeExecution dpiChangeExecution) {
Event event = new Event();
event.type = SWT.ZoomChanged;
event.widget = this;
event.detail = zoom;
event.doit = true;
DPIChangeExecution dpiChangeExecution = new DPIChangeExecution();
dpiChangeExecution.asyncExec = asyncExec;
event.data = dpiChangeExecution;
return event;
}
Expand Down Expand Up @@ -5905,7 +5904,13 @@ LRESULT wmScrollChild (long wParam, long lParam) {

static class DPIChangeExecution {
AtomicInteger taskCount = new AtomicInteger();
private boolean asyncExec = true;
boolean asyncExec = true;
Rectangle shellBounds;

public DPIChangeExecution(boolean asyncExec, Rectangle shellBounds) {
this.asyncExec = asyncExec;
this.shellBounds = shellBounds;
}

private void process(Control control, Runnable operation) {
boolean currentAsyncExec = asyncExec;
Expand Down Expand Up @@ -5948,6 +5953,9 @@ void sendZoomChangedEvent(Event event, Shell shell) {
}
if (dpiExecData.decrement()) {
if (event.doit) {
if (dpiExecData.shellBounds != null) {
shell.setSizeInPixels(dpiExecData.shellBounds.width, dpiExecData.shellBounds.height);
}
shell.layout(true, true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2489,13 +2489,13 @@ private void handleMonitorSpecificDpiChange(int newNativeZoom, Rectangle newBoun
// Do not process DPI change for child shells asynchronous to avoid relayouting when
// repositioning the child shell to a different monitor upon opening
boolean processDpiChangeAsynchronous = getParent() == null;
Event zoomChangedEvent = createZoomChangedEvent(newNativeZoom, processDpiChangeAsynchronous);
DPIChangeExecution dpiChangeExecution = new DPIChangeExecution(processDpiChangeAsynchronous, newBoundsInPixels);
Event zoomChangedEvent = createZoomChangedEvent(newNativeZoom, dpiChangeExecution);
if (lastDpiChangeEvent != null) {
lastDpiChangeEvent.doit = false;
}
lastDpiChangeEvent = zoomChangedEvent;
notifyListeners(SWT.ZoomChanged, zoomChangedEvent);
this.setBoundsInPixels(newBoundsInPixels.x, newBoundsInPixels.y, newBoundsInPixels.width, newBoundsInPixels.height);
}

@Override
Expand Down
Loading