/*
* 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.
*/
private static final PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XToolkit");
private static final PlatformLogger timeoutTaskLog = PlatformLogger.getLogger("sun.awt.X11.timeoutTask.XToolkit");
private static final PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XToolkit");
private static final PlatformLogger backingStoreLog = PlatformLogger.getLogger("sun.awt.X11.backingStore.XToolkit");
//There is 400 ms is set by default on Windows and 500 by default on KDE and GNOME.
//We use the same hardcoded constant.
static final boolean PRIMARY_LOOP = false;
static final boolean SECONDARY_LOOP = true;
// the system clipboard - CLIPBOARD selection
// the system selection - PRIMARY selection
// Dynamic Layout Resize client code setting
protected static boolean dynamicLayoutSetting = false;
//Is it allowed to generate events assigned to extra mouse buttons.
//Set to true by default.
private static boolean areExtraMouseButtonsEnabled = true;
/**
* True when the x settings have been loaded.
*/
private boolean loadedXSettings;
/**
* XSETTINGS for the default screen.
* <p>
*/
static int arrowCursor;
private static long _display;
static int awt_multiclick_time;
static boolean securityWarningEnabled;
static {
if (GraphicsEnvironment.isHeadless()) {
} else {
}
initIDs();
}
}
/*
* Return (potentially) platform specific display timeout for the
* tray icon
*/
static native long getTrayIconDisplayTimeout();
private native static void initIDs();
static boolean isToolkitThread() {
}
static void initSecurityWarning() {
// Enable warning only for internal builds
new GetPropertyAction("java.runtime.version"));
}
static boolean isSecurityWarningEnabled() {
return securityWarningEnabled;
}
static native void awt_output_flush();
static final void awtFUnlock() {
awtUnlock();
}
if (uidefaults == null) {
}
return uidefaults;
}
}
static void initUIDefaults() {
try {
// Load Defaults from MotifLookAndFeel
// This dummy load is necessary to get SystemColor initialized. !!!!!!
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static long getDisplay() {
return _display;
}
public static long getDefaultRootWindow() {
awtLock();
try {
if (res == 0) {
throw new IllegalStateException("Root window must not be null");
}
return res;
} finally {
awtUnlock();
}
}
void init() {
awtLock();
try {
}
tryXKB();
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned
} finally {
awtUnlock();
}
}
public void run() {
}
}
freeXKB();
dumpPeers();
}
}
};
return null;
}
};
}
} else {
return val;
}
}
return awtAppClassName;
}
public XToolkit() {
super();
if (PerformanceLogger.loggingEnabled()) {
}
if (!GraphicsEnvironment.isHeadless()) {
if (bottom >= 0) {
}
mainClassName = "AWT";
}
init();
}
return thread;
}
};
}
}
return peer;
}
return peer;
}
{
synchronized(winMap) {
}
}
synchronized(winMap) {
}
}
synchronized(winMap) {
}
}
synchronized(winToDispatcher) {
if (dispatchers == null) {
dispatchers = new Vector();
}
}
}
synchronized(winToDispatcher) {
if (dispatchers != null) {
}
}
}
/**
* Returns whether there is last remembered cursor position. The
* position is remembered from X mouse events on our peers. The
* position is stored in <code>p</code>.
* @return true, if there is remembered last cursor position,
* false otherwise
*/
awtLock();
try {
if (lastCursorPos == null) {
return false;
}
return true;
} finally {
awtUnlock();
}
}
// Only our windows guaranteely generate MotionNotify, so we
// switch to XQueryPointer
awtLock();
try {
if (lastCursorPos == null) {
} else {
}
} finally {
awtUnlock();
}
// Leave from our window
awtLock();
try {
} finally {
awtUnlock();
}
// Entrance into our window
awtLock();
try {
if (lastCursorPos == null) {
} else {
}
} finally {
awtUnlock();
}
}
}
public interface XEventListener {
}
synchronized (listeners) {
}
}
synchronized (listeners) {
try {
}
} finally {
}
}
}
(ev.get_type() == XConstants.MotionNotify || ev.get_type() == XConstants.EnterNotify || ev.get_type() == XConstants.LeaveNotify))
{
}
// The 'window' field in this event is unused.
// This application itself does nothing to initiate such an event
// (no calls of XChangeKeyboardMapping etc.).
// SunRay server sends this event to the application once on every
// keyboard (not just layout) change which means, quite seldom.
}
synchronized(winToDispatcher) {
}
}
if (dispatchers != null) {
}
}
}
}
}
static native void awt_toolkit_init();
public void run() {
}
{
while(true) {
// Fix for 6829923: we should gracefully handle toolkit thread interruption
// We expect interruption from the AppContext.dispose() method only.
// If the thread is interrupted from another place, let's skip it
// for compatibility reasons. Probably some time later we'll remove
// the check for AppContext.isDisposed() and will unconditionally
// break the loop here.
break;
}
}
awtLock();
try {
if (loop == SECONDARY_LOOP) {
// In the secondary loop we may have already aquired awt_lock
// several times, so waitForEvents() might be unable to release
// the awt_lock and this causes lock up.
// For now, we just avoid waitForEvents in the secondary loop.
break;
}
} else {
// If no events are queued, waitForEvents() causes calls to
// awtUnlock(), awtJNI_ThreadYield, poll, awtLock(),
// so it spends most of its time in poll, without holding the lock.
}
}
eventNumber++;
}
}
continue;
}
}
// Check if input method consumes the event
long w = 0;
if (ownerWindow != null) {
w = ownerWindow.getContentWindow();
}
}
}
if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) {
}
continue;
}
if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) {
}
} catch (ThreadDeath td) {
return;
} finally {
awtUnlock();
}
}
}
static int getDefaultScreenWidth() {
if (screenWidth == -1) {
long display = getDisplay();
awtLock();
try {
} finally {
awtUnlock();
}
}
return screenWidth;
}
static int getDefaultScreenHeight() {
if (screenHeight == -1) {
long display = getDisplay();
awtLock();
try {
} finally {
awtUnlock();
}
}
return screenHeight;
}
protected int getScreenWidth() {
return getDefaultScreenWidth();
}
protected int getScreenHeight() {
return getDefaultScreenHeight();
}
{
try
{
if (workareaPresent)
{
}
}
finally
{
}
return null;
}
/*
* If we're running in non-Xinerama environment and the current
* window manager supports _NET protocol then the screen insets
* are calculated using _NET_WM_WORKAREA property of the root
* window.
* Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is
* not set, we try to calculate the insets ourselves using
* getScreenInsetsManually method.
*/
{
{
return super.getScreenInsets(gc);
}
try
{
if (!x11ge.runningXinerama())
{
{
workArea.x,
}
}
}
finally
{
}
}
/*
* Manual calculation of screen insets: get all the windows with
* _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL hints and add these
* hints' values to screen insets.
*
* This method should be called under XToolkit.awtLock()
*/
{
/*
* During the manual calculation of screen insets we iterate
* all the X windows hierarchy starting from root window. This
* constant is the max level inspected in this hierarchy.
* 3 is a heuristic value: I suppose any the toolbar-like
* window is a child of either root or desktop window.
*/
final int MAX_NESTED_LEVEL = 3;
{
/*
* Note that most of the modern window managers unmap
* application window if it is iconified. Thus, any
* _NET_WM_STRUT[_PARTIAL] hints for iconified windows
* are not included to the screen insets.
*/
{
continue;
}
try
{
// first, check if _NET_WM_STRUT or _NET_WM_STRUT_PARTIAL are present
// if both are set on the window, _NET_WM_STRUT_PARTIAL is used (see _NET spec)
boolean strutPresent = XA_NET_WM_STRUT_PARTIAL.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4);
if (!strutPresent)
{
}
if (strutPresent)
{
// second, verify that window is located on the proper screen
if (windowLevel > 1)
{
}
// if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect
// if the struts area intersects with screenBounds, however some window
// managers don't set this hint correctly, so we just get intersection with windowBounds
{
}
}
}
finally
{
}
if (windowLevel < MAX_NESTED_LEVEL)
{
{
}
}
}
return insets;
}
/*
* The current implementation of disabling background erasing for
* canvases is that we don't set any native background color
* (with XSetWindowBackground) for the canvas window. However,
* this color is set in the peer constructor - see
* XWindow.postInit() for details. That's why this method from
* SunToolkit is not overridden in XToolkit: it's too late to
* disable background erasing :(
*/
/*
@Override
public void disableBackgroundErase(Canvas canvas) {
XCanvasPeer peer = (XCanvasPeer)canvas.getPeer();
if (peer == null) {
throw new IllegalStateException("Canvas must have a valid peer");
}
peer.disableBackgroundErase();
}
*/
// Need this for XMenuItemPeer.
}
if (p != null) return p;
else
}
// Need this for XMenuItemPeer.
}
}
/*
* On X, support for dynamic layout on resizing is governed by the
* window manager. If the window manager supports it, it happens
* automatically. The setter method for this property is
* irrelevant on X.
*/
public void setDynamicLayout(boolean b) {
dynamicLayoutSetting = b;
}
protected boolean isDynamicLayoutSet() {
return dynamicLayoutSetting;
}
/* Called from isDynamicLayoutActive() and from
* lazilyLoadDynamicLayoutSupportedProperty()
*/
protected boolean isDynamicLayoutSupported() {
}
public boolean isDynamicLayoutActive() {
return isDynamicLayoutSupported();
}
}
public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
}
public <T extends DragGestureRecognizer> T
Component c,
int srcActions,
{
else
return null;
}
//vb157120: looks like we don't need to map menu items
//in new menus implementation
//targetCreatedPeer(target, peer);
return peer;
}
//vb157120: looks like we don't need to map menu items
//in new menus implementation
//targetCreatedPeer(target, peer);
return peer;
}
return peer;
}
return peer;
}
return peer;
}
return peer;
}
return peer;
}
return peer;
}
return peer;
}
return peer;
}
XCanvasPeer peer = (isXEmbedServerRequested() ? new XEmbedCanvasPeer(target) : new XCanvasPeer(target));
return peer;
}
return peer;
}
return peer;
}
return peer;
}
/**
* Returns the value of "sun.awt.disableGtkFileDialogs" property. Default
* value is {@code false}.
*/
public synchronized static boolean getSunAwtDisableGtkFileDialogs() {
if (sunAwtDisableGtkFileDialogs == null) {
new GetBooleanAction("sun.awt.disableGtkFileDialogs"));
}
return sunAwtDisableGtkFileDialogs.booleanValue();
}
// The current GtkFileChooser is available from GTK+ 2.4
} else {
}
return peer;
}
return peer;
}
//vb157120: looks like we don't need to map menu items
//in new menus implementation
//targetCreatedPeer(target, peer);
return peer;
}
return peer;
}
xPeer = new XMouseInfoPeer();
}
return xPeer;
}
{
return peer;
}
return peer;
}
return XKeyboardFocusManagerPeer.getInstance();
}
/**
* Returns a new custom cursor.
*/
throws IndexOutOfBoundsException {
}
throws HeadlessException, AWTException
{
return peer;
}
return peer;
}
public boolean isTraySupported() {
return peer.isAvailable();
}
return false;
}
/**
* Returns the supported cursor size
*/
return XCustomCursor.getBestCursorSize(
}
public int getMaximumCursorColors() {
return 2; // Black and white.
}
}
throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
}
awtLock();
try {
return getModifierState( key );
} finally {
awtUnlock();
}
}
}
synchronized (this) {
}
}
return clipboard;
}
}
synchronized (this) {
}
}
return selection;
}
public void beep() {
awtLock();
try {
} finally {
awtUnlock();
}
}
final Properties props) {
throw new NullPointerException("frame must not be null");
}
if (printJob.printDialog() == false) {
}
return printJob;
}
final JobAttributes jobAttributes,
final PageAttributes pageAttributes)
{
throw new NullPointerException("frame must not be null");
}
if (printJob.printDialog() == false) {
}
return printJob;
}
static void XSync() {
awtLock();
try {
} finally {
awtUnlock();
}
}
public int getScreenResolution() {
long display = getDisplay();
awtLock();
try {
} finally {
awtUnlock();
}
}
static native long getDefaultXColormap();
static native long getDefaultScreenData();
if (screenmodel == null) {
}
return screenmodel;
}
return getStaticColorModel();
}
/**
* Returns a new input method adapter descriptor for native input methods.
*/
return new XInputMethodDescriptor();
}
/**
* Returns whether enableInputMethods should be set to true for peered
* TextComponent instances on this platform. True by default.
*/
public boolean enableInputMethodsForTextComponent() {
return true;
}
static int getMultiClickTime() {
if (awt_multiclick_time == 0) {
}
return awt_multiclick_time;
}
static void initializeMultiClickTime() {
awtLock();
try {
try {
String multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), "*", "multiClickTime");
if (multiclick_time_query != null) {
} else {
"OpenWindows", "MultiClickTimeout");
if (multiclick_time_query != null) {
/* Note: OpenWindows.MultiClickTimeout is in tenths of
a second, so we need to multiply by 100 to convert to
milliseconds */
} else {
}
}
} catch (NumberFormatException nf) {
} catch (NullPointerException npe) {
}
} finally {
awtUnlock();
}
if (awt_multiclick_time == 0) {
}
}
throws HeadlessException
{
return true;
} else {
}
}
static void dumpPeers() {
}
}
}
}
}
}
/* Protected with awt_lock. */
private static boolean initialized;
private static boolean timeStampUpdated;
private static long timeStamp;
new XEventDispatcher() {
case XConstants.PropertyNotify:
awtLock();
try {
timeStampUpdated = true;
} finally {
awtUnlock();
}
break;
}
}
};
static long getCurrentServerTime() {
awtLock();
try {
try {
if (!initialized) {
initialized = true;
}
timeStampUpdated = false;
0, 0);
if (isToolkitThread()) {
try {
}
finally {
}
}
else {
while (!timeStampUpdated) {
awtLockWait();
}
}
} catch (InterruptedException ie) {
// Note: the returned timeStamp can be incorrect in this case.
if (log.isLoggable(PlatformLogger.FINE)) log.fine("Catched exception, timeStamp may not be correct (ie = " + ie + ")");
}
} finally {
awtUnlock();
}
return timeStamp;
}
protected void initializeDesktopProperties() {
"sun.awt.shell.ShellFolderManager");
// Don't want to call getMultiClickTime() if we are headless
if (!GraphicsEnvironment.isHeadless()) {
}
}
/**
* This method runs through the XPointer and XExtendedPointer array.
* XExtendedPointer has priority because on some systems XPointer
* (which is assigned to the virtual pointer) reports the maximum
* capabilities of the mouse pointer (i.e. 32 physical buttons).
*/
private native int getNumberOfButtonsImpl();
public int getNumberOfButtons(){
awtLock();
try {
if (numberOfButtons == 0) {
numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
//4th and 5th buttons are for wheel and shouldn't be reported as buttons.
//If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
//If we have 3 physical buttons and a wheel, we report 3 buttons.
//If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
if (numberOfButtons >=5) {
numberOfButtons -= 2;
numberOfButtons = 3;
}
}
//Assume don't have to re-query the number again and again.
return numberOfButtons;
} finally {
awtUnlock();
}
}
try {
} catch (AWTException awte) {
}
}
}
if (initXSettingsIfNeeded(name)) {
}
return super.lazilyLoadDesktopProperty(name);
}
// See JavaDoc for the Toolkit.addPropertyChangeListener() method
return;
}
}
/**
* Initializes XAWTXSettings if a property for a given property name is provided by
* XSettings and they are not initialized yet.
*
* @return true if the method has initialized XAWTXSettings.
*/
if (!loadedXSettings &&
{
loadedXSettings = true;
if (!GraphicsEnvironment.isHeadless()) {
/* If no desktop font hint could be retrieved, check for
* KDE running KWin and retrieve settings from fontconfig.
* If that isn't found let SunToolkit will see if there's a
* system property set by a user.
*/
/* set the fontconfig/KDE property so that
* getDesktopHints() below will see it
* and set the public property.
*/
hint);
}
}
}
return true;
}
}
return false;
}
private void loadXSettings() {
xs = new XAWTXSettings();
}
/**
* Callback from the native side indicating some, or all, of the
* desktop properties have changed and need to be reloaded.
* <code>data</code> is the byte array directly from the x server and
* may be in little endian format.
* <p>
* NB: This could be called from any thread if triggered by
* <code>loadXSettings</code>. It is called from the System EDT
* if triggered by an XSETTINGS change.
*/
return;
}
while (i.hasNext()) {
// XXX: we probably want to do something smarter. In
// particular, "Net" properties are of interest to the
// "core" AWT itself. E.g.
//
// Net/DndDragThreshold -> ???
// Net/DoubleClickTime -> awt.multiClickInterval
}
synchronized (this) {
}
if (dragThreshold != null) {
}
}
static int altMask;
static int metaMask;
static int numLockMask;
static int modeSwitchMask;
static int modLockIsShiftLock;
/* Like XKeysymToKeycode, but ensures that keysym is the primary
* symbol on the keycode returned. Returns zero otherwise.
*/
awtLock();
try {
if (code == 0) {
return 0;
}
return 0;
}
return code;
} finally {
awtUnlock();
}
}
int iKeyMask = 0;
if (kc == 0) {
return false;
}
awtLock();
try {
for( int k = 0; k < 8; k++ ) {
for (int i = 0; i < nkeys; ++i) {
if (keycode == 0) {
continue; // ignore zero keycode
}
iKeyMask = 1 << k;
break;
}
}
if( iKeyMask != 0 ) {
break;
}
}
if (iKeyMask == 0 ) {
return false;
}
// Now we know to which modifier is assigned the keycode
// correspondent to the keysym correspondent to the java
// keycode. We are going to check a state of this modifier.
// If a modifier is a weird one, we cannot help it.
long window = 0;
try{
// get any application window
}catch(NoSuchElementException nex) {
// get root window
}
} finally {
awtUnlock();
}
}
/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
* Only consider primary symbols on keycodes attached to modifiers.
*/
static void setupModifierMap() {
final int modmask[] = { XConstants.ShiftMask, XConstants.LockMask, XConstants.ControlMask, XConstants.Mod1Mask,
awtLock();
try {
++modn)
{
for (int i = 0; i < nkeys; ++i) {
/* for each keycode attached to this modifier */
if (keycode == 0) {
break;
}
if (metaMask == 0 &&
{
break;
}
break;
}
break;
}
break;
}
continue;
}
}
modLockIsShiftLock = 0;
for (int j = 0; j < nkeys; ++j) {
if (keycode == 0) {
break;
}
modLockIsShiftLock = 1;
break;
}
break;
}
}
} finally {
awtUnlock();
}
}
}
/**
* Removed the task from the list of waiting-to-be called tasks.
* If the task has been scheduled several times removes only first one.
*/
throw new NullPointerException("task is null");
}
awtLock();
try {
}
if (timeoutTasks == null) {
}
return;
}
boolean removed = false;
}
break;
}
}
} finally {
awtUnlock();
}
}
static native void wakeup_poll();
/**
* Registers a Runnable which <code>run()</code> method will be called
* once on the toolkit thread when a specified interval of time elapses.
*
* @param task a Runnable which <code>run</code> method will be called
* on the toolkit thread when <code>interval</code> milliseconds
* elapse
* @param interval an interal in milliseconds
*
* @throws NullPointerException if <code>task</code> is <code>null</code>
* @throws IllegalArgumentException if <code>interval</code> is not positive
*/
throw new NullPointerException("task is null");
}
if (interval <= 0) {
}
awtLock();
try {
"; interval={1}" +
"; task being added={2}" + "; tasks before addition={3}",
}
if (timeoutTasks == null) {
timeoutTasks = new TreeMap();
}
}
// Added task became first task - poll won't know
// about it so we need to wake it up
wakeup_poll();
}
} finally {
awtUnlock();
}
}
private long getNextTaskTime() {
awtLock();
try {
return -1L;
}
} finally {
awtUnlock();
}
}
/**
* Executes mature timeout tasks registered with schedule().
* Called from run() under awtLock.
*/
private static void callTimeoutTasks() {
}
return;
}
}
try {
} catch (ThreadDeath td) {
throw td;
}
}
if (timeoutTasks.isEmpty()) {
break;
}
}
}
static long getAwtDefaultFg() {
return awt_defaultFg;
}
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_DRAGGED:
}
return false;
}
int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_DRAGGED:
}
return false;
}
static long reset_time_utc;
/*
* This function converts between the X server time (number of milliseconds
* since the last server reset) and the UTC time for the 'when' field of an
* InputEvent (or another event type with a timestamp).
*/
// ported from awt_util.c
/*
* Because Time is of type 'unsigned long', it is possible that Time will
* never wrap when using 64-bit Xlib. However, if a 64-bit client
* connects to a 32-bit server, I suspect the values will still wrap. So
* we should not attempt to remove the wrap checking even if _LP64 is
* true.
*/
}
}
}
return reset_time_utc + server_offset;
}
/**
* @see sun.awt.SunToolkit#needsXEmbedImpl
*/
protected boolean needsXEmbedImpl() {
// XToolkit implements supports for XEmbed-client protocol and
// requires the supports from the embedding host for it to work.
return true;
}
return (modalityType == null) ||
}
return (exclusionType == null) ||
}
if (appContext != null) {
}
return null;
}
boolean removeAllEvents) {
}
public boolean isAlwaysOnTopSupported() {
return true;
}
}
return false;
}
public boolean useBufferPerWindow() {
}
/**
* Returns one of XConstants: NotUseful, WhenMapped or Always.
* If backing store is not available on at least one screen, or
* java2d uses DGA(which conflicts with backing store) on at least one screen,
* or the string system property "sun.awt.backingStore" is neither "Always"
* nor "WhenMapped", then the method returns XConstants.NotUseful.
* Otherwise, if the system property "sun.awt.backingStore" is "WhenMapped",
* then the method returns XConstants.WhenMapped.
* Otherwise (i.e., if the system property "sun.awt.backingStore" is "Always"),
* the method returns XConstants.Always.
*/
static int getBackingStoreType() {
return backingStoreType;
}
private static void setBackingStoreType() {
", by default backingStore=NotUseful");
}
return;
}
}
} else {
}
"WhenMapped" : "Always") );
}
}
return;
}
awtLock();
try {
for (int i = 0; i < screenCount; i++) {
== XConstants.NotUseful) {
i + ", backingStore=NotUseful");
}
return;
}
}
} finally {
awtUnlock();
}
}
/**
* One of XConstants: NotUseful, WhenMapped or Always.
*/
private static int backingStoreType;
static boolean awt_UseXKB = false;
static boolean awt_UseXKB_Calls = false;
// to XkbTranslateKeyCode
/**
* Check for Xsun convention regarding numpad keys.
* Xsun and some other servers (i.e. derived from Xsun)
* under certain conditions process numpad keys unlike Xorg.
*/
static boolean isXsunKPBehavior() {
awtLock();
try {
if( awt_IsXsunKPBehavior == 0 ) {
}else{
}
}
return awt_IsXsunKPBehavior == XSUN_KP_BEHAVIOR ? true : false;
} finally {
awtUnlock();
}
}
static void resetKeyboardSniffer() {
sunOrNotKeyboard = 0;
kanaOrNotKeyboard = 0;
}
static boolean isSunKeyboard() {
if( sunOrNotKeyboard == 0 ) {
}else{
}
}
return (sunOrNotKeyboard == IS_SUN_KEYBOARD);
}
static boolean isKanaKeyboard() {
if( kanaOrNotKeyboard == 0 ) {
}else{
}
}
return (kanaOrNotKeyboard == IS_KANA_KEYBOARD);
}
static boolean isXKBenabled() {
awtLock();
try {
return awt_UseXKB;
} finally {
awtUnlock();
}
}
/**
Query XKEYBOARD extension.
If possible, initialize xkb library.
*/
static boolean tryXKB() {
awtLock();
try {
// First, if there is extension at all.
awt_UseXKB = XlibWrapper.XQueryExtension( getDisplay(), name, XlibWrapper.larg1, XlibWrapper.larg2, XlibWrapper.larg3);
if( awt_UseXKB ) {
// There is a keyboard extension. Check if a client library is compatible.
// If not, don't use xkb calls.
// In this case we still may be Xkb-capable application.
if( awt_UseXKB_Calls ) {
awt_UseXKB_Calls = XlibWrapper.XkbQueryExtension( getDisplay(), XlibWrapper.larg1, XlibWrapper.larg2,
if( awt_UseXKB_Calls ) {
//XConstants.XkbStateNotifyMask,
//XConstants.XkbStateNotifyMask);
//XXX ? XkbGroupLockMask last, XkbAllStateComponentsMask before last?
}
}
}
return awt_UseXKB;
} finally {
awtUnlock();
}
}
static boolean canUseXKBCalls() {
awtLock();
try {
return awt_UseXKB_Calls;
} finally {
awtUnlock();
}
}
static int getXKBEffectiveGroup() {
awtLock();
try {
return awt_XKBEffectiveGroup;
} finally {
awtUnlock();
}
}
static int getXKBBaseEventCode() {
awtLock();
try {
return awt_XKBBaseEventCode;
} finally {
awtUnlock();
}
}
static long getXKBKbdDesc() {
awtLock();
try {
return awt_XKBDescPtr;
} finally {
awtUnlock();
}
}
void freeXKB() {
awtLock();
try {
awt_XKBDescPtr = 0;
}
} finally {
awtUnlock();
}
}
// mapping change --> refresh kbd map
// state change --> get a new effective group; do I really need it
// or that should be left for XkbTranslateKeyCode?
switch( xkb_type ) {
case XConstants.XkbNewKeyboardNotify :
if( awt_XKBDescPtr != 0 ) {
freeXKB();
}
//System.out.println("XkbNewKeyboard:"+(xke.get_new_kbd()));
break;
case XConstants.XkbMapNotify :
//TODO: provide a simple unit test.
//System.out.println("XkbMap:"+(xke.get_map()));
break;
case XConstants.XkbStateNotify :
// May use it later e.g. to obtain an effective group etc.
//System.out.println("XkbState:"+(xke.get_state()));
break;
default:
//System.out.println("XkbEvent of xkb_type "+xkb_type);
break;
}
}
private static long eventNumber;
public static long getEventNumber() {
awtLock();
try {
return eventNumber;
} finally {
awtUnlock();
}
}
private static boolean oops_updated;
private static boolean oops_failed;
/**
* @inheritDoc
*/
if (oops_waiter == null) {
oops_waiter = new XEventDispatcher() {
public void dispatchEvent(XEvent e) {
oops_updated = true;
{
// WM forgot to acquire selection or there is no WM
oops_failed = true;
}
}
}
};
}
}
awtLock();
try {
oops_updated = false;
oops_failed = false;
// Wait for selection notify for oops on win
long event_number = getEventNumber();
eventLog.finer("WM_S0 selection owner {0}", XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom()));
XSync();
while (!oops_updated && !oops_failed) {
try {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// This "while" is a protection from spurious
// wake-ups. However, we shouldn't wait for too long
}
}
// If selection update failed we can simply wait some time
// hoping some events will arrive
awtUnlock();
try {
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
} finally {
awtLock();
}
}
} finally {
awtUnlock();
}
}
}
}
}
}
/**
* Returns if the java.awt.Desktop class is supported on the current
* desktop.
* <p>
* The methods of java.awt.Desktop class are supported on the Gnome desktop.
* Check if the running desktop is Gnome by checking the window manager.
*/
public boolean isDesktopSupported(){
return XDesktopPeer.isDesktopSupported();
}
return new XDesktopPeer();
}
return areExtraMouseButtonsEnabled;
}
public boolean isWindowOpacitySupported() {
if (net_protocol == null) {
return false;
}
return net_protocol.doOpacityProtocol();
}
public boolean isWindowShapingSupported() {
return XlibUtil.isShapingSupported();
}
public boolean isWindowTranslucencySupported() {
//NOTE: it may not be supported. The actual check is being performed
// at com.sun.awt.AWTUtilities(). In X11 we need to check
// whether there's any translucency-capable GC available.
return true;
}
if (!(gc instanceof X11GraphicsConfig)) {
return false;
}
}
/**
* Returns the value of "sun.awt.disablegrab" property. Default
* value is {@code false}.
*/
public static boolean getSunAwtDisableGrab() {
}
}