Skip to content
Merged
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,7 @@ private DPITestUtil() {

public static void changeDPIZoom (Shell shell, int nativeZoom) {
DPIUtil.setDeviceZoom(nativeZoom);
Event event = shell.createZoomChangedEvent(nativeZoom);
Event event = shell.createZoomChangedEvent(nativeZoom, true);
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 @@ -4784,12 +4784,9 @@ public boolean setParent (Composite parent) {
if (OS.SetParent (topHandle, parent.handle) == 0) return false;
this.parent = parent;
// If parent changed, zoom level might need to be adjusted
if (parent.nativeZoom != nativeZoom) {
int newZoom = parent.nativeZoom;
Event zoomChangedEvent = createZoomChangedEvent(newZoom);
if (currentDpiChangeEvent != null) {
currentDpiChangeEvent.doit = false;
}
int newZoom = parent.nativeZoom;
if (newZoom != nativeZoom) {
Event zoomChangedEvent = createZoomChangedEvent(newZoom, false);
sendZoomChangedEvent(zoomChangedEvent, getShell());
}
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
Expand Down Expand Up @@ -4985,7 +4982,10 @@ LRESULT WM_DESTROY (long wParam, long lParam) {

private void handleMonitorSpecificDpiChange(int newNativeZoom, Rectangle newBoundsInPixels) {
DPIUtil.setDeviceZoom (newNativeZoom);
Event zoomChangedEvent = createZoomChangedEvent(newNativeZoom);
// 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 = getShell().getParent() == null;
Event zoomChangedEvent = createZoomChangedEvent(newNativeZoom, processDpiChangeAsynchronous);
if (currentDpiChangeEvent != null) {
currentDpiChangeEvent.doit = false;
}
Expand All @@ -4994,13 +4994,15 @@ private void handleMonitorSpecificDpiChange(int newNativeZoom, Rectangle newBoun
this.setBoundsInPixels(newBoundsInPixels.x, newBoundsInPixels.y, newBoundsInPixels.width, newBoundsInPixels.height);
}

Event createZoomChangedEvent(int zoom) {
Event createZoomChangedEvent(int zoom, boolean asyncExec) {
Event event = new Event();
event.type = SWT.ZoomChanged;
event.widget = this;
event.detail = zoom;
event.doit = true;
event.data = new DPIChangeExecution();
DPIChangeExecution dpiChangeExecution = new DPIChangeExecution();
dpiChangeExecution.asyncExec = asyncExec;
event.data = dpiChangeExecution;
return event;
}

Expand Down
Loading