|
24 | 24 |
|
25 | 25 | import java.util.ArrayList;
|
26 | 26 | import java.util.List;
|
| 27 | +import java.util.concurrent.atomic.AtomicInteger; |
27 | 28 | import java.util.function.Supplier;
|
28 | 29 |
|
29 | 30 | import org.eclipse.swt.SWT;
|
|
49 | 50 | import com.biglybt.ui.swt.UIExitUtilsSWT.canCloseListener;
|
50 | 51 | import com.biglybt.ui.swt.mainwindow.Colors;
|
51 | 52 | import com.biglybt.ui.swt.shells.MessageBoxShell;
|
| 53 | +import com.biglybt.ui.swt.shells.opentorrent.OpenTorrentOptionsWindow; |
52 | 54 | import com.biglybt.core.CoreOperation;
|
53 | 55 | import com.biglybt.core.CoreOperationListener;
|
54 | 56 | import com.biglybt.core.CoreOperationTask;
|
|
61 | 63 | {
|
62 | 64 | private static canCloseListener canCloseListener;
|
63 | 65 |
|
| 66 | + private static final AtomicInteger window_id_next = new AtomicInteger(); |
| 67 | + |
| 68 | + private static List<ProgressWindow> active_windows = new ArrayList(); |
| 69 | + |
64 | 70 | public static void
|
65 | 71 | register(
|
66 | 72 | Core core )
|
|
290 | 296 |
|
291 | 297 | private static final ThreadPool core_op_pool = new ThreadPool( "ProgressWindow:coreops", 32, true );
|
292 | 298 |
|
| 299 | + private final int window_id = window_id_next.incrementAndGet(); |
| 300 | + |
293 | 301 | private volatile Shell shell;
|
294 | 302 | private volatile boolean task_complete;
|
295 | 303 |
|
|
524 | 532 | }
|
525 | 533 | }
|
526 | 534 |
|
| 535 | + private Shell |
| 536 | + getShell() |
| 537 | + { |
| 538 | + return( shell ); |
| 539 | + } |
| 540 | + |
527 | 541 | protected void
|
528 | 542 | showDialog(
|
529 | 543 | Shell _shell,
|
@@ -920,7 +934,69 @@ public void widgetDisposed(DisposeEvent arg0){
|
920 | 934 | }
|
921 | 935 | }
|
922 | 936 |
|
923 |
| - shell.open(); |
| 937 | + ProgressWindow moveBelow = null; |
| 938 | + |
| 939 | + for ( ProgressWindow window: active_windows ){ |
| 940 | + |
| 941 | + if ( moveBelow == null || |
| 942 | + moveBelow.window_id < window.window_id ){ |
| 943 | + |
| 944 | + moveBelow = window; |
| 945 | + } |
| 946 | + } |
| 947 | + |
| 948 | + active_windows.add( this ); |
| 949 | + |
| 950 | + shell.addListener( SWT.Dispose, (ev)->{ active_windows.remove( this ); }); |
| 951 | + |
| 952 | + if ( moveBelow == null ){ |
| 953 | + |
| 954 | + shell.open(); |
| 955 | + |
| 956 | + }else{ |
| 957 | + |
| 958 | + shell.moveBelow(moveBelow.getShell()); |
| 959 | + |
| 960 | + shell.setVisible(true); |
| 961 | + } |
| 962 | + |
| 963 | + // don't want them appearing on top of each other |
| 964 | + |
| 965 | + int num_active_windows = active_windows.size(); |
| 966 | + |
| 967 | + if ( num_active_windows > 1 ){ |
| 968 | + |
| 969 | + int max_x = Integer.MIN_VALUE; |
| 970 | + int max_y = Integer.MIN_VALUE; |
| 971 | + |
| 972 | + for ( ProgressWindow window: active_windows ){ |
| 973 | + |
| 974 | + Rectangle rect = window.getShell().getBounds(); |
| 975 | + |
| 976 | + max_x = Math.max( max_x, rect.x ); |
| 977 | + max_y = Math.max( max_y, rect.y ); |
| 978 | + } |
| 979 | + |
| 980 | + if ( max_x > Integer.MIN_VALUE ){ |
| 981 | + |
| 982 | + Rectangle rect = shell.getBounds(); |
| 983 | + |
| 984 | + rect.x = max_x + 16; |
| 985 | + rect.y = max_y + 16; |
| 986 | + |
| 987 | + try{ |
| 988 | + Utils.setShellMetricsConfigEnabled( shell, false ); |
| 989 | + |
| 990 | + shell.setBounds( rect ); |
| 991 | + |
| 992 | + }finally{ |
| 993 | + |
| 994 | + Utils.setShellMetricsConfigEnabled( shell, true ); |
| 995 | + } |
| 996 | + } |
| 997 | + } |
| 998 | + |
| 999 | + Utils.verifyShellRect( shell, true ); |
924 | 1000 | }
|
925 | 1001 |
|
926 | 1002 | public void
|
|
0 commit comments