summaryrefslogtreecommitdiffstats
path: root/depends
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-05-11 15:03:28 +0200
committerPetr Mrázek <peterix@gmail.com>2014-06-09 01:38:30 +0200
commitad1f2c530cc4f402d65d46f644a181e1126ddbf5 (patch)
tree28fec3fc316dee47f99691e538095ef08b27a9cf /depends
parent69c3e7111f93290d1278d6116e9fd50079b4fe79 (diff)
downloadMultiMC-ad1f2c530cc4f402d65d46f644a181e1126ddbf5.tar
MultiMC-ad1f2c530cc4f402d65d46f644a181e1126ddbf5.tar.gz
MultiMC-ad1f2c530cc4f402d65d46f644a181e1126ddbf5.tar.lz
MultiMC-ad1f2c530cc4f402d65d46f644a181e1126ddbf5.tar.xz
MultiMC-ad1f2c530cc4f402d65d46f644a181e1126ddbf5.zip
Use window icons and titles in 1.6+
Diffstat (limited to 'depends')
-rw-r--r--depends/launcher/org/multimc/onesix/OneSixLauncher.java92
1 files changed, 45 insertions, 47 deletions
diff --git a/depends/launcher/org/multimc/onesix/OneSixLauncher.java b/depends/launcher/org/multimc/onesix/OneSixLauncher.java
index 7bf71b3d..5bfe7e9a 100644
--- a/depends/launcher/org/multimc/onesix/OneSixLauncher.java
+++ b/depends/launcher/org/multimc/onesix/OneSixLauncher.java
@@ -218,6 +218,51 @@ public class OneSixLauncher implements Launcher
e.printStackTrace(System.err);
return -1;
}
+ final java.nio.ByteBuffer[] icons = IconLoader.load("icon.png");
+ new Thread() {
+ public void run() {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ try
+ {
+ Class<?> Display;
+ Method isCreated;
+ Method setTitle;
+ Method setIcon;
+ Field fieldWindowCreated;
+ Boolean created = false;
+ Display = cl.loadClass("org.lwjgl.opengl.Display");
+ fieldWindowCreated = Display.getDeclaredField("window_created");
+ fieldWindowCreated.setAccessible( true );
+ setTitle = Display.getMethod("setTitle", String.class);
+ setIcon = Display.getMethod("setIcon", java.nio.ByteBuffer[].class);
+ created = (Boolean) fieldWindowCreated.get( null );
+ // set the window title? Maybe?
+ while(!created)
+ {
+ try
+ {
+ Thread.sleep(150);
+ created = (Boolean) fieldWindowCreated.get( null );
+ } catch (InterruptedException ignored) {}
+ }
+ // Give it a bit more time ;)
+ Thread.sleep(150);
+ // set the title
+ setTitle.invoke(null,windowTitle);
+ // only set icon when there's actually something to set...
+ if(icons.length > 0)
+ {
+ setIcon.invoke(null,(Object)icons);
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println("Couldn't set window icon or title.");
+ e.printStackTrace(System.err);
+ }
+ }
+ }
+ .start();
// init params for the main method to chomp on.
String[] paramsArray = mcparams.toArray(new String[mcparams.size()]);
@@ -318,50 +363,3 @@ public class OneSixLauncher implements Launcher
}
}
}
-
-
-// FIXME: works only on linux, we need a better solution
-/*
- final java.nio.ByteBuffer[] icons = IconLoader.load("icon.png");
- new Thread() {
- public void run() {
- ClassLoader cl = ClassLoader.getSystemClassLoader();
- try
- {
- Class<?> Display;
- Method isCreated;
- Method setTitle;
- Method setIcon;
-
- Display = cl.loadClass("org.lwjgl.opengl.Display");
- isCreated = Display.getMethod("isCreated");
- setTitle = Display.getMethod("setTitle", String.class);
- setIcon = Display.getMethod("setIcon", java.nio.ByteBuffer[].class);
-
- // set the window title? Maybe?
- while(!(Boolean) isCreated.invoke(null))
- {
- try
- {
- Thread.sleep(150);
- } catch (InterruptedException ignored) {}
- }
- // Give it a bit more time ;)
- Thread.sleep(150);
- // set the title
- setTitle.invoke(null,windowTitle);
- // only set icon when there's actually something to set...
- if(icons.length > 0)
- {
- setIcon.invoke(null,(Object)icons);
- }
- }
- catch (Exception e)
- {
- System.err.println("Couldn't set window icon or title.");
- e.printStackTrace(System.err);
- }
- }
- }
- .start();
-*/ \ No newline at end of file