/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is an implementation of a GraphicsEnvironment object for the
* default local GraphicsEnvironment used by the Java Runtime Environment
* for X11 environments.
*
* @see GraphicsDevice
* @see GraphicsConfiguration
*/
public class X11GraphicsEnvironment
extends SunGraphicsEnvironment
{
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11GraphicsEnvironment");
private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.screen.X11GraphicsEnvironment");
static {
/*
* Note: The MToolkit object depends on the static initializer
* of X11GraphicsEnvironment to initialize the connection to
* the X11 server.
*/
if (!isHeadless()) {
// first check the OGL system property
boolean glxRequested = false;
glxRequested = true;
glxRequested = true;
glxVerbose = true;
}
}
// Now check for XRender system property
boolean xRenderRequested = false;
xRenderRequested = true;
xRenderRequested = true;
xRenderVerbose = true;
}
}
// initialize the X11 display connection
// only attempt to initialize GLX if it was requested
if (glxRequested) {
glxAvailable = initGLX();
if (glxVerbose && !glxAvailable) {
"Could not enable OpenGL " +
"pipeline (GLX 1.3 not available)");
}
}
// only attempt to initialize Xrender if it was requested
if (xRenderRequested) {
if (xRenderVerbose && !xRenderAvailable) {
"Could not enable XRender pipeline");
}
}
if (xRenderAvailable) {
}
}
return null;
}
});
// Install the correct surface manager factory.
}
private static boolean glxAvailable;
private static boolean glxVerbose;
private static native boolean initGLX();
public static boolean isGLXAvailable() {
return glxAvailable;
}
public static boolean isGLXVerbose() {
return glxVerbose;
}
private static boolean xRenderVerbose;
private static boolean xRenderAvailable;
public static boolean isXRenderAvailable() {
return xRenderAvailable;
}
public static boolean isXRenderVerbose() {
return xRenderVerbose;
}
/**
* Checks if Shared Memory extension can be used.
* Returns:
* -1 if server doesn't support MITShm
* 1 if server supports it and it can be used
* 0 otherwise
*/
private static native int checkShmExt();
/**
* This should only be called from the static initializer, so no need for
* the synchronized keyword.
*/
public X11GraphicsEnvironment() {
}
protected native int getNumScreens();
return new X11GraphicsDevice(screennum);
}
protected native int getDefaultScreenNum();
/**
* Returns the default screen graphics device.
*/
return getScreenDevices()[getDefaultScreenNum()];
}
public boolean isDisplayLocal() {
if (isDisplayLocal == null) {
try {
if (isDisplayLocal == null) {
}
} finally {
}
}
return isDisplayLocal.booleanValue();
}
private static boolean _isDisplayLocal() {
if (isHeadless()) {
return true;
}
}
int shm = checkShmExt();
if (shm != -1) {
return (shm == 1);
}
// If XServer doesn't support ShMem extension,
// try the other way
if (ind <= 0) {
// ':0' case
return true;
}
try {
}
} catch (UnknownHostException e) {
} catch (SocketException e1) {
}
for (; interfaces.hasMoreElements();) {
for (; locals.hasMoreElements();) {
}
}
}
}
}});
return result.booleanValue();
}
/**
* Returns face name for default font, or null if
* no face names are used for CompositeFontDescriptors
* for this platform.
*/
return null;
}
private static native boolean pRunningXinerama();
/**
* Override for Xinerama case: call new Solaris API for getting the correct
* centering point from the windowing system.
*/
if (runningXinerama()) {
Point p = getXineramaCenterPoint();
if (p != null) {
return p;
}
}
return super.getCenterPoint();
}
/**
* Override for Xinerama case
*/
if (runningXinerama()) {
return getXineramaWindowBounds();
} else {
return super.getMaximumWindowBounds();
}
}
public boolean runningXinerama() {
if (xinerState == null) {
// pRunningXinerama() simply returns a global boolean variable,
// so there is no need to synchronize here
}
}
return xinerState.booleanValue();
}
/**
* Return the bounds for a centered Window on a system running in Xinerama
* mode.
*
* Calculations are based on the assumption of a perfectly rectangular
* display area (display edges line up with one another, and displays
*
* The bounds to return depend on the arrangement of displays and on where
* Windows are to be centered. There are two common situations:
*
* 1) The center point lies at the center of the combined area of all the
* displays. In this case, the combined area of all displays is
* returned.
*
* 2) The center point lies at the center of a single display. In this case
* the user most likely wants centered Windows to be constrained to that
* single display. The boundaries of the one display are returned.
*
* It is possible for the center point to be at both the center of the
* entire display space AND at the center of a single monitor (a square of
* 9 monitors, for instance). In this case, the entire display area is
* returned.
*
* Because the center point is arbitrarily settable by the user, it could
* fit neither of the cases above. The fallback case is to simply return
* the combined area for all screens.
*/
int i;
// if center point is at the center of all monitors
// return union of all bounds
//
// MM*MM MMM M
// M*M *
// MMM M
// if center point is at center of a single monitor (but not of all
// monitors)
// return bounds of single monitor
//
// MMM MM
// MM* *M
// else, center is in some strange spot (such as on the border between
// monitors), and we should just return the union of all monitors
//
// MM MMM
// MM MMM
if (centerMonitorRect == null &&
// add a pixel or two for fudge-factor
}
}
// first: check for center of all monitors (video wall)
// add a pixel or two for fudge-factor
}
return unionRect;
}
// next, check if at center of one monitor
if (centerMonitorRect != null) {
"monitor, but not of the entire virtual display.");
}
return centerMonitorRect;
}
// otherwise, the center is at some weird spot: return unionRect
}
return unionRect;
}
/**
* From the DisplayChangedListener interface; devices do not need
* to react to this event.
*/
public void paletteChanged() {
}
}