< prev index next >

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

Print this page




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.X11;
  26 
  27 import java.awt.MenuItem;
  28 import java.awt.PopupMenu;
  29 import java.awt.Taskbar.Feature;
  30 import java.awt.peer.TaskbarPeer;
  31 import java.awt.event.ActionEvent;
  32 import sun.misc.ManagedLocalsThread;
  33 import java.security.AccessController;
  34 import sun.security.action.GetPropertyAction;
  35 
  36 final class XTaskbarPeer implements TaskbarPeer {
  37 
  38     private static boolean nativeLibraryLoaded = false;
  39     private static boolean initExecuted = false;
  40 
  41     private PopupMenu menu = null;
  42 
  43     private static void initWithLock() {
  44         XToolkit.awtLock();
  45         try {
  46             if (!initExecuted) {
  47                 String dname = AccessController.doPrivileged(
  48                                 new GetPropertyAction("java.desktop.appName", ""));
  49                 nativeLibraryLoaded = init(dname);
  50                 if (nativeLibraryLoaded) {
  51                     ManagedLocalsThread t
  52                             = new ManagedLocalsThread(() -> {
  53                                 runloop();
  54                             });
  55                     t.setDaemon(true);
  56                     t.start();
  57                 }
  58             }
  59         } finally {
  60             initExecuted = true;
  61             XToolkit.awtUnlock();
  62         }
  63     }
  64 
  65     XTaskbarPeer() {
  66         initWithLock();
  67     }
  68 
  69     static boolean isTaskbarSupported() {
  70         initWithLock();
  71         return nativeLibraryLoaded;
  72     }
  73 
  74     @Override




  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.X11;
  26 
  27 import java.awt.MenuItem;
  28 import java.awt.PopupMenu;
  29 import java.awt.Taskbar.Feature;
  30 import java.awt.peer.TaskbarPeer;
  31 import java.awt.event.ActionEvent;

  32 import java.security.AccessController;
  33 import sun.security.action.GetPropertyAction;
  34 
  35 final class XTaskbarPeer implements TaskbarPeer {
  36 
  37     private static boolean nativeLibraryLoaded = false;
  38     private static boolean initExecuted = false;
  39 
  40     private PopupMenu menu = null;
  41 
  42     private static void initWithLock() {
  43         XToolkit.awtLock();
  44         try {
  45             if (!initExecuted) {
  46                 String dname = AccessController.doPrivileged(
  47                                 new GetPropertyAction("java.desktop.appName", ""));
  48                 nativeLibraryLoaded = init(dname);
  49                 if (nativeLibraryLoaded) {
  50                     Thread t = new Thread(null, () -> { runloop(); },
  51                                           "TaskBar", 0, false);


  52                     t.setDaemon(true);
  53                     t.start();
  54                 }
  55             }
  56         } finally {
  57             initExecuted = true;
  58             XToolkit.awtUnlock();
  59         }
  60     }
  61 
  62     XTaskbarPeer() {
  63         initWithLock();
  64     }
  65 
  66     static boolean isTaskbarSupported() {
  67         initWithLock();
  68         return nativeLibraryLoaded;
  69     }
  70 
  71     @Override


< prev index next >