< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java

Print this page




 267                 }
 268             });
 269         } finally {
 270             awtUnlock();
 271         }
 272         PrivilegedAction<Void> a = () -> {
 273             Runnable r = () -> {
 274                 XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
 275                 if (peer != null) {
 276                     peer.dispose();
 277                 }
 278                 if (xs != null) {
 279                     ((XAWTXSettings)xs).dispose();
 280                 }
 281                 freeXKB();
 282                 if (log.isLoggable(PlatformLogger.Level.FINE)) {
 283                     dumpPeers();
 284                 }
 285             };
 286             String name = "XToolkt-Shutdown-Thread";
 287             Thread shutdownThread = new ManagedLocalsThread(
 288                     ThreadGroupUtils.getRootThreadGroup(), r, name);
 289             shutdownThread.setContextClassLoader(null);
 290             Runtime.getRuntime().addShutdownHook(shutdownThread);
 291             return null;
 292         };
 293         AccessController.doPrivileged(a);
 294     }
 295 
 296     static String getCorrectXIDString(String val) {
 297         if (val != null) {
 298             return val.replace('.', '-');
 299         } else {
 300             return val;
 301         }
 302     }
 303 
 304     static native String getEnv(String key);
 305 
 306 
 307     static String getAWTAppClassName() {
 308         return awtAppClassName;


 315         }
 316 
 317         if (!GraphicsEnvironment.isHeadless()) {
 318             String mainClassName = null;
 319 
 320             StackTraceElement trace[] = (new Throwable()).getStackTrace();
 321             int bottom = trace.length - 1;
 322             if (bottom >= 0) {
 323                 mainClassName = trace[bottom].getClassName();
 324             }
 325             if (mainClassName == null || mainClassName.equals("")) {
 326                 mainClassName = "AWT";
 327             }
 328             awtAppClassName = getCorrectXIDString(mainClassName);
 329 
 330             init();
 331             XWM.init();
 332 
 333             toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
 334                 String name = "AWT-XAWT";
 335                 Thread thread = new ManagedLocalsThread(
 336                         ThreadGroupUtils.getRootThreadGroup(), this, name);

 337                 thread.setContextClassLoader(null);
 338                 thread.setPriority(Thread.NORM_PRIORITY + 1);
 339                 thread.setDaemon(true);
 340                 return thread;
 341             });
 342             toolkitThread.start();
 343         }
 344     }
 345 
 346     @Override
 347     public ButtonPeer createButton(Button target) {
 348         ButtonPeer peer = new XButtonPeer(target);
 349         targetCreatedPeer(target, peer);
 350         return peer;
 351     }
 352 
 353     @Override
 354     public FramePeer createLightweightFrame(LightweightFrame target) {
 355         FramePeer peer = new XLightweightFramePeer(target);
 356         targetCreatedPeer(target, peer);




 267                 }
 268             });
 269         } finally {
 270             awtUnlock();
 271         }
 272         PrivilegedAction<Void> a = () -> {
 273             Runnable r = () -> {
 274                 XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
 275                 if (peer != null) {
 276                     peer.dispose();
 277                 }
 278                 if (xs != null) {
 279                     ((XAWTXSettings)xs).dispose();
 280                 }
 281                 freeXKB();
 282                 if (log.isLoggable(PlatformLogger.Level.FINE)) {
 283                     dumpPeers();
 284                 }
 285             };
 286             String name = "XToolkt-Shutdown-Thread";
 287             Thread shutdownThread = new Thread(
 288                     ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
 289             shutdownThread.setContextClassLoader(null);
 290             Runtime.getRuntime().addShutdownHook(shutdownThread);
 291             return null;
 292         };
 293         AccessController.doPrivileged(a);
 294     }
 295 
 296     static String getCorrectXIDString(String val) {
 297         if (val != null) {
 298             return val.replace('.', '-');
 299         } else {
 300             return val;
 301         }
 302     }
 303 
 304     static native String getEnv(String key);
 305 
 306 
 307     static String getAWTAppClassName() {
 308         return awtAppClassName;


 315         }
 316 
 317         if (!GraphicsEnvironment.isHeadless()) {
 318             String mainClassName = null;
 319 
 320             StackTraceElement trace[] = (new Throwable()).getStackTrace();
 321             int bottom = trace.length - 1;
 322             if (bottom >= 0) {
 323                 mainClassName = trace[bottom].getClassName();
 324             }
 325             if (mainClassName == null || mainClassName.equals("")) {
 326                 mainClassName = "AWT";
 327             }
 328             awtAppClassName = getCorrectXIDString(mainClassName);
 329 
 330             init();
 331             XWM.init();
 332 
 333             toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
 334                 String name = "AWT-XAWT";
 335                 Thread thread = new Thread(
 336                         ThreadGroupUtils.getRootThreadGroup(), this, name,
 337                         0, false);
 338                 thread.setContextClassLoader(null);
 339                 thread.setPriority(Thread.NORM_PRIORITY + 1);
 340                 thread.setDaemon(true);
 341                 return thread;
 342             });
 343             toolkitThread.start();
 344         }
 345     }
 346 
 347     @Override
 348     public ButtonPeer createButton(Button target) {
 349         ButtonPeer peer = new XButtonPeer(target);
 350         targetCreatedPeer(target, peer);
 351         return peer;
 352     }
 353 
 354     @Override
 355     public FramePeer createLightweightFrame(LightweightFrame target) {
 356         FramePeer peer = new XLightweightFramePeer(target);
 357         targetCreatedPeer(target, peer);


< prev index next >