Added support for Compiz's legacy fullscreen workaround.

This commit is contained in:
Ioannis Tsakpinis 2010-07-07 12:37:40 +00:00
parent 840f05dbf5
commit eebd82198c
3 changed files with 136 additions and 8 deletions

View File

@ -39,6 +39,9 @@ package org.lwjgl.opengl;
*/
import java.awt.Canvas;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
@ -410,6 +413,10 @@ final class LinuxDisplay implements DisplayImplementation {
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(Display.isFullscreen());
// Try to enable Lecagy FullScreen Support in Compiz, else
// we may have trouble with stuff overlapping our fullscreen window.
if ( current_window_mode != WINDOWED )
Compiz.setLegacyFullscreenSupport(true);
// Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
// managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
// unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
@ -490,6 +497,9 @@ final class LinuxDisplay implements DisplayImplementation {
ungrabKeyboard();
nDestroyWindow(getDisplay(), getWindow());
decDisplay();
if ( current_window_mode != WINDOWED )
Compiz.setLegacyFullscreenSupport(false);
} finally {
unlockAWT();
}
@ -544,6 +554,8 @@ final class LinuxDisplay implements DisplayImplementation {
}
if (isXF86VidModeSupported())
doSetGamma(saved_gamma);
Compiz.setLegacyFullscreenSupport(false);
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while resetting mode: " + e);
} finally {
@ -618,6 +630,8 @@ final class LinuxDisplay implements DisplayImplementation {
public DisplayMode init() throws LWJGLException {
lockAWT();
try {
Compiz.init();
delete_atom = internAtom("WM_DELETE_WINDOW", false);
current_displaymode_extension = getBestDisplayModeExtension();
if (current_displaymode_extension == NONE)
@ -1233,4 +1247,96 @@ final class LinuxDisplay implements DisplayImplementation {
public boolean isInsideWindow() {
return true;
}
}
/**
* Helper class for managing Compiz's workarounds.
*/
private static final class Compiz {
private static final String LEGACY_FULLSCREEN_SUPPORT = "/org/freedesktop/compiz/workarounds/allscreens/legacy_fullscreen";
private static boolean dbusAvailable;
private static boolean legacyFullscreenSupport;
private Compiz() {
}
static void init() {
if ( Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.nocompiz_lfs") )
return;
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
legacyFullscreenSupport = getBoolean(LEGACY_FULLSCREEN_SUPPORT);
dbusAvailable = true;
} catch (LWJGLException e) {
LWJGLUtil.log("Compiz Dbus communication failed. Reason: " + e.getMessage());
}
return null;
}
});
}
static void setLegacyFullscreenSupport(final boolean enabled) {
if ( !dbusAvailable || legacyFullscreenSupport )
return;
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
setBoolean(LEGACY_FULLSCREEN_SUPPORT, enabled);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to change Compiz Legacy Fullscreen Support. Reason: " + e.getMessage());
}
return null;
}
});
}
private static boolean getBoolean(final String option) throws LWJGLException {
try {
final Process p = Runtime.getRuntime().exec(new String[] {
"dbus-send", "--print-reply", "--type=method_call", "--dest=org.freedesktop.compiz", option, "org.freedesktop.compiz.get"
});
final int exitValue = p.waitFor();
if ( exitValue != 0 )
throw new LWJGLException("Dbus error.");
final BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String reply = br.readLine(); // header
if ( !reply.startsWith("method return") )
throw new LWJGLException("Invalid Dbus reply.");
reply = br.readLine().trim(); // value
if ( !reply.startsWith("boolean") )
throw new LWJGLException("Invalid Dbus reply.");
return "true".equalsIgnoreCase(reply.substring("boolean".length() + 1));
} catch (IOException e) {
throw new LWJGLException("Dbus command failed.", e);
} catch (InterruptedException e) {
throw new LWJGLException("Dbus command failed.", e);
}
}
private static void setBoolean(final String option, final boolean value) throws LWJGLException {
try {
final Process p = Runtime.getRuntime().exec(new String[] {
"dbus-send", "--type=method_call", "--dest=org.freedesktop.compiz", option, "org.freedesktop.compiz.set", "boolean:" + Boolean.toString(value)
});
final int exitValue = p.waitFor();
if ( exitValue != 0 )
throw new LWJGLException("Dbus error.");
} catch (IOException e) {
throw new LWJGLException("Dbus command failed.", e);
} catch (InterruptedException e) {
throw new LWJGLException("Dbus command failed.", e);
}
}
}
}

View File

@ -219,7 +219,7 @@ public class XRandR
* the list to add the Screen to if it's valid
* @param name
* the name of this screen
* @param conf
* @param what
* config string, format either widthxheight or
* widthxheight+xPos+yPos
*/
@ -231,7 +231,7 @@ public class XRandR
m = SCREEN_PATTERN2.matcher( what );
if( !m.matches() )
{
System.out.println( "Did not match: " + what );
LWJGLUtil.log( "Did not match: " + what );
return;
}
}

View File

@ -519,11 +519,11 @@ public interface EXT_direct_state_access {
value parameters
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glEnableClientStateiEXT(@GLenum int array, @GLuint int index);
@Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glDisableClientStateiEXT(@GLenum int array, @GLuint int index);
@ -565,7 +565,7 @@ public interface EXT_direct_state_access {
and before state value parameters
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix("params")
void glGetFloati_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") FloatBuffer params);
@ -576,7 +576,7 @@ public interface EXT_direct_state_access {
@StripPostfix("params")
void glGetFloati_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter FloatBuffer params);
@Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix("params")
void glGetDoublei_vEXT(@GLenum int pname, @GLuint int index, @OutParameter @Check("16") DoubleBuffer params);
@ -587,7 +587,7 @@ public interface EXT_direct_state_access {
@StripPostfix("params")
void glGetDoublei_vEXT2(@GLenum int pname, @GLuint int index, @OutParameter DoubleBuffer params);
@Optional(reason = "AMD does not expose this (last driver checked: 10.3)")
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix(value = "params", hasPostfix = false)
void glGetPointeri_vEXT(@GLenum int pname, @GLuint int index, @Result @GLvoid ByteBuffer params);
@ -1343,6 +1343,7 @@ public interface EXT_direct_state_access {
OpenGL 3.1: New buffer data copy command
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL31,GL_ARB_copy_buffer")
void glNamedCopyBufferSubDataEXT(@GLuint int readBuffer, @GLuint int writeBuffer, @GLintptr long readoffset, @GLintptr long writeoffset, @GLsizeiptr long size);
@ -1386,44 +1387,55 @@ public interface EXT_direct_state_access {
and change the final parameter from "const void *" to "intptr offset"
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayVertexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayEdgeFlagOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glVertexArrayIndexOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayNormalOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayMultiTexCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int texunit, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArrayFogCoordOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@DeprecatedGL
void glVertexArraySecondaryColorOffsetEXT(@GLuint int vaobj, @GLuint int buffer, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glVertexArrayVertexAttribOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, boolean normalized, @GLsizei int stride, @GLintptr long offset);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glVertexArrayVertexAttribIOffsetEXT(@GLuint int vaobj, @GLuint int buffer, @GLuint int index, int size, @GLenum int type, @GLsizei int stride, @GLintptr long offset);
@ -1433,9 +1445,11 @@ public interface EXT_direct_state_access {
"uint vaobj" parameter
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glEnableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glDisableVertexArrayEXT(@GLuint int vaobj, @GLenum int array);
@ -1445,9 +1459,11 @@ public interface EXT_direct_state_access {
and add an initial "uint vaobj" parameter
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glEnableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glDisableVertexArrayAttribEXT(@GLuint int vaobj, @GLuint int index);
@ -1455,6 +1471,7 @@ public interface EXT_direct_state_access {
OpenGL 3.0: New queries for vertex array objects
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix("param")
void glGetVertexArrayIntegervEXT(@GLuint int vaobj, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
@ -1465,10 +1482,12 @@ public interface EXT_direct_state_access {
@StripPostfix("param")
void glGetVertexArrayIntegervEXT2(@GLuint int vaobj, @GLenum int pname, @OutParameter IntBuffer param);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix("param")
void glGetVertexArrayPointervEXT(@GLuint int vaobj, @GLenum int pname, @Result @GLvoid ByteBuffer param);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix(value = "param")
void glGetVertexArrayIntegeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter @Check("16") IntBuffer param);
@ -1479,6 +1498,7 @@ public interface EXT_direct_state_access {
@StripPostfix(value = "param", postfix = "_v")
void glGetVertexArrayIntegeri_vEXT2(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @OutParameter IntBuffer param);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@StripPostfix(value = "param")
void glGetVertexArrayPointeri_vEXT(@GLuint int vaobj, @GLuint int index, @GLenum int pname, @Result @GLvoid ByteBuffer param);
@ -1502,12 +1522,14 @@ public interface EXT_direct_state_access {
*
* @return A ByteBuffer representing the mapped buffer memory.
*/
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
@CachedResult(isRange = true)
@GLvoid
@AutoResultSize("length")
ByteBuffer glMapNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length, @GLbitfield int access);
@Optional(reason = "AMD does not expose this (last driver checked: 10.5)")
@Dependent("OpenGL30")
void glFlushMappedNamedBufferRangeEXT(@GLuint int buffer, @GLintptr long offset, @GLsizeiptr long length);