final List output = Compiz.run(
"dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.get"
);
if ( output == null || output.size() < 2 )
throw new LWJGLException("Invalid Dbus reply.");
String line = (String)output.get(0);
if ( !line.startsWith("method return") )
throw new LWJGLException("Invalid Dbus reply.");
line = ((String)output.get(1)).trim(); // value
if ( !line.startsWith("boolean") || line.length() < 12)
throw new LWJGLException("Invalid Dbus reply.");
return "true".equalsIgnoreCase(line.substring("boolean".length() + 1));
}
public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException {
if ( Compiz.run(
"dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", KEY, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(state)
) == null )
throw new LWJGLException("Failed to apply Compiz LFS workaround.");
}
};
} else {
try {
// Check if Gconf is available
Runtime.getRuntime().exec("gconftool");
providerName = "gconftool";
provider = new Provider() {
private static final String KEY = "/apps/compiz/plugins/workarounds/allscreens/options/legacy_fullscreen";
public boolean hasLegacyFullscreenSupport() throws LWJGLException {
final List output = Compiz.run(new String[] {
"gconftool", "-g", KEY
});
if ( output == null || output.size() == 0 )
throw new LWJGLException("Invalid gconftool reply.");
return Boolean.parseBoolean(((String)output.get(0)).trim());
}
public void setLegacyFullscreenSupport(final boolean state) throws LWJGLException {
if ( Compiz.run(new String[] {
"gconftool", "-s", KEY, "-s", Boolean.toString(state), "-t", "bool"
}) == null )
throw new LWJGLException("Failed to apply Compiz LFS workaround.");
if ( state ) {
try {
// gconftool will not apply the workaround immediately, sleep a bit
// to make sure it will be ok when we create the window.