Skip to content
Draft
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 @@ -16,6 +16,7 @@


import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.stream.*;

Expand Down Expand Up @@ -5982,6 +5983,7 @@ LRESULT wmScrollChild (long wParam, long lParam) {
static class DPIChangeExecution {
AtomicInteger taskCount = new AtomicInteger();
private boolean asyncExec = true;
ExecutorService executor = Executors.newSingleThreadExecutor();

private void process(Control control, Runnable operation) {
boolean currentAsyncExec = asyncExec;
Expand All @@ -5992,7 +5994,9 @@ private void process(Control control, Runnable operation) {
asyncExec &= (comp.layout != null);
}
if (asyncExec) {
control.getDisplay().asyncExec(operation::run);
executor.submit(() -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea: couldn't we even simplify this by just having a single async task that sequentially runs through the controls and performs a syncExec with the operation on them? Maybe could even get rid of the counter then as there would be a single reponsingle (the executor) for tracking the process.
Maybe that's not possible or too complicated to adapt the implementation, but could be an interesting potential for simplification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is currently one executor per DPI_CHANGE event yes. I could try getting rid of the counter and see how it affects the overall event.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After having a look, I think it is not possible to track the end of execution without using a counter because all the controls are notified from within handleDPIChange event and that happens during the execution of each control.

control.getDisplay().syncExec(operation::run);
});
} else {
operation.run();
}
Expand Down
Loading