@@ -386,6 +386,8 @@ public class Display extends Device {
386
386
387
387
DesktopItem [] desktopItems ;
388
388
389
+ static String bodyOverflow , htmlOverflow ;
390
+
389
391
static int AUTO_HIDE_DELAY = 2000 ;
390
392
391
393
/* Private SWT Window Messages */
@@ -404,6 +406,7 @@ public class Display extends Device {
404
406
405
407
/* Package Name */
406
408
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets." ; //$NON-NLS-1$
409
+ private RunnableCompatibility mouseMoveListener ;
407
410
/*
408
411
* This code is intentionally commented. In order
409
412
* to support CLDC, .class cannot be used because
@@ -941,6 +944,14 @@ protected void destroy () {
941
944
void destroyDisplay () {
942
945
}
943
946
947
+ public void dispose () {
948
+ Shell [] shells = getShells ();
949
+ if (shells == null || shells .length == 0 ) {
950
+ super .dispose ();
951
+ }
952
+ //super.dispose();
953
+ }
954
+
944
955
/**
945
956
* Causes the <code>run()</code> method of the runnable to
946
957
* be invoked by the user-interface thread just before the
@@ -1767,6 +1778,10 @@ Shell getModalDialogShell () {
1767
1778
Monitor monitor = new Monitor ();
1768
1779
monitor .handle = document .body ;
1769
1780
monitor .clientWidth = document .body .clientWidth ;
1781
+ int parentWidth = OS .getContainerWidth (document .body .parentNode );
1782
+ if (parentWidth > monitor .clientWidth ) {
1783
+ monitor .clientWidth = parentWidth ;
1784
+ }
1770
1785
monitor .width = window .screen .availWidth ;
1771
1786
monitor .clientHeight = OS .getFixedBodyClientHeight (); //document.body.clientHeight;
1772
1787
monitor .height = window .screen .availHeight ;
@@ -2261,13 +2276,20 @@ public Tray getSystemTray () {
2261
2276
if (tray != null ) return tray ;
2262
2277
for (int i = 0 ; i < Displays .length ; i ++) {
2263
2278
Display disp = Displays [i ];
2264
- if (disp != null ) {
2265
- if (disp .tray != null ) {
2266
- return disp .tray ;
2279
+ if (disp != null && disp .tray != null && !disp .tray .isDisposed ()) {
2280
+ tray = disp .tray ;
2281
+ if (disp .trayCorner != null ) {
2282
+ disp .trayCorner .tray = tray ;
2267
2283
}
2284
+ return tray ;
2268
2285
}
2269
2286
}
2270
- return tray = new Tray (this , SWT .NONE );
2287
+ tray = new Tray (this , SWT .NONE );
2288
+ if (trayCorner != null ) {
2289
+ trayCorner .tray = tray ;
2290
+ trayCorner .initialize ();
2291
+ }
2292
+ return tray ;
2271
2293
}
2272
2294
2273
2295
/**
@@ -2445,7 +2467,8 @@ protected void init () {
2445
2467
void initializeDekstop () {
2446
2468
for (int i = 0 ; i < Displays .length ; i ++) {
2447
2469
Display disp = Displays [i ];
2448
- if (disp != this && disp != null && !disp .isDisposed ()) {
2470
+ if (disp != this && disp != null && !disp .isDisposed ()
2471
+ && disp .taskBar != null && disp .topBar != null ) {
2449
2472
taskBar = disp .taskBar ;
2450
2473
topBar = disp .topBar ;
2451
2474
shortcutBar = disp .shortcutBar ;
@@ -2454,22 +2477,33 @@ void initializeDekstop() {
2454
2477
return ;
2455
2478
}
2456
2479
}
2457
-
2458
2480
if (desktopItems != null ) return ;
2459
2481
2482
+ taskBar = new TaskBar (this );
2483
+ topBar = new MaximizedTitle (this );
2484
+ if (QuickLaunch .defaultQuickLaunch != null ) {
2485
+ shortcutBar = QuickLaunch .defaultQuickLaunch ;
2486
+ } else {
2487
+ shortcutBar = new QuickLaunch (this );
2488
+ }
2489
+ if (NotificationCorner .defaultNotificationCorner != null ) {
2490
+ trayCorner = NotificationCorner .defaultNotificationCorner ;
2491
+ } else {
2492
+ trayCorner = new NotificationCorner (this );
2493
+ }
2494
+
2460
2495
desktopItems = new DesktopItem [] {
2461
- taskBar = new TaskBar ( this ) ,
2462
- topBar = new MaximizedTitle ( this ) ,
2463
- shortcutBar = new QuickLaunch ( this ) ,
2464
- trayCorner = new NotificationCorner ( this )
2496
+ taskBar ,
2497
+ topBar ,
2498
+ shortcutBar ,
2499
+ trayCorner
2465
2500
};
2466
2501
for (int i = 0 ; i < desktopItems .length ; i ++) {
2467
2502
desktopItems [i ].initialize ();
2468
2503
}
2469
2504
2470
- RunnableCompatibility listener = new RunnableCompatibility (){
2505
+ mouseMoveListener = new RunnableCompatibility (){
2471
2506
2472
- @ Override
2473
2507
public void run () {
2474
2508
HTMLEvent e = (HTMLEvent ) getEvent ();
2475
2509
for (int i = 0 ; i < desktopItems .length ; i ++) {
@@ -2483,15 +2517,14 @@ public void run() {
2483
2517
}
2484
2518
2485
2519
};
2486
-
2487
2520
/**
2488
2521
* @j2sNative
2489
2522
if (document.addEventListener) {
2490
- document.addEventListener ("mousemove", listener , false);
2523
+ document.addEventListener ("mousemove", this.mouseMoveListener , false);
2491
2524
} else if (document.attachEvent) {
2492
- document.attachEvent ("onmousemove", listener );
2525
+ document.attachEvent ("onmousemove", this.mouseMoveListener );
2493
2526
}
2494
- */ { listener .run (); }
2527
+ */ { mouseMoveListener .run (); }
2495
2528
2496
2529
}
2497
2530
@@ -3333,7 +3366,16 @@ protected void release () {
3333
3366
Shell shell = shells [i ];
3334
3367
if (!shell .isDisposed ()) shell .dispose ();
3335
3368
}
3336
- if (tray != null ) tray .dispose ();
3369
+ int trayRefs = 1 ;
3370
+ for (int i = 0 ; i < Displays .length ; i ++) {
3371
+ Display disp = Displays [i ];
3372
+ if (disp != this && disp != null && !disp .isDisposed ()) {
3373
+ if (disp .tray != null ) {
3374
+ trayRefs ++;
3375
+ }
3376
+ }
3377
+ }
3378
+ if (tray != null && trayRefs < 2 ) tray .dispose ();
3337
3379
tray = null ;
3338
3380
/*
3339
3381
* Don't loop this "while"!
@@ -3363,6 +3405,24 @@ protected void release () {
3363
3405
releaseDesktop ();
3364
3406
releaseDisplay ();
3365
3407
super .release ();
3408
+
3409
+ if (NotificationCorner .defaultNotificationCorner != null ) {
3410
+ new Display ().getSystemTray ();
3411
+ NotificationCorner corner = NotificationCorner .defaultNotificationCorner ;
3412
+ document .body .removeChild (corner .handle );
3413
+ document .body .appendChild (corner .handle );
3414
+ }
3415
+ if (NotificationCorner .defaultNotificationCorner == null
3416
+ && QuickLaunch .defaultQuickLaunch == null ) {
3417
+ if (htmlOverflow != null ) {
3418
+ document .body .parentNode .style .overflow = htmlOverflow ;
3419
+ htmlOverflow = null ;
3420
+ }
3421
+ if (bodyOverflow != null ) {
3422
+ document .body .style .overflow = bodyOverflow ;
3423
+ bodyOverflow = null ;
3424
+ }
3425
+ }
3366
3426
}
3367
3427
3368
3428
void releaseDesktop () {
@@ -3375,17 +3435,51 @@ void releaseDesktop () {
3375
3435
}
3376
3436
}
3377
3437
if (existed ) {
3438
+ existed = false ;
3439
+ for (int i = 0 ; i < Displays .length ; i ++) {
3440
+ Display disp = Displays [i ];
3441
+ if (disp != this && disp != null && !disp .isDisposed ()
3442
+ && disp .tray != null && !disp .tray .isDisposed ()) {
3443
+ existed = true ;
3444
+ break ;
3445
+ }
3446
+ }
3447
+ if (!existed && trayCorner .handle != null ) {
3448
+ trayCorner .handle .style .display = "none" ;
3449
+ }
3378
3450
return ;
3379
3451
}
3380
3452
3453
+ int trayRefs = 1 ;
3454
+ for (int i = 0 ; i < Displays .length ; i ++) {
3455
+ Display disp = Displays [i ];
3456
+ if (disp != this && disp != null && !disp .isDisposed ()) {
3457
+ if (disp .tray != null ) {
3458
+ trayRefs ++;
3459
+ }
3460
+ }
3461
+ }
3462
+
3381
3463
for (int i = 0 ; i < desktopItems .length ; i ++) {
3464
+ if (trayRefs > 1 && desktopItems [i ] == trayCorner ) {
3465
+ continue ;
3466
+ }
3382
3467
desktopItems [i ].releaseWidget ();
3383
3468
}
3384
3469
desktopItems = null ;
3385
3470
trayCorner = null ;
3386
3471
taskBar = null ;
3387
3472
shortcutBar = null ;
3388
3473
topBar = null ;
3474
+
3475
+ /**
3476
+ * @j2sNative
3477
+ if (document.removeEventListener) {
3478
+ document.removeEventListener ("mousemove", this.mouseMoveListener, false);
3479
+ } else if (document.detachEvent) {
3480
+ document.detachEvent ("onmousemove", this.mouseMoveListener);
3481
+ }
3482
+ */ { mouseMoveListener .run (); }
3389
3483
}
3390
3484
3391
3485
void releaseDisplay () {
@@ -3655,14 +3749,21 @@ void removeBar (Menu menu) {
3655
3749
Control removeControl (Object handle ) {
3656
3750
if (handle == null ) return null ;
3657
3751
Control control = null ;
3658
- int index = 0 ;
3752
+ int index = - 1 ;
3659
3753
/*
3660
3754
if (USE_PROPERTY) {
3661
3755
index = OS.RemoveProp (handle, SWT_OBJECT_INDEX) - 1;
3662
3756
} else {
3663
3757
index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
3664
3758
}
3665
3759
*/
3760
+ for (int i = 0 ; i < controlTable .length ; i ++) {
3761
+ Control ctrl = controlTable [i ];
3762
+ if (ctrl != null && ctrl .handle == handle ) {
3763
+ index = i ;
3764
+ break ;
3765
+ }
3766
+ }
3666
3767
if (0 <= index && index < controlTable .length ) {
3667
3768
control = controlTable [index ];
3668
3769
controlTable [index ] = null ;
@@ -4393,14 +4494,12 @@ static Tray getTray() {
4393
4494
if (Default != null ) {
4394
4495
tray = Default .tray ;
4395
4496
}
4396
- if (tray != null ) {
4497
+ if (tray == null || tray . isDisposed () ) {
4397
4498
for (int i = 0 ; i < Displays .length ; i ++){
4398
4499
Display disp = Displays [i ];
4399
- if (disp != null ) {
4400
- if (disp .tray != null ){
4401
- tray = disp .tray ;
4402
- break ;
4403
- }
4500
+ if (disp != null && disp .tray != null && !disp .tray .isDisposed ()){
4501
+ tray = disp .tray ;
4502
+ break ;
4404
4503
}
4405
4504
}
4406
4505
}
0 commit comments