< prev index next >

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

Print this page




  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 
  33 import sun.awt.UNIXToolkit;
  34 import java.security.AccessController;

  35 import sun.security.action.GetPropertyAction;
  36 
  37 final class XTaskbarPeer implements TaskbarPeer {
  38 
  39     private static boolean nativeLibraryLoaded = false;
  40     private static boolean initExecuted = false;
  41 
  42     private PopupMenu menu = null;








  43 
  44     private static void initWithLock() {
  45         XToolkit.awtLock();
  46         try {
  47             if (!initExecuted) {
  48                 String dname = AccessController.doPrivileged(
  49                                 new GetPropertyAction("java.desktop.appName", ""));
  50                 nativeLibraryLoaded = init(dname,
  51                         UNIXToolkit.getEnabledGtkVersion().ordinal(),
  52                         UNIXToolkit.isGtkVerbose());
  53                 if (nativeLibraryLoaded) {
  54                     Thread t = new Thread(null, () -> { runloop(); },
  55                                           "TaskBar", 0, false);
  56                     t.setDaemon(true);
  57                     t.start();
  58                 }
  59             }
  60         } finally {
  61             initExecuted = true;
  62             XToolkit.awtUnlock();
  63         }
  64     }
  65 
  66     XTaskbarPeer() {
  67         initWithLock();
  68     }
  69 
  70     static boolean isTaskbarSupported() {



  71         initWithLock();
  72         return nativeLibraryLoaded;
  73     }
  74 
  75     @Override
  76     public boolean isSupported(Feature feature) {
  77         switch (feature) {
  78             case ICON_BADGE_NUMBER:
  79             case MENU:
  80             case PROGRESS_VALUE:
  81             case USER_ATTENTION:
  82                 return true;
  83             default:
  84                 return false;
  85         }
  86     }
  87 
  88     @Override
  89     public void setProgressValue(int value) {
  90         boolean visible




  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 
  33 import sun.awt.UNIXToolkit;
  34 import java.security.AccessController;
  35 import java.security.PrivilegedAction;
  36 import sun.security.action.GetPropertyAction;
  37 
  38 final class XTaskbarPeer implements TaskbarPeer {
  39 
  40     private static boolean nativeLibraryLoaded = false;
  41     private static boolean initExecuted = false;
  42 
  43     private PopupMenu menu = null;
  44     private static boolean isUnity;
  45 
  46     static {
  47         String de = AccessController.doPrivileged(
  48                         (PrivilegedAction<String>) ()
  49                                 -> System.getenv("XDG_CURRENT_DESKTOP"));
  50         isUnity = de != null && de.equals("Unity");
  51     }
  52 
  53     private static void initWithLock() {
  54         XToolkit.awtLock();
  55         try {
  56             if (!initExecuted) {
  57                 String dname = AccessController.doPrivileged(
  58                                 new GetPropertyAction("java.desktop.appName", ""));
  59                 nativeLibraryLoaded = init(dname,
  60                         UNIXToolkit.getEnabledGtkVersion().ordinal(),
  61                         UNIXToolkit.isGtkVerbose());
  62                 if (nativeLibraryLoaded) {
  63                     Thread t = new Thread(null, () -> { runloop(); },
  64                                           "TaskBar", 0, false);
  65                     t.setDaemon(true);
  66                     t.start();
  67                 }
  68             }
  69         } finally {
  70             initExecuted = true;
  71             XToolkit.awtUnlock();
  72         }
  73     }
  74 
  75     XTaskbarPeer() {
  76         initWithLock();
  77     }
  78 
  79     static boolean isTaskbarSupported() {
  80         if (!isUnity) {
  81             return false;
  82         }
  83         initWithLock();
  84         return nativeLibraryLoaded;
  85     }
  86 
  87     @Override
  88     public boolean isSupported(Feature feature) {
  89         switch (feature) {
  90             case ICON_BADGE_NUMBER:
  91             case MENU:
  92             case PROGRESS_VALUE:
  93             case USER_ATTENTION:
  94                 return true;
  95             default:
  96                 return false;
  97         }
  98     }
  99 
 100     @Override
 101     public void setProgressValue(int value) {
 102         boolean visible


< prev index next >