]> source.dussan.org Git - tigervnc.git/commitdiff
Set the dock icon on OS X. Not perfect as it still shows the standard Java logo...
authorBrian Hinz <bphinz@users.sourceforge.net>
Sat, 4 Jan 2014 17:28:20 +0000 (17:28 +0000)
committerBrian Hinz <bphinz@users.sourceforge.net>
Sat, 4 Jan 2014 17:28:20 +0000 (17:28 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@5151 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/com/tigervnc/vncviewer/Viewport.java

index a6ce355479f4d500790f6c355b01aa2cb98c2218..e7d76a54d321a0596433168331ec4c36313d108a 100644 (file)
@@ -27,6 +27,7 @@ import java.awt.Event;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
 import java.awt.GraphicsEnvironment;
+import java.awt.Image;
 import java.awt.Window;
 import java.lang.reflect.*;
 import javax.swing.*;
@@ -41,7 +42,23 @@ public class Viewport extends JFrame
     setTitle(name+" - TigerVNC");
     setFocusable(false);
     setFocusTraversalKeysEnabled(false);
-    setIconImage(VncViewer.frameIcon);
+    if (VncViewer.os.startsWith("mac os x")) {
+      try {
+        Class appClass = Class.forName("com.apple.eawt.Application");
+        Method getApplication = 
+          appClass.getMethod("getApplication", (Class[])null);
+        Object app = getApplication.invoke(appClass);
+        Class paramTypes[] = new Class[1];
+        paramTypes[0] = Image.class;
+        Method setDockIconImage = 
+          appClass.getMethod("setDockIconImage", paramTypes);
+        setDockIconImage.invoke(app, VncViewer.logoImage);
+      } catch (Exception e) {
+        vlog.debug("Could not set OS X dock icon: " + e.getMessage());
+      }
+    } else {
+      setIconImage(VncViewer.frameIcon);
+    }
     UIManager.getDefaults().put("ScrollPane.ancestorInputMap",
       new UIDefaults.LazyInputMap(new Object[]{}));
     sp = new JScrollPane();
@@ -133,7 +150,6 @@ public class Viewport extends JFrame
     } catch (Exception e) {
       vlog.debug("Could not enable OS X 10.7+ full-screen mode: " +
                  e.getMessage());
-      
     }
   }