jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
changeset 17679 a81555868357
parent 16839 d0f2e97b7359
child 18178 ee71c923891d
equal deleted inserted replaced
17678:ec24ad8455ec 17679:a81555868357
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   126             }
   126             }
   127             setupModifierMap();
   127             setupModifierMap();
   128             initIDs();
   128             initIDs();
   129             setBackingStoreType();
   129             setBackingStoreType();
   130         }
   130         }
   131         noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
       
   132     }
   131     }
   133 
   132 
   134     /*
   133     /*
   135      * Return (potentially) platform specific display timeout for the
   134      * Return (potentially) platform specific display timeout for the
   136      * tray icon
   135      * tray icon
   137      */
   136      */
   138     static native long getTrayIconDisplayTimeout();
   137     static native long getTrayIconDisplayTimeout();
   139 
       
   140     //---- ERROR HANDLER CODE ----//
       
   141 
       
   142     /*
       
   143      * Error handler at the moment of XToolkit initialization
       
   144      */
       
   145     private static long saved_error_handler;
       
   146 
       
   147     /*
       
   148      * XErrorEvent being handled
       
   149      */
       
   150     static volatile XErrorEvent saved_error;
       
   151 
       
   152     /*
       
   153      * Current error handler or null if no error handler is set
       
   154      */
       
   155     private static XErrorHandler current_error_handler;
       
   156 
       
   157     /*
       
   158      * Value of sun.awt.noisyerrorhandler system property
       
   159      */
       
   160     private static boolean noisyAwtHandler;
       
   161 
       
   162     public static void WITH_XERROR_HANDLER(XErrorHandler handler) {
       
   163         saved_error = null;
       
   164         current_error_handler = handler;
       
   165     }
       
   166 
       
   167     public static void RESTORE_XERROR_HANDLER() {
       
   168         // wait until all requests are processed by the X server
       
   169         // and only then uninstall the error handler
       
   170         XSync();
       
   171         current_error_handler = null;
       
   172     }
       
   173 
       
   174     // Should be called under LOCK
       
   175     public static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
       
   176         if (saved_error_handler != 0) {
       
   177             // Default XErrorHandler may just terminate the process. Don't call it.
       
   178             // return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
       
   179         }
       
   180         if (log.isLoggable(PlatformLogger.FINE)) {
       
   181             log.fine("Unhandled XErrorEvent: " +
       
   182                      "id=" + error.get_resourceid() + ", " +
       
   183                      "serial=" + error.get_serial() + ", " +
       
   184                      "ec=" + error.get_error_code() + ", " +
       
   185                      "rc=" + error.get_request_code() + ", " +
       
   186                      "mc=" + error.get_minor_code());
       
   187         }
       
   188         return 0;
       
   189     }
       
   190 
       
   191     // Called from the native code when an error occurs
       
   192     private static int globalErrorHandler(long display, long event_ptr) {
       
   193         if (noisyAwtHandler) {
       
   194             XlibWrapper.PrintXErrorEvent(display, event_ptr);
       
   195         }
       
   196         XErrorEvent event = new XErrorEvent(event_ptr);
       
   197         saved_error = event;
       
   198         try {
       
   199             if (current_error_handler != null) {
       
   200                 return current_error_handler.handleError(display, event);
       
   201             } else {
       
   202                 return SAVED_ERROR_HANDLER(display, event);
       
   203             }
       
   204         } catch (Throwable z) {
       
   205             log.fine("Error in GlobalErrorHandler", z);
       
   206         }
       
   207         return 0;
       
   208     }
       
   209 
       
   210     //---- END OF ERROR HANDLER CODE ----//
       
   211 
   138 
   212     private native static void initIDs();
   139     private native static void initIDs();
   213     native static void waitForEvents(long nextTaskTime);
   140     native static void waitForEvents(long nextTaskTime);
   214     static Thread toolkitThread;
   141     static Thread toolkitThread;
   215     static boolean isToolkitThread() {
   142     static boolean isToolkitThread() {
   303             arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
   230             arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
   304                 XCursorFontConstants.XC_arrow);
   231                 XCursorFontConstants.XC_arrow);
   305             areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
   232             areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
   306             //set system property if not yet assigned
   233             //set system property if not yet assigned
   307             System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
   234             System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
   308 
       
   309             saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
       
   310 
   235 
   311             // Detect display mode changes
   236             // Detect display mode changes
   312             XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask);
   237             XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask);
   313             XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() {
   238             XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() {
   314                 @Override
   239                 @Override