0N/A/*
6447N/A * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage sun.awt.X11;
0N/A
0N/Aimport java.awt.*;
84N/Aimport java.awt.event.InputEvent;
84N/Aimport java.awt.event.MouseEvent;
874N/Aimport java.awt.event.KeyEvent;
84N/Aimport java.awt.datatransfer.Clipboard;
0N/Aimport java.awt.dnd.DragSource;
0N/Aimport java.awt.dnd.DragGestureListener;
0N/Aimport java.awt.dnd.DragGestureEvent;
0N/Aimport java.awt.dnd.DragGestureRecognizer;
0N/Aimport java.awt.dnd.MouseDragGestureRecognizer;
0N/Aimport java.awt.dnd.InvalidDnDOperationException;
0N/Aimport java.awt.dnd.peer.DragSourceContextPeer;
0N/Aimport java.awt.im.InputMethodHighlight;
0N/Aimport java.awt.im.spi.InputMethodDescriptor;
84N/Aimport java.awt.image.ColorModel;
84N/Aimport java.awt.peer.*;
84N/Aimport java.beans.PropertyChangeListener;
84N/Aimport java.security.AccessController;
84N/Aimport java.security.PrivilegedAction;
84N/Aimport java.util.*;
0N/Aimport javax.swing.LookAndFeel;
0N/Aimport javax.swing.UIDefaults;
84N/Aimport sun.awt.*;
1686N/Aimport sun.font.FontConfigManager;
0N/Aimport sun.misc.PerformanceLogger;
0N/Aimport sun.print.PrintJob2D;
5255N/Aimport sun.security.action.GetPropertyAction;
1065N/Aimport sun.security.action.GetBooleanAction;
1696N/Aimport sun.util.logging.PlatformLogger;
0N/A
216N/Apublic final class XToolkit extends UNIXToolkit implements Runnable {
1696N/A private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XToolkit");
1696N/A private static final PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XToolkit");
1696N/A private static final PlatformLogger timeoutTaskLog = PlatformLogger.getLogger("sun.awt.X11.timeoutTask.XToolkit");
1696N/A private static final PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XToolkit");
1696N/A private static final PlatformLogger backingStoreLog = PlatformLogger.getLogger("sun.awt.X11.backingStore.XToolkit");
0N/A
877N/A //There is 400 ms is set by default on Windows and 500 by default on KDE and GNOME.
877N/A //We use the same hardcoded constant.
877N/A private final static int AWT_MULTICLICK_DEFAULT_TIME = 500;
877N/A
0N/A static final boolean PRIMARY_LOOP = false;
0N/A static final boolean SECONDARY_LOOP = true;
0N/A
0N/A private static String awtAppClassName = null;
0N/A
0N/A // the system clipboard - CLIPBOARD selection
0N/A XClipboard clipboard;
0N/A // the system selection - PRIMARY selection
0N/A XClipboard selection;
0N/A
0N/A // Dynamic Layout Resize client code setting
0N/A protected static boolean dynamicLayoutSetting = false;
0N/A
870N/A //Is it allowed to generate events assigned to extra mouse buttons.
870N/A //Set to true by default.
870N/A private static boolean areExtraMouseButtonsEnabled = true;
870N/A
0N/A /**
0N/A * True when the x settings have been loaded.
0N/A */
0N/A private boolean loadedXSettings;
0N/A
0N/A /**
0N/A * XSETTINGS for the default screen.
0N/A * <p>
0N/A */
0N/A private XSettings xs;
0N/A
1686N/A private FontConfigManager fcManager = new FontConfigManager();
1686N/A
0N/A static int arrowCursor;
0N/A static TreeMap winMap = new TreeMap();
0N/A static HashMap specialPeerMap = new HashMap();
0N/A static HashMap winToDispatcher = new HashMap();
0N/A private static long _display;
0N/A static UIDefaults uidefaults;
0N/A static X11GraphicsEnvironment localEnv;
0N/A static X11GraphicsDevice device;
0N/A static final X11GraphicsConfig config;
0N/A static int awt_multiclick_time;
0N/A static boolean securityWarningEnabled;
0N/A
0N/A private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
0N/A static long awt_defaultFg; // Pixel
0N/A private static XMouseInfoPeer xPeer;
0N/A
0N/A static {
0N/A initSecurityWarning();
0N/A if (GraphicsEnvironment.isHeadless()) {
0N/A config = null;
0N/A } else {
0N/A localEnv = (X11GraphicsEnvironment) GraphicsEnvironment
0N/A .getLocalGraphicsEnvironment();
0N/A device = (X11GraphicsDevice) localEnv.getDefaultScreenDevice();
0N/A config = (X11GraphicsConfig) (device.getDefaultConfiguration());
0N/A if (device != null) {
0N/A _display = device.getDisplay();
0N/A }
0N/A setupModifierMap();
0N/A initIDs();
0N/A setBackingStoreType();
0N/A }
1216N/A }
1216N/A
3876N/A /*
3876N/A * Return (potentially) platform specific display timeout for the
3876N/A * tray icon
3876N/A */
3876N/A static native long getTrayIconDisplayTimeout();
3876N/A
0N/A private native static void initIDs();
0N/A native static void waitForEvents(long nextTaskTime);
0N/A static Thread toolkitThread;
0N/A static boolean isToolkitThread() {
0N/A return Thread.currentThread() == toolkitThread;
0N/A }
0N/A
0N/A static void initSecurityWarning() {
0N/A // Enable warning only for internal builds
5255N/A String runtime = AccessController.doPrivileged(
5255N/A new GetPropertyAction("java.runtime.version"));
0N/A securityWarningEnabled = (runtime != null && runtime.contains("internal"));
0N/A }
0N/A
0N/A static boolean isSecurityWarningEnabled() {
0N/A return securityWarningEnabled;
0N/A }
0N/A
0N/A static native void awt_output_flush();
0N/A
0N/A static final void awtFUnlock() {
0N/A awtUnlock();
0N/A awt_output_flush();
0N/A }
0N/A
0N/A
0N/A public native void nativeLoadSystemColors(int[] systemColors);
0N/A
0N/A static UIDefaults getUIDefaults() {
0N/A if (uidefaults == null) {
0N/A initUIDefaults();
0N/A }
0N/A return uidefaults;
0N/A }
0N/A
0N/A public void loadSystemColors(int[] systemColors) {
0N/A nativeLoadSystemColors(systemColors);
0N/A MotifColorUtilities.loadSystemColors(systemColors);
0N/A }
0N/A
0N/A
0N/A
0N/A static void initUIDefaults() {
0N/A try {
0N/A // Load Defaults from MotifLookAndFeel
0N/A
0N/A // This dummy load is necessary to get SystemColor initialized. !!!!!!
0N/A Color c = SystemColor.text;
0N/A
0N/A LookAndFeel lnf = new XAWTLookAndFeel();
0N/A uidefaults = lnf.getDefaults();
0N/A }
0N/A catch (Exception e)
0N/A {
0N/A e.printStackTrace();
0N/A }
0N/A }
0N/A
0N/A static Object displayLock = new Object();
0N/A
0N/A public static long getDisplay() {
0N/A return _display;
0N/A }
0N/A
0N/A public static long getDefaultRootWindow() {
0N/A awtLock();
0N/A try {
0N/A long res = XlibWrapper.RootWindow(XToolkit.getDisplay(),
0N/A XlibWrapper.DefaultScreen(XToolkit.getDisplay()));
0N/A
0N/A if (res == 0) {
0N/A throw new IllegalStateException("Root window must not be null");
0N/A }
0N/A return res;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A void init() {
0N/A awtLock();
0N/A try {
0N/A XlibWrapper.XSupportsLocale();
0N/A if (XlibWrapper.XSetLocaleModifiers("") == null) {
0N/A log.finer("X locale modifiers are not supported, using default");
0N/A }
1067N/A tryXKB();
0N/A
0N/A AwtScreenData defaultScreen = new AwtScreenData(XToolkit.getDefaultScreenData());
0N/A awt_defaultFg = defaultScreen.get_blackpixel();
0N/A
0N/A arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
0N/A XCursorFontConstants.XC_arrow);
870N/A areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
870N/A //set system property if not yet assigned
870N/A System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
0N/A } finally {
0N/A awtUnlock();
0N/A }
2285N/A PrivilegedAction<Void> a = new PrivilegedAction<Void>() {
2285N/A public Void run() {
2285N/A ThreadGroup mainTG = Thread.currentThread().getThreadGroup();
2285N/A ThreadGroup parentTG = mainTG.getParent();
2285N/A while (parentTG != null) {
2285N/A mainTG = parentTG;
2285N/A parentTG = mainTG.getParent();
1216N/A }
2285N/A Thread shutdownThread = new Thread(mainTG, "XToolkt-Shutdown-Thread") {
2285N/A public void run() {
2285N/A XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
2285N/A if (peer != null) {
2285N/A peer.dispose();
2285N/A }
2285N/A if (xs != null) {
2285N/A ((XAWTXSettings)xs).dispose();
2285N/A }
2285N/A freeXKB();
2285N/A if (log.isLoggable(PlatformLogger.FINE)) {
2285N/A dumpPeers();
2285N/A }
2285N/A }
2285N/A };
2285N/A shutdownThread.setContextClassLoader(null);
2285N/A Runtime.getRuntime().addShutdownHook(shutdownThread);
2285N/A return null;
1216N/A }
2285N/A };
2285N/A AccessController.doPrivileged(a);
0N/A }
0N/A
0N/A static String getCorrectXIDString(String val) {
0N/A if (val != null) {
0N/A return val.replace('.', '-');
0N/A } else {
0N/A return val;
0N/A }
0N/A }
0N/A
0N/A static native String getEnv(String key);
0N/A
0N/A
0N/A static String getAWTAppClassName() {
0N/A return awtAppClassName;
0N/A }
0N/A
0N/A static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer";
0N/A
0N/A public XToolkit() {
0N/A super();
0N/A if (PerformanceLogger.loggingEnabled()) {
0N/A PerformanceLogger.setTime("XToolkit construction");
0N/A }
0N/A
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A String mainClassName = null;
0N/A
0N/A StackTraceElement trace[] = (new Throwable()).getStackTrace();
0N/A int bottom = trace.length - 1;
0N/A if (bottom >= 0) {
0N/A mainClassName = trace[bottom].getClassName();
0N/A }
0N/A if (mainClassName == null || mainClassName.equals("")) {
0N/A mainClassName = "AWT";
0N/A }
0N/A awtAppClassName = getCorrectXIDString(mainClassName);
0N/A
0N/A init();
0N/A XWM.init();
0N/A SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
2854N/A
2854N/A PrivilegedAction<Thread> action = new PrivilegedAction() {
2854N/A public Thread run() {
2854N/A ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
2854N/A ThreadGroup parentTG = currentTG.getParent();
2854N/A while (parentTG != null) {
2854N/A currentTG = parentTG;
2854N/A parentTG = currentTG.getParent();
2854N/A }
2854N/A Thread thread = new Thread(currentTG, XToolkit.this, "AWT-XAWT");
2854N/A thread.setPriority(Thread.NORM_PRIORITY + 1);
2854N/A thread.setDaemon(true);
2854N/A return thread;
2854N/A }
2854N/A };
2854N/A toolkitThread = AccessController.doPrivileged(action);
0N/A toolkitThread.start();
0N/A }
0N/A }
0N/A
0N/A public ButtonPeer createButton(Button target) {
0N/A ButtonPeer peer = new XButtonPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public FramePeer createFrame(Frame target) {
0N/A FramePeer peer = new XFramePeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A static void addToWinMap(long window, XBaseWindow xwin)
0N/A {
0N/A synchronized(winMap) {
0N/A winMap.put(Long.valueOf(window),xwin);
0N/A }
0N/A }
0N/A
0N/A static void removeFromWinMap(long window, XBaseWindow xwin) {
0N/A synchronized(winMap) {
0N/A winMap.remove(Long.valueOf(window));
0N/A }
0N/A }
0N/A static XBaseWindow windowToXWindow(long window) {
0N/A synchronized(winMap) {
0N/A return (XBaseWindow) winMap.get(Long.valueOf(window));
0N/A }
0N/A }
0N/A
0N/A static void addEventDispatcher(long window, XEventDispatcher dispatcher) {
0N/A synchronized(winToDispatcher) {
0N/A Long key = Long.valueOf(window);
0N/A Collection dispatchers = (Collection)winToDispatcher.get(key);
0N/A if (dispatchers == null) {
0N/A dispatchers = new Vector();
0N/A winToDispatcher.put(key, dispatchers);
0N/A }
0N/A dispatchers.add(dispatcher);
0N/A }
0N/A }
0N/A static void removeEventDispatcher(long window, XEventDispatcher dispatcher) {
0N/A synchronized(winToDispatcher) {
0N/A Long key = Long.valueOf(window);
0N/A Collection dispatchers = (Collection)winToDispatcher.get(key);
0N/A if (dispatchers != null) {
0N/A dispatchers.remove(dispatcher);
0N/A }
0N/A }
0N/A }
0N/A
0N/A private Point lastCursorPos;
0N/A
0N/A /**
0N/A * Returns whether there is last remembered cursor position. The
0N/A * position is remembered from X mouse events on our peers. The
0N/A * position is stored in <code>p</code>.
0N/A * @return true, if there is remembered last cursor position,
0N/A * false otherwise
0N/A */
0N/A boolean getLastCursorPos(Point p) {
0N/A awtLock();
0N/A try {
0N/A if (lastCursorPos == null) {
0N/A return false;
0N/A }
0N/A p.setLocation(lastCursorPos);
0N/A return true;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A private void processGlobalMotionEvent(XEvent e) {
0N/A // Only our windows guaranteely generate MotionNotify, so we
0N/A // should track enter/leave, to catch the moment when to
0N/A // switch to XQueryPointer
216N/A if (e.get_type() == XConstants.MotionNotify) {
0N/A XMotionEvent ev = e.get_xmotion();
0N/A awtLock();
0N/A try {
0N/A if (lastCursorPos == null) {
0N/A lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root());
0N/A } else {
0N/A lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root());
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
216N/A } else if (e.get_type() == XConstants.LeaveNotify) {
0N/A // Leave from our window
0N/A awtLock();
0N/A try {
0N/A lastCursorPos = null;
0N/A } finally {
0N/A awtUnlock();
0N/A }
216N/A } else if (e.get_type() == XConstants.EnterNotify) {
0N/A // Entrance into our window
0N/A XCrossingEvent ev = e.get_xcrossing();
0N/A awtLock();
0N/A try {
0N/A if (lastCursorPos == null) {
0N/A lastCursorPos = new Point(ev.get_x_root(), ev.get_y_root());
0N/A } else {
0N/A lastCursorPos.setLocation(ev.get_x_root(), ev.get_y_root());
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A }
0N/A
0N/A public interface XEventListener {
0N/A public void eventProcessed(XEvent e);
0N/A }
0N/A
0N/A private Collection<XEventListener> listeners = new LinkedList<XEventListener>();
0N/A
0N/A public void addXEventListener(XEventListener listener) {
0N/A synchronized (listeners) {
0N/A listeners.add(listener);
0N/A }
0N/A }
0N/A
0N/A private void notifyListeners(XEvent xev) {
0N/A synchronized (listeners) {
0N/A if (listeners.size() == 0) return;
0N/A
0N/A XEvent copy = xev.clone();
0N/A try {
0N/A for (XEventListener listener : listeners) {
0N/A listener.eventProcessed(copy);
0N/A }
0N/A } finally {
0N/A copy.dispose();
0N/A }
0N/A }
0N/A }
0N/A
0N/A private void dispatchEvent(XEvent ev) {
0N/A final XAnyEvent xany = ev.get_xany();
0N/A
0N/A if (windowToXWindow(xany.get_window()) != null &&
216N/A (ev.get_type() == XConstants.MotionNotify || ev.get_type() == XConstants.EnterNotify || ev.get_type() == XConstants.LeaveNotify))
0N/A {
0N/A processGlobalMotionEvent(ev);
0N/A }
0N/A
1975N/A if( ev.get_type() == XConstants.MappingNotify ) {
1975N/A // The 'window' field in this event is unused.
1975N/A // This application itself does nothing to initiate such an event
1975N/A // (no calls of XChangeKeyboardMapping etc.).
1975N/A // SunRay server sends this event to the application once on every
1975N/A // keyboard (not just layout) change which means, quite seldom.
1975N/A XlibWrapper.XRefreshKeyboardMapping(ev.pData);
1975N/A resetKeyboardSniffer();
1975N/A setupModifierMap();
1975N/A }
0N/A XBaseWindow.dispatchToWindow(ev);
0N/A
0N/A Collection dispatchers = null;
0N/A synchronized(winToDispatcher) {
0N/A Long key = Long.valueOf(xany.get_window());
0N/A dispatchers = (Collection)winToDispatcher.get(key);
0N/A if (dispatchers != null) { // Clone it to avoid synchronization during dispatching
0N/A dispatchers = new Vector(dispatchers);
0N/A }
0N/A }
0N/A if (dispatchers != null) {
0N/A Iterator iter = dispatchers.iterator();
0N/A while (iter.hasNext()) {
0N/A XEventDispatcher disp = (XEventDispatcher)iter.next();
0N/A disp.dispatchEvent(ev);
0N/A }
0N/A }
0N/A notifyListeners(ev);
0N/A }
0N/A
0N/A static void processException(Throwable thr) {
1696N/A if (log.isLoggable(PlatformLogger.WARNING)) {
1696N/A log.warning("Exception on Toolkit thread", thr);
0N/A }
0N/A }
0N/A
0N/A static native void awt_toolkit_init();
0N/A
0N/A public void run() {
0N/A awt_toolkit_init();
0N/A run(PRIMARY_LOOP);
0N/A }
0N/A
0N/A public void run(boolean loop)
0N/A {
0N/A XEvent ev = new XEvent();
0N/A while(true) {
1165N/A // Fix for 6829923: we should gracefully handle toolkit thread interruption
1165N/A if (Thread.currentThread().isInterrupted()) {
1165N/A // We expect interruption from the AppContext.dispose() method only.
1165N/A // If the thread is interrupted from another place, let's skip it
1165N/A // for compatibility reasons. Probably some time later we'll remove
1165N/A // the check for AppContext.isDisposed() and will unconditionally
1165N/A // break the loop here.
1165N/A if (AppContext.getAppContext().isDisposed()) {
1165N/A break;
1165N/A }
1165N/A }
0N/A awtLock();
0N/A try {
0N/A if (loop == SECONDARY_LOOP) {
0N/A // In the secondary loop we may have already aquired awt_lock
0N/A // several times, so waitForEvents() might be unable to release
0N/A // the awt_lock and this causes lock up.
0N/A // For now, we just avoid waitForEvents in the secondary loop.
0N/A if (!XlibWrapper.XNextSecondaryLoopEvent(getDisplay(),ev.pData)) {
0N/A break;
0N/A }
0N/A } else {
0N/A callTimeoutTasks();
0N/A // If no events are queued, waitForEvents() causes calls to
0N/A // awtUnlock(), awtJNI_ThreadYield, poll, awtLock(),
0N/A // so it spends most of its time in poll, without holding the lock.
216N/A while ((XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterReading) == 0) &&
216N/A (XlibWrapper.XEventsQueued(getDisplay(), XConstants.QueuedAfterFlush) == 0)) {
0N/A callTimeoutTasks();
0N/A waitForEvents(getNextTaskTime());
0N/A }
0N/A XlibWrapper.XNextEvent(getDisplay(),ev.pData);
0N/A }
0N/A
216N/A if (ev.get_type() != XConstants.NoExpose) {
0N/A eventNumber++;
0N/A }
1067N/A if (awt_UseXKB_Calls && ev.get_type() == awt_XKBBaseEventCode) {
1067N/A processXkbChanges(ev);
1067N/A }
0N/A
0N/A if (XDropTargetEventProcessor.processEvent(ev) ||
0N/A XDragSourceContextPeer.processEvent(ev)) {
0N/A continue;
0N/A }
0N/A
1696N/A if (eventLog.isLoggable(PlatformLogger.FINER)) {
1696N/A eventLog.finer("{0}", ev);
0N/A }
0N/A
0N/A // Check if input method consumes the event
0N/A long w = 0;
0N/A if (windowToXWindow(ev.get_xany().get_window()) != null) {
0N/A Component owner =
5336N/A XKeyboardFocusManagerPeer.getInstance().getCurrentFocusOwner();
0N/A if (owner != null) {
1976N/A XWindow ownerWindow = (XWindow) AWTAccessor.getComponentAccessor().getPeer(owner);
0N/A if (ownerWindow != null) {
0N/A w = ownerWindow.getContentWindow();
0N/A }
0N/A }
0N/A }
1696N/A if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) {
0N/A keyEventLog.fine("before XFilterEvent:"+ev);
0N/A }
0N/A if (XlibWrapper.XFilterEvent(ev.getPData(), w)) {
0N/A continue;
0N/A }
1696N/A if( keyEventLog.isLoggable(PlatformLogger.FINE) && (ev.get_type() == XConstants.KeyPress || ev.get_type() == XConstants.KeyRelease) ) {
0N/A keyEventLog.fine("after XFilterEvent:"+ev); // IS THIS CORRECT?
0N/A }
0N/A
0N/A dispatchEvent(ev);
0N/A } catch (ThreadDeath td) {
0N/A XBaseWindow.ungrabInput();
0N/A return;
0N/A } catch (Throwable thr) {
0N/A XBaseWindow.ungrabInput();
0N/A processException(thr);
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A }
0N/A
0N/A static int getDefaultScreenWidth() {
0N/A if (screenWidth == -1) {
0N/A long display = getDisplay();
0N/A awtLock();
0N/A try {
0N/A screenWidth = (int) XlibWrapper.DisplayWidth(display, XlibWrapper.DefaultScreen(display));
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A return screenWidth;
0N/A }
0N/A
0N/A static int getDefaultScreenHeight() {
0N/A if (screenHeight == -1) {
0N/A long display = getDisplay();
0N/A awtLock();
0N/A try {
0N/A screenHeight = (int) XlibWrapper.DisplayHeight(display, XlibWrapper.DefaultScreen(display));
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A return screenHeight;
0N/A }
0N/A
0N/A protected int getScreenWidth() {
0N/A return getDefaultScreenWidth();
0N/A }
0N/A
0N/A protected int getScreenHeight() {
0N/A return getDefaultScreenHeight();
0N/A }
0N/A
0N/A private static Rectangle getWorkArea(long root)
0N/A {
0N/A XAtom XA_NET_WORKAREA = XAtom.get("_NET_WORKAREA");
0N/A
0N/A long native_ptr = Native.allocateLongArray(4);
0N/A try
0N/A {
0N/A boolean workareaPresent = XA_NET_WORKAREA.getAtomData(root,
0N/A XAtom.XA_CARDINAL, native_ptr, 4);
0N/A if (workareaPresent)
0N/A {
0N/A int rootX = (int)Native.getLong(native_ptr, 0);
0N/A int rootY = (int)Native.getLong(native_ptr, 1);
0N/A int rootWidth = (int)Native.getLong(native_ptr, 2);
0N/A int rootHeight = (int)Native.getLong(native_ptr, 3);
0N/A
0N/A return new Rectangle(rootX, rootY, rootWidth, rootHeight);
0N/A }
0N/A }
0N/A finally
0N/A {
0N/A XlibWrapper.unsafe.freeMemory(native_ptr);
0N/A }
0N/A
0N/A return null;
0N/A }
0N/A
0N/A /*
0N/A * If we're running in non-Xinerama environment and the current
0N/A * window manager supports _NET protocol then the screen insets
0N/A * are calculated using _NET_WM_WORKAREA property of the root
0N/A * window.
0N/A * Otherwise, i. e. if Xinerama is on or _NET_WM_WORKAREA is
0N/A * not set, we try to calculate the insets ourselves using
0N/A * getScreenInsetsManually method.
0N/A */
0N/A public Insets getScreenInsets(GraphicsConfiguration gc)
0N/A {
0N/A XNETProtocol netProto = XWM.getWM().getNETProtocol();
0N/A if ((netProto == null) || !netProto.active())
0N/A {
0N/A return super.getScreenInsets(gc);
0N/A }
0N/A
0N/A XToolkit.awtLock();
0N/A try
0N/A {
0N/A X11GraphicsConfig x11gc = (X11GraphicsConfig)gc;
0N/A X11GraphicsDevice x11gd = (X11GraphicsDevice)x11gc.getDevice();
0N/A long root = XlibUtil.getRootWindow(x11gd.getScreen());
0N/A Rectangle rootBounds = XlibUtil.getWindowGeometry(root);
0N/A
0N/A X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
0N/A GraphicsEnvironment.getLocalGraphicsEnvironment();
0N/A if (!x11ge.runningXinerama())
0N/A {
0N/A Rectangle workArea = XToolkit.getWorkArea(root);
0N/A if (workArea != null)
0N/A {
0N/A return new Insets(workArea.y,
0N/A workArea.x,
0N/A rootBounds.height - workArea.height - workArea.y,
0N/A rootBounds.width - workArea.width - workArea.x);
0N/A }
0N/A }
0N/A
0N/A return getScreenInsetsManually(root, rootBounds, gc.getBounds());
0N/A }
0N/A finally
0N/A {
0N/A XToolkit.awtUnlock();
0N/A }
0N/A }
0N/A
0N/A /*
0N/A * Manual calculation of screen insets: get all the windows with
0N/A * _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL hints and add these
0N/A * hints' values to screen insets.
0N/A *
0N/A * This method should be called under XToolkit.awtLock()
0N/A */
0N/A private Insets getScreenInsetsManually(long root, Rectangle rootBounds, Rectangle screenBounds)
0N/A {
0N/A /*
0N/A * During the manual calculation of screen insets we iterate
0N/A * all the X windows hierarchy starting from root window. This
0N/A * constant is the max level inspected in this hierarchy.
0N/A * 3 is a heuristic value: I suppose any the toolbar-like
0N/A * window is a child of either root or desktop window.
0N/A */
0N/A final int MAX_NESTED_LEVEL = 3;
0N/A
0N/A XAtom XA_NET_WM_STRUT = XAtom.get("_NET_WM_STRUT");
0N/A XAtom XA_NET_WM_STRUT_PARTIAL = XAtom.get("_NET_WM_STRUT_PARTIAL");
0N/A
0N/A Insets insets = new Insets(0, 0, 0, 0);
0N/A
0N/A java.util.List search = new LinkedList();
0N/A search.add(root);
0N/A search.add(0);
0N/A while (!search.isEmpty())
0N/A {
0N/A long window = (Long)search.remove(0);
0N/A int windowLevel = (Integer)search.remove(0);
0N/A
0N/A /*
0N/A * Note that most of the modern window managers unmap
0N/A * application window if it is iconified. Thus, any
0N/A * _NET_WM_STRUT[_PARTIAL] hints for iconified windows
0N/A * are not included to the screen insets.
0N/A */
216N/A if (XlibUtil.getWindowMapState(window) == XConstants.IsUnmapped)
0N/A {
0N/A continue;
0N/A }
0N/A
0N/A long native_ptr = Native.allocateLongArray(4);
0N/A try
0N/A {
0N/A // first, check if _NET_WM_STRUT or _NET_WM_STRUT_PARTIAL are present
0N/A // if both are set on the window, _NET_WM_STRUT_PARTIAL is used (see _NET spec)
0N/A boolean strutPresent = XA_NET_WM_STRUT_PARTIAL.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4);
0N/A if (!strutPresent)
0N/A {
0N/A strutPresent = XA_NET_WM_STRUT.getAtomData(window, XAtom.XA_CARDINAL, native_ptr, 4);
0N/A }
0N/A if (strutPresent)
0N/A {
0N/A // second, verify that window is located on the proper screen
0N/A Rectangle windowBounds = XlibUtil.getWindowGeometry(window);
0N/A if (windowLevel > 1)
0N/A {
0N/A windowBounds = XlibUtil.translateCoordinates(window, root, windowBounds);
0N/A }
0N/A // if _NET_WM_STRUT_PARTIAL is present, we should use its values to detect
0N/A // if the struts area intersects with screenBounds, however some window
0N/A // managers don't set this hint correctly, so we just get intersection with windowBounds
2447N/A if (windowBounds != null && windowBounds.intersects(screenBounds))
0N/A {
0N/A insets.left = Math.max((int)Native.getLong(native_ptr, 0), insets.left);
0N/A insets.right = Math.max((int)Native.getLong(native_ptr, 1), insets.right);
0N/A insets.top = Math.max((int)Native.getLong(native_ptr, 2), insets.top);
0N/A insets.bottom = Math.max((int)Native.getLong(native_ptr, 3), insets.bottom);
0N/A }
0N/A }
0N/A }
0N/A finally
0N/A {
0N/A XlibWrapper.unsafe.freeMemory(native_ptr);
0N/A }
0N/A
0N/A if (windowLevel < MAX_NESTED_LEVEL)
0N/A {
0N/A Set<Long> children = XlibUtil.getChildWindows(window);
0N/A for (long child : children)
0N/A {
0N/A search.add(child);
0N/A search.add(windowLevel + 1);
0N/A }
0N/A }
0N/A }
0N/A
0N/A return insets;
0N/A }
0N/A
0N/A /*
0N/A * The current implementation of disabling background erasing for
0N/A * canvases is that we don't set any native background color
0N/A * (with XSetWindowBackground) for the canvas window. However,
0N/A * this color is set in the peer constructor - see
0N/A * XWindow.postInit() for details. That's why this method from
0N/A * SunToolkit is not overridden in XToolkit: it's too late to
0N/A * disable background erasing :(
0N/A */
0N/A /*
0N/A @Override
0N/A public void disableBackgroundErase(Canvas canvas) {
0N/A XCanvasPeer peer = (XCanvasPeer)canvas.getPeer();
0N/A if (peer == null) {
0N/A throw new IllegalStateException("Canvas must have a valid peer");
0N/A }
0N/A peer.disableBackgroundErase();
0N/A }
0N/A */
0N/A
0N/A // Need this for XMenuItemPeer.
0N/A protected static final Object targetToPeer(Object target) {
0N/A Object p=null;
0N/A if (target != null && !GraphicsEnvironment.isHeadless()) {
0N/A p = specialPeerMap.get(target);
0N/A }
0N/A if (p != null) return p;
0N/A else
0N/A return SunToolkit.targetToPeer(target);
0N/A }
0N/A
0N/A // Need this for XMenuItemPeer.
0N/A protected static final void targetDisposedPeer(Object target, Object peer) {
0N/A SunToolkit.targetDisposedPeer(target, peer);
0N/A }
0N/A
0N/A public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
0N/A return new XRobotPeer(screen.getDefaultConfiguration());
0N/A }
0N/A
0N/A
0N/A /*
0N/A * On X, support for dynamic layout on resizing is governed by the
0N/A * window manager. If the window manager supports it, it happens
0N/A * automatically. The setter method for this property is
0N/A * irrelevant on X.
0N/A */
0N/A public void setDynamicLayout(boolean b) {
0N/A dynamicLayoutSetting = b;
0N/A }
0N/A
0N/A protected boolean isDynamicLayoutSet() {
0N/A return dynamicLayoutSetting;
0N/A }
0N/A
0N/A /* Called from isDynamicLayoutActive() and from
0N/A * lazilyLoadDynamicLayoutSupportedProperty()
0N/A */
0N/A protected boolean isDynamicLayoutSupported() {
0N/A return XWM.getWM().supportsDynamicLayout();
0N/A }
0N/A
0N/A public boolean isDynamicLayoutActive() {
0N/A return isDynamicLayoutSupported();
0N/A }
0N/A
0N/A
0N/A public FontPeer getFontPeer(String name, int style){
0N/A return new XFontPeer(name, style);
0N/A }
0N/A
0N/A public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
0N/A return XDragSourceContextPeer.createDragSourceContextPeer(dge);
0N/A }
0N/A
0N/A public <T extends DragGestureRecognizer> T
0N/A createDragGestureRecognizer(Class<T> recognizerClass,
0N/A DragSource ds,
0N/A Component c,
0N/A int srcActions,
0N/A DragGestureListener dgl)
0N/A {
0N/A if (MouseDragGestureRecognizer.class.equals(recognizerClass))
0N/A return (T)new XMouseDragGestureRecognizer(ds, c, srcActions, dgl);
0N/A else
0N/A return null;
0N/A }
0N/A
0N/A public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
0N/A XCheckboxMenuItemPeer peer = new XCheckboxMenuItemPeer(target);
0N/A //vb157120: looks like we don't need to map menu items
0N/A //in new menus implementation
0N/A //targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public MenuItemPeer createMenuItem(MenuItem target) {
0N/A XMenuItemPeer peer = new XMenuItemPeer(target);
0N/A //vb157120: looks like we don't need to map menu items
0N/A //in new menus implementation
0N/A //targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public TextFieldPeer createTextField(TextField target) {
0N/A TextFieldPeer peer = new XTextFieldPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public LabelPeer createLabel(Label target) {
0N/A LabelPeer peer = new XLabelPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public ListPeer createList(java.awt.List target) {
0N/A ListPeer peer = new XListPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public CheckboxPeer createCheckbox(Checkbox target) {
0N/A CheckboxPeer peer = new XCheckboxPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public ScrollbarPeer createScrollbar(Scrollbar target) {
0N/A XScrollbarPeer peer = new XScrollbarPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public ScrollPanePeer createScrollPane(ScrollPane target) {
0N/A XScrollPanePeer peer = new XScrollPanePeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public TextAreaPeer createTextArea(TextArea target) {
0N/A TextAreaPeer peer = new XTextAreaPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public ChoicePeer createChoice(Choice target) {
0N/A XChoicePeer peer = new XChoicePeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public CanvasPeer createCanvas(Canvas target) {
0N/A XCanvasPeer peer = (isXEmbedServerRequested() ? new XEmbedCanvasPeer(target) : new XCanvasPeer(target));
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public PanelPeer createPanel(Panel target) {
0N/A PanelPeer peer = new XPanelPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public WindowPeer createWindow(Window target) {
0N/A WindowPeer peer = new XWindowPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public DialogPeer createDialog(Dialog target) {
0N/A DialogPeer peer = new XDialogPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
2520N/A private static Boolean sunAwtDisableGtkFileDialogs = null;
2520N/A
2520N/A /**
2520N/A * Returns the value of "sun.awt.disableGtkFileDialogs" property. Default
2520N/A * value is {@code false}.
2520N/A */
2520N/A public synchronized static boolean getSunAwtDisableGtkFileDialogs() {
2520N/A if (sunAwtDisableGtkFileDialogs == null) {
5255N/A sunAwtDisableGtkFileDialogs = AccessController.doPrivileged(
5255N/A new GetBooleanAction("sun.awt.disableGtkFileDialogs"));
2520N/A }
2520N/A return sunAwtDisableGtkFileDialogs.booleanValue();
2520N/A }
2520N/A
0N/A public FileDialogPeer createFileDialog(FileDialog target) {
2520N/A FileDialogPeer peer = null;
2328N/A // The current GtkFileChooser is available from GTK+ 2.4
2520N/A if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) {
2520N/A peer = new GtkFileDialogPeer(target);
2520N/A } else {
2520N/A peer = new XFileDialogPeer(target);
2520N/A }
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public MenuBarPeer createMenuBar(MenuBar target) {
0N/A XMenuBarPeer peer = new XMenuBarPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public MenuPeer createMenu(Menu target) {
0N/A XMenuPeer peer = new XMenuPeer(target);
0N/A //vb157120: looks like we don't need to map menu items
0N/A //in new menus implementation
0N/A //targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public PopupMenuPeer createPopupMenu(PopupMenu target) {
0N/A XPopupMenuPeer peer = new XPopupMenuPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public synchronized MouseInfoPeer getMouseInfoPeer() {
0N/A if (xPeer == null) {
0N/A xPeer = new XMouseInfoPeer();
0N/A }
0N/A return xPeer;
0N/A }
0N/A
0N/A public XEmbeddedFramePeer createEmbeddedFrame(XEmbeddedFrame target)
0N/A {
0N/A XEmbeddedFramePeer peer = new XEmbeddedFramePeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A XEmbedChildProxyPeer createEmbedProxy(XEmbedChildProxy target) {
0N/A XEmbedChildProxyPeer peer = new XEmbedChildProxyPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
5336N/A public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
5336N/A return XKeyboardFocusManagerPeer.getInstance();
0N/A }
0N/A
0N/A /**
0N/A * Returns a new custom cursor.
0N/A */
0N/A public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
0N/A throws IndexOutOfBoundsException {
0N/A return new XCustomCursor(cursor, hotSpot, name);
0N/A }
0N/A
0N/A public TrayIconPeer createTrayIcon(TrayIcon target)
0N/A throws HeadlessException, AWTException
0N/A {
0N/A TrayIconPeer peer = new XTrayIconPeer(target);
0N/A targetCreatedPeer(target, peer);
0N/A return peer;
0N/A }
0N/A
0N/A public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException {
0N/A SystemTrayPeer peer = new XSystemTrayPeer(target);
0N/A return peer;
0N/A }
0N/A
0N/A public boolean isTraySupported() {
0N/A XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
0N/A if (peer != null) {
0N/A return peer.isAvailable();
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * Returns the supported cursor size
0N/A */
0N/A public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
0N/A return XCustomCursor.getBestCursorSize(
0N/A java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
0N/A }
0N/A
0N/A
0N/A public int getMaximumCursorColors() {
0N/A return 2; // Black and white.
0N/A }
0N/A
0N/A public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
0N/A return XInputMethod.mapInputMethodHighlight(highlight);
0N/A }
874N/A @Override
874N/A public boolean getLockingKeyState(int key) {
874N/A if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
874N/A key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
874N/A throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
874N/A }
874N/A awtLock();
874N/A try {
874N/A return getModifierState( key );
874N/A } finally {
874N/A awtUnlock();
874N/A }
874N/A }
0N/A
0N/A public Clipboard getSystemClipboard() {
0N/A SecurityManager security = System.getSecurityManager();
0N/A if (security != null) {
0N/A security.checkSystemClipboardAccess();
0N/A }
0N/A synchronized (this) {
0N/A if (clipboard == null) {
0N/A clipboard = new XClipboard("System", "CLIPBOARD");
0N/A }
0N/A }
0N/A return clipboard;
0N/A }
0N/A
0N/A public Clipboard getSystemSelection() {
0N/A SecurityManager security = System.getSecurityManager();
0N/A if (security != null) {
0N/A security.checkSystemClipboardAccess();
0N/A }
0N/A synchronized (this) {
0N/A if (selection == null) {
0N/A selection = new XClipboard("Selection", "PRIMARY");
0N/A }
0N/A }
0N/A return selection;
0N/A }
0N/A
0N/A public void beep() {
0N/A awtLock();
0N/A try {
0N/A XlibWrapper.XBell(getDisplay(), 0);
1337N/A XlibWrapper.XFlush(getDisplay());
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A public PrintJob getPrintJob(final Frame frame, final String doctitle,
0N/A final Properties props) {
0N/A
3821N/A if (frame == null) {
3821N/A throw new NullPointerException("frame must not be null");
0N/A }
0N/A
0N/A PrintJob2D printJob = new PrintJob2D(frame, doctitle, props);
0N/A
0N/A if (printJob.printDialog() == false) {
0N/A printJob = null;
0N/A }
0N/A return printJob;
0N/A }
0N/A
0N/A public PrintJob getPrintJob(final Frame frame, final String doctitle,
0N/A final JobAttributes jobAttributes,
3821N/A final PageAttributes pageAttributes)
3821N/A {
3821N/A if (frame == null) {
3821N/A throw new NullPointerException("frame must not be null");
0N/A }
0N/A
0N/A PrintJob2D printJob = new PrintJob2D(frame, doctitle,
0N/A jobAttributes, pageAttributes);
0N/A
0N/A if (printJob.printDialog() == false) {
0N/A printJob = null;
0N/A }
0N/A
0N/A return printJob;
0N/A }
0N/A
0N/A static void XSync() {
0N/A awtLock();
0N/A try {
0N/A XlibWrapper.XSync(getDisplay(),0);
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A public int getScreenResolution() {
0N/A long display = getDisplay();
0N/A awtLock();
0N/A try {
0N/A return (int) ((XlibWrapper.DisplayWidth(display,
0N/A XlibWrapper.DefaultScreen(display)) * 25.4) /
0N/A XlibWrapper.DisplayWidthMM(display,
0N/A XlibWrapper.DefaultScreen(display)));
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A static native long getDefaultXColormap();
0N/A static native long getDefaultScreenData();
0N/A
0N/A static ColorModel screenmodel;
0N/A
0N/A static ColorModel getStaticColorModel() {
0N/A if (screenmodel == null) {
0N/A screenmodel = config.getColorModel ();
0N/A }
0N/A return screenmodel;
0N/A }
0N/A
0N/A public ColorModel getColorModel() {
0N/A return getStaticColorModel();
0N/A }
0N/A
0N/A /**
0N/A * Returns a new input method adapter descriptor for native input methods.
0N/A */
0N/A public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
0N/A return new XInputMethodDescriptor();
0N/A }
0N/A
5527N/A /**
5527N/A * Returns whether enableInputMethods should be set to true for peered
5527N/A * TextComponent instances on this platform. True by default.
5527N/A */
5527N/A @Override
5527N/A public boolean enableInputMethodsForTextComponent() {
5527N/A return true;
5527N/A }
5527N/A
0N/A static int getMultiClickTime() {
0N/A if (awt_multiclick_time == 0) {
0N/A initializeMultiClickTime();
0N/A }
0N/A return awt_multiclick_time;
0N/A }
0N/A static void initializeMultiClickTime() {
0N/A awtLock();
0N/A try {
0N/A try {
0N/A String multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(), "*", "multiClickTime");
0N/A if (multiclick_time_query != null) {
0N/A awt_multiclick_time = (int)Long.parseLong(multiclick_time_query);
0N/A } else {
0N/A multiclick_time_query = XlibWrapper.XGetDefault(XToolkit.getDisplay(),
0N/A "OpenWindows", "MultiClickTimeout");
0N/A if (multiclick_time_query != null) {
0N/A /* Note: OpenWindows.MultiClickTimeout is in tenths of
0N/A a second, so we need to multiply by 100 to convert to
0N/A milliseconds */
0N/A awt_multiclick_time = (int)Long.parseLong(multiclick_time_query) * 100;
0N/A } else {
877N/A awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
0N/A }
0N/A }
0N/A } catch (NumberFormatException nf) {
877N/A awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
0N/A } catch (NullPointerException npe) {
877N/A awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A if (awt_multiclick_time == 0) {
877N/A awt_multiclick_time = AWT_MULTICLICK_DEFAULT_TIME;
0N/A }
0N/A }
0N/A
0N/A public boolean isFrameStateSupported(int state)
0N/A throws HeadlessException
0N/A {
0N/A if (state == Frame.NORMAL || state == Frame.ICONIFIED) {
0N/A return true;
0N/A } else {
0N/A return XWM.getWM().supportsExtendedState(state);
0N/A }
0N/A }
0N/A
0N/A static void dumpPeers() {
1696N/A if (log.isLoggable(PlatformLogger.FINE)) {
0N/A log.fine("Mapped windows:");
0N/A Iterator iter = winMap.entrySet().iterator();
0N/A while (iter.hasNext()) {
0N/A Map.Entry entry = (Map.Entry)iter.next();
0N/A log.fine(entry.getKey() + "->" + entry.getValue());
0N/A if (entry.getValue() instanceof XComponentPeer) {
0N/A Component target = (Component)((XComponentPeer)entry.getValue()).getTarget();
0N/A log.fine("\ttarget: " + target);
0N/A }
0N/A }
0N/A
0N/A SunToolkit.dumpPeers(log);
0N/A
0N/A log.fine("Mapped special peers:");
0N/A iter = specialPeerMap.entrySet().iterator();
0N/A while (iter.hasNext()) {
0N/A Map.Entry entry = (Map.Entry)iter.next();
0N/A log.fine(entry.getKey() + "->" + entry.getValue());
0N/A }
0N/A
0N/A log.fine("Mapped dispatchers:");
0N/A iter = winToDispatcher.entrySet().iterator();
0N/A while (iter.hasNext()) {
0N/A Map.Entry entry = (Map.Entry)iter.next();
0N/A log.fine(entry.getKey() + "->" + entry.getValue());
0N/A }
0N/A }
0N/A }
0N/A
0N/A /* Protected with awt_lock. */
0N/A private static boolean initialized;
0N/A private static boolean timeStampUpdated;
0N/A private static long timeStamp;
0N/A
0N/A private static final XEventDispatcher timeFetcher =
0N/A new XEventDispatcher() {
0N/A public void dispatchEvent(XEvent ev) {
0N/A switch (ev.get_type()) {
216N/A case XConstants.PropertyNotify:
0N/A XPropertyEvent xpe = ev.get_xproperty();
0N/A
0N/A awtLock();
0N/A try {
0N/A timeStamp = xpe.get_time();
0N/A timeStampUpdated = true;
0N/A awtLockNotifyAll();
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A
0N/A break;
0N/A }
0N/A }
0N/A };
0N/A
0N/A private static XAtom _XA_JAVA_TIME_PROPERTY_ATOM;
0N/A
0N/A static long getCurrentServerTime() {
0N/A awtLock();
0N/A try {
0N/A try {
0N/A if (!initialized) {
0N/A XToolkit.addEventDispatcher(XBaseWindow.getXAWTRootWindow().getWindow(),
0N/A timeFetcher);
0N/A _XA_JAVA_TIME_PROPERTY_ATOM = XAtom.get("_SUNW_JAVA_AWT_TIME");
0N/A initialized = true;
0N/A }
0N/A timeStampUpdated = false;
0N/A XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
0N/A XBaseWindow.getXAWTRootWindow().getWindow(),
0N/A _XA_JAVA_TIME_PROPERTY_ATOM.getAtom(), XAtom.XA_ATOM, 32,
216N/A XConstants.PropModeAppend,
0N/A 0, 0);
0N/A XlibWrapper.XFlush(XToolkit.getDisplay());
0N/A
0N/A if (isToolkitThread()) {
0N/A XEvent event = new XEvent();
0N/A try {
0N/A XlibWrapper.XWindowEvent(XToolkit.getDisplay(),
0N/A XBaseWindow.getXAWTRootWindow().getWindow(),
0N/A XConstants.PropertyChangeMask,
0N/A event.pData);
0N/A timeFetcher.dispatchEvent(event);
0N/A }
0N/A finally {
0N/A event.dispose();
0N/A }
0N/A }
0N/A else {
0N/A while (!timeStampUpdated) {
0N/A awtLockWait();
0N/A }
0N/A }
0N/A } catch (InterruptedException ie) {
0N/A // Note: the returned timeStamp can be incorrect in this case.
1696N/A if (log.isLoggable(PlatformLogger.FINE)) log.fine("Catched exception, timeStamp may not be correct (ie = " + ie + ")");
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A return timeStamp;
0N/A }
0N/A protected void initializeDesktopProperties() {
1338N/A desktopProperties.put("DnD.Autoscroll.initialDelay",
1338N/A Integer.valueOf(50));
1338N/A desktopProperties.put("DnD.Autoscroll.interval",
1338N/A Integer.valueOf(50));
1338N/A desktopProperties.put("DnD.Autoscroll.cursorHysteresis",
1338N/A Integer.valueOf(5));
1338N/A desktopProperties.put("Shell.shellFolderManager",
1338N/A "sun.awt.shell.ShellFolderManager");
0N/A // Don't want to call getMultiClickTime() if we are headless
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A desktopProperties.put("awt.multiClickInterval",
0N/A Integer.valueOf(getMultiClickTime()));
0N/A desktopProperties.put("awt.mouse.numButtons",
1224N/A Integer.valueOf(getNumberOfButtons()));
0N/A }
0N/A }
0N/A
1224N/A /**
1224N/A * This method runs through the XPointer and XExtendedPointer array.
1224N/A * XExtendedPointer has priority because on some systems XPointer
1224N/A * (which is assigned to the virtual pointer) reports the maximum
1224N/A * capabilities of the mouse pointer (i.e. 32 physical buttons).
1224N/A */
1981N/A private native int getNumberOfButtonsImpl();
1224N/A
1224N/A @Override
1224N/A public int getNumberOfButtons(){
0N/A awtLock();
0N/A try {
875N/A if (numberOfButtons == 0) {
1224N/A numberOfButtons = getNumberOfButtonsImpl();
2773N/A numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
2773N/A //4th and 5th buttons are for wheel and shouldn't be reported as buttons.
2773N/A //If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
2773N/A //If we have 3 physical buttons and a wheel, we report 3 buttons.
2773N/A //If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
2773N/A if (numberOfButtons >=5) {
2773N/A numberOfButtons -= 2;
2773N/A } else if (numberOfButtons == 4 || numberOfButtons ==5){
2773N/A numberOfButtons = 3;
2773N/A }
875N/A }
2773N/A //Assume don't have to re-query the number again and again.
2773N/A return numberOfButtons;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A private final static String prefix = "DnD.Cursor.";
0N/A private final static String postfix = ".32x32";
0N/A private static final String dndPrefix = "DnD.";
0N/A
0N/A protected Object lazilyLoadDesktopProperty(String name) {
0N/A if (name.startsWith(prefix)) {
0N/A String cursorName = name.substring(prefix.length(), name.length()) + postfix;
0N/A
0N/A try {
0N/A return Cursor.getSystemCustomCursor(cursorName);
0N/A } catch (AWTException awte) {
0N/A throw new RuntimeException("cannot load system cursor: " + cursorName, awte);
0N/A }
0N/A }
0N/A
0N/A if (name.equals("awt.dynamicLayoutSupported")) {
0N/A return Boolean.valueOf(isDynamicLayoutSupported());
0N/A }
0N/A
0N/A if (initXSettingsIfNeeded(name)) {
0N/A return desktopProperties.get(name);
0N/A }
0N/A
0N/A return super.lazilyLoadDesktopProperty(name);
0N/A }
0N/A
0N/A public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
4363N/A if (name == null) {
4363N/A // See JavaDoc for the Toolkit.addPropertyChangeListener() method
4363N/A return;
4363N/A }
0N/A initXSettingsIfNeeded(name);
0N/A super.addPropertyChangeListener(name, pcl);
0N/A }
0N/A
0N/A /**
0N/A * Initializes XAWTXSettings if a property for a given property name is provided by
0N/A * XSettings and they are not initialized yet.
0N/A *
0N/A * @return true if the method has initialized XAWTXSettings.
0N/A */
0N/A private boolean initXSettingsIfNeeded(final String propName) {
0N/A if (!loadedXSettings &&
0N/A (propName.startsWith("gnome.") ||
0N/A propName.equals(SunToolkit.DESKTOPFONTHINTS) ||
0N/A propName.startsWith(dndPrefix)))
0N/A {
0N/A loadedXSettings = true;
0N/A if (!GraphicsEnvironment.isHeadless()) {
0N/A loadXSettings();
0N/A /* If no desktop font hint could be retrieved, check for
0N/A * KDE running KWin and retrieve settings from fontconfig.
0N/A * If that isn't found let SunToolkit will see if there's a
0N/A * system property set by a user.
0N/A */
0N/A if (desktopProperties.get(SunToolkit.DESKTOPFONTHINTS) == null) {
0N/A if (XWM.isKDE2()) {
1686N/A Object hint = fcManager.getFontConfigAAHint();
0N/A if (hint != null) {
0N/A /* set the fontconfig/KDE property so that
0N/A * getDesktopHints() below will see it
0N/A * and set the public property.
0N/A */
0N/A desktopProperties.put(UNIXToolkit.FONTCONFIGAAHINT,
0N/A hint);
0N/A }
0N/A }
0N/A desktopProperties.put(SunToolkit.DESKTOPFONTHINTS,
0N/A SunToolkit.getDesktopFontHints());
0N/A }
0N/A
0N/A return true;
0N/A }
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A private void loadXSettings() {
0N/A xs = new XAWTXSettings();
0N/A }
0N/A
0N/A /**
0N/A * Callback from the native side indicating some, or all, of the
0N/A * desktop properties have changed and need to be reloaded.
0N/A * <code>data</code> is the byte array directly from the x server and
0N/A * may be in little endian format.
0N/A * <p>
0N/A * NB: This could be called from any thread if triggered by
0N/A * <code>loadXSettings</code>. It is called from the System EDT
0N/A * if triggered by an XSETTINGS change.
0N/A */
0N/A void parseXSettings(int screen_XXX_ignored,Map updatedSettings) {
0N/A
0N/A if (updatedSettings == null || updatedSettings.isEmpty()) {
0N/A return;
0N/A }
0N/A
0N/A Iterator i = updatedSettings.entrySet().iterator();
0N/A while (i.hasNext()) {
0N/A Map.Entry e = (Map.Entry)i.next();
0N/A String name = (String)e.getKey();
0N/A
0N/A name = "gnome." + name;
0N/A setDesktopProperty(name, e.getValue());
0N/A log.fine("name = " + name + " value = " + e.getValue());
0N/A
0N/A // XXX: we probably want to do something smarter. In
0N/A // particular, "Net" properties are of interest to the
0N/A // "core" AWT itself. E.g.
0N/A //
0N/A // Net/DndDragThreshold -> ???
0N/A // Net/DoubleClickTime -> awt.multiClickInterval
0N/A }
0N/A
0N/A setDesktopProperty(SunToolkit.DESKTOPFONTHINTS,
0N/A SunToolkit.getDesktopFontHints());
0N/A
0N/A Integer dragThreshold = null;
0N/A synchronized (this) {
0N/A dragThreshold = (Integer)desktopProperties.get("gnome.Net/DndDragThreshold");
0N/A }
0N/A if (dragThreshold != null) {
0N/A setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold);
0N/A }
0N/A
0N/A }
0N/A
0N/A
0N/A
0N/A static int altMask;
0N/A static int metaMask;
0N/A static int numLockMask;
0N/A static int modeSwitchMask;
0N/A static int modLockIsShiftLock;
0N/A
0N/A /* Like XKeysymToKeycode, but ensures that keysym is the primary
0N/A * symbol on the keycode returned. Returns zero otherwise.
0N/A */
0N/A static int keysymToPrimaryKeycode(long sym) {
0N/A awtLock();
0N/A try {
0N/A int code = XlibWrapper.XKeysymToKeycode(getDisplay(), sym);
0N/A if (code == 0) {
0N/A return 0;
0N/A }
0N/A long primary = XlibWrapper.XKeycodeToKeysym(getDisplay(), code, 0);
0N/A if (sym != primary) {
0N/A return 0;
0N/A }
0N/A return code;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
874N/A static boolean getModifierState( int jkc ) {
874N/A int iKeyMask = 0;
874N/A long ks = XKeysym.javaKeycode2Keysym( jkc );
874N/A int kc = XlibWrapper.XKeysymToKeycode(getDisplay(), ks);
874N/A if (kc == 0) {
874N/A return false;
874N/A }
874N/A awtLock();
874N/A try {
874N/A XModifierKeymap modmap = new XModifierKeymap(
874N/A XlibWrapper.XGetModifierMapping(getDisplay()));
874N/A
874N/A int nkeys = modmap.get_max_keypermod();
874N/A
874N/A long map_ptr = modmap.get_modifiermap();
874N/A for( int k = 0; k < 8; k++ ) {
874N/A for (int i = 0; i < nkeys; ++i) {
874N/A int keycode = Native.getUByte(map_ptr, k * nkeys + i);
874N/A if (keycode == 0) {
874N/A continue; // ignore zero keycode
874N/A }
874N/A if (kc == keycode) {
874N/A iKeyMask = 1 << k;
874N/A break;
874N/A }
874N/A }
874N/A if( iKeyMask != 0 ) {
874N/A break;
874N/A }
874N/A }
874N/A XlibWrapper.XFreeModifiermap(modmap.pData);
874N/A if (iKeyMask == 0 ) {
874N/A return false;
874N/A }
874N/A // Now we know to which modifier is assigned the keycode
874N/A // correspondent to the keysym correspondent to the java
874N/A // keycode. We are going to check a state of this modifier.
874N/A // If a modifier is a weird one, we cannot help it.
874N/A long window = 0;
874N/A try{
874N/A // get any application window
874N/A window = ((Long)(winMap.firstKey())).longValue();
874N/A }catch(NoSuchElementException nex) {
874N/A // get root window
874N/A window = getDefaultRootWindow();
874N/A }
874N/A boolean res = XlibWrapper.XQueryPointer(getDisplay(), window,
874N/A XlibWrapper.larg1, //root
874N/A XlibWrapper.larg2, //child
874N/A XlibWrapper.larg3, //root_x
874N/A XlibWrapper.larg4, //root_y
874N/A XlibWrapper.larg5, //child_x
874N/A XlibWrapper.larg6, //child_y
874N/A XlibWrapper.larg7);//mask
874N/A int mask = Native.getInt(XlibWrapper.larg7);
874N/A return ((mask & iKeyMask) != 0);
874N/A } finally {
874N/A awtUnlock();
874N/A }
874N/A }
0N/A
0N/A /* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
0N/A * Only consider primary symbols on keycodes attached to modifiers.
0N/A */
0N/A static void setupModifierMap() {
0N/A final int metaL = keysymToPrimaryKeycode(XKeySymConstants.XK_Meta_L);
0N/A final int metaR = keysymToPrimaryKeycode(XKeySymConstants.XK_Meta_R);
0N/A final int altL = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_L);
0N/A final int altR = keysymToPrimaryKeycode(XKeySymConstants.XK_Alt_R);
0N/A final int numLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Num_Lock);
0N/A final int modeSwitch = keysymToPrimaryKeycode(XKeySymConstants.XK_Mode_switch);
0N/A final int shiftLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Shift_Lock);
0N/A final int capsLock = keysymToPrimaryKeycode(XKeySymConstants.XK_Caps_Lock);
0N/A
216N/A final int modmask[] = { XConstants.ShiftMask, XConstants.LockMask, XConstants.ControlMask, XConstants.Mod1Mask,
216N/A XConstants.Mod2Mask, XConstants.Mod3Mask, XConstants.Mod4Mask, XConstants.Mod5Mask };
0N/A
0N/A log.fine("In setupModifierMap");
0N/A awtLock();
0N/A try {
0N/A XModifierKeymap modmap = new XModifierKeymap(
0N/A XlibWrapper.XGetModifierMapping(getDisplay()));
0N/A
0N/A int nkeys = modmap.get_max_keypermod();
0N/A
0N/A long map_ptr = modmap.get_modifiermap();
0N/A
0N/A for (int modn = XConstants.Mod1MapIndex;
0N/A modn <= XConstants.Mod5MapIndex;
0N/A ++modn)
0N/A {
0N/A for (int i = 0; i < nkeys; ++i) {
0N/A /* for each keycode attached to this modifier */
0N/A int keycode = Native.getUByte(map_ptr, modn * nkeys + i);
0N/A
0N/A if (keycode == 0) {
0N/A break;
0N/A }
0N/A if (metaMask == 0 &&
0N/A (keycode == metaL || keycode == metaR))
0N/A {
0N/A metaMask = modmask[modn];
0N/A break;
0N/A }
0N/A if (altMask == 0 && (keycode == altL || keycode == altR)) {
0N/A altMask = modmask[modn];
0N/A break;
0N/A }
0N/A if (numLockMask == 0 && keycode == numLock) {
0N/A numLockMask = modmask[modn];
0N/A break;
0N/A }
0N/A if (modeSwitchMask == 0 && keycode == modeSwitch) {
0N/A modeSwitchMask = modmask[modn];
0N/A break;
0N/A }
0N/A continue;
0N/A }
0N/A }
0N/A modLockIsShiftLock = 0;
0N/A for (int j = 0; j < nkeys; ++j) {
0N/A int keycode = Native.getUByte(map_ptr, XConstants.LockMapIndex * nkeys + j);
0N/A if (keycode == 0) {
0N/A break;
0N/A }
0N/A if (keycode == shiftLock) {
0N/A modLockIsShiftLock = 1;
0N/A break;
0N/A }
0N/A if (keycode == capsLock) {
0N/A break;
0N/A }
0N/A }
0N/A XlibWrapper.XFreeModifiermap(modmap.pData);
0N/A } finally {
0N/A awtUnlock();
0N/A }
1696N/A if (log.isLoggable(PlatformLogger.FINE)) {
0N/A log.fine("metaMask = " + metaMask);
0N/A log.fine("altMask = " + altMask);
0N/A log.fine("numLockMask = " + numLockMask);
0N/A log.fine("modeSwitchMask = " + modeSwitchMask);
0N/A log.fine("modLockIsShiftLock = " + modLockIsShiftLock);
0N/A }
0N/A }
0N/A
0N/A
0N/A private static SortedMap timeoutTasks;
0N/A
0N/A /**
0N/A * Removed the task from the list of waiting-to-be called tasks.
0N/A * If the task has been scheduled several times removes only first one.
0N/A */
0N/A static void remove(Runnable task) {
0N/A if (task == null) {
0N/A throw new NullPointerException("task is null");
0N/A }
0N/A awtLock();
0N/A try {
1696N/A if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) {
0N/A timeoutTaskLog.finer("Removing task " + task);
0N/A }
0N/A if (timeoutTasks == null) {
1696N/A if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) {
0N/A timeoutTaskLog.finer("Task is not scheduled");
0N/A }
0N/A return;
0N/A }
0N/A Collection values = timeoutTasks.values();
0N/A Iterator iter = values.iterator();
0N/A while (iter.hasNext()) {
0N/A java.util.List list = (java.util.List)iter.next();
0N/A boolean removed = false;
0N/A if (list.contains(task)) {
0N/A list.remove(task);
0N/A if (list.isEmpty()) {
0N/A iter.remove();
0N/A }
0N/A break;
0N/A }
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A static native void wakeup_poll();
0N/A
0N/A /**
0N/A * Registers a Runnable which <code>run()</code> method will be called
0N/A * once on the toolkit thread when a specified interval of time elapses.
0N/A *
0N/A * @param task a Runnable which <code>run</code> method will be called
0N/A * on the toolkit thread when <code>interval</code> milliseconds
0N/A * elapse
0N/A * @param interval an interal in milliseconds
0N/A *
0N/A * @throws NullPointerException if <code>task</code> is <code>null</code>
0N/A * @throws IllegalArgumentException if <code>interval</code> is not positive
0N/A */
0N/A static void schedule(Runnable task, long interval) {
0N/A if (task == null) {
0N/A throw new NullPointerException("task is null");
0N/A }
0N/A if (interval <= 0) {
0N/A throw new IllegalArgumentException("interval " + interval + " is not positive");
0N/A }
0N/A
0N/A awtLock();
0N/A try {
1696N/A if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) {
1696N/A timeoutTaskLog.finer("XToolkit.schedule(): current time={0}" +
1696N/A "; interval={1}" +
1696N/A "; task being added={2}" + "; tasks before addition={3}",
1696N/A Long.valueOf(System.currentTimeMillis()), Long.valueOf(interval), task, timeoutTasks);
0N/A }
0N/A
0N/A if (timeoutTasks == null) {
0N/A timeoutTasks = new TreeMap();
0N/A }
0N/A
0N/A Long time = Long.valueOf(System.currentTimeMillis() + interval);
0N/A java.util.List tasks = (java.util.List)timeoutTasks.get(time);
0N/A if (tasks == null) {
0N/A tasks = new ArrayList(1);
0N/A timeoutTasks.put(time, tasks);
0N/A }
0N/A tasks.add(task);
0N/A
0N/A
0N/A if (timeoutTasks.get(timeoutTasks.firstKey()) == tasks && tasks.size() == 1) {
0N/A // Added task became first task - poll won't know
0N/A // about it so we need to wake it up
0N/A wakeup_poll();
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A private long getNextTaskTime() {
0N/A awtLock();
0N/A try {
0N/A if (timeoutTasks == null || timeoutTasks.isEmpty()) {
0N/A return -1L;
0N/A }
0N/A return (Long)timeoutTasks.firstKey();
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Executes mature timeout tasks registered with schedule().
0N/A * Called from run() under awtLock.
0N/A */
0N/A private static void callTimeoutTasks() {
1696N/A if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) {
1696N/A timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" +
1696N/A "; tasks={1}", Long.valueOf(System.currentTimeMillis()), timeoutTasks);
0N/A }
0N/A
0N/A if (timeoutTasks == null || timeoutTasks.isEmpty()) {
0N/A return;
0N/A }
0N/A
0N/A Long currentTime = Long.valueOf(System.currentTimeMillis());
0N/A Long time = (Long)timeoutTasks.firstKey();
0N/A
0N/A while (time.compareTo(currentTime) <= 0) {
0N/A java.util.List tasks = (java.util.List)timeoutTasks.remove(time);
0N/A
0N/A for (Iterator iter = tasks.iterator(); iter.hasNext();) {
0N/A Runnable task = (Runnable)iter.next();
0N/A
1696N/A if (timeoutTaskLog.isLoggable(PlatformLogger.FINER)) {
1696N/A timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" +
1696N/A "; about to run task={1}", Long.valueOf(currentTime), task);
0N/A }
0N/A
0N/A try {
0N/A task.run();
0N/A } catch (ThreadDeath td) {
0N/A throw td;
0N/A } catch (Throwable thr) {
0N/A processException(thr);
0N/A }
0N/A }
0N/A
0N/A if (timeoutTasks.isEmpty()) {
0N/A break;
0N/A }
0N/A time = (Long)timeoutTasks.firstKey();
0N/A }
0N/A }
0N/A
0N/A static long getAwtDefaultFg() {
0N/A return awt_defaultFg;
0N/A }
0N/A
0N/A static boolean isLeftMouseButton(MouseEvent me) {
0N/A switch (me.getID()) {
0N/A case MouseEvent.MOUSE_PRESSED:
0N/A case MouseEvent.MOUSE_RELEASED:
0N/A return (me.getButton() == MouseEvent.BUTTON1);
0N/A case MouseEvent.MOUSE_ENTERED:
0N/A case MouseEvent.MOUSE_EXITED:
0N/A case MouseEvent.MOUSE_CLICKED:
0N/A case MouseEvent.MOUSE_DRAGGED:
0N/A return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0);
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A static boolean isRightMouseButton(MouseEvent me) {
0N/A int numButtons = ((Integer)getDefaultToolkit().getDesktopProperty("awt.mouse.numButtons")).intValue();
0N/A switch (me.getID()) {
0N/A case MouseEvent.MOUSE_PRESSED:
0N/A case MouseEvent.MOUSE_RELEASED:
0N/A return ((numButtons == 2 && me.getButton() == MouseEvent.BUTTON2) ||
0N/A (numButtons > 2 && me.getButton() == MouseEvent.BUTTON3));
0N/A case MouseEvent.MOUSE_ENTERED:
0N/A case MouseEvent.MOUSE_EXITED:
0N/A case MouseEvent.MOUSE_CLICKED:
0N/A case MouseEvent.MOUSE_DRAGGED:
0N/A return ((numButtons == 2 && (me.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0) ||
0N/A (numButtons > 2 && (me.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0));
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A static long reset_time_utc;
2445N/A static final long WRAP_TIME_MILLIS = 0x00000000FFFFFFFFL;
0N/A
0N/A /*
0N/A * This function converts between the X server time (number of milliseconds
0N/A * since the last server reset) and the UTC time for the 'when' field of an
0N/A * InputEvent (or another event type with a timestamp).
0N/A */
0N/A static long nowMillisUTC_offset(long server_offset) {
0N/A // ported from awt_util.c
0N/A /*
0N/A * Because Time is of type 'unsigned long', it is possible that Time will
0N/A * never wrap when using 64-bit Xlib. However, if a 64-bit client
0N/A * connects to a 32-bit server, I suspect the values will still wrap. So
0N/A * we should not attempt to remove the wrap checking even if _LP64 is
0N/A * true.
0N/A */
0N/A
0N/A long current_time_utc = System.currentTimeMillis();
1696N/A if (log.isLoggable(PlatformLogger.FINER)) {
0N/A log.finer("reset_time=" + reset_time_utc + ", current_time=" + current_time_utc
0N/A + ", server_offset=" + server_offset + ", wrap_time=" + WRAP_TIME_MILLIS);
0N/A }
0N/A
0N/A if ((current_time_utc - reset_time_utc) > WRAP_TIME_MILLIS) {
0N/A reset_time_utc = System.currentTimeMillis() - getCurrentServerTime();
0N/A }
0N/A
1696N/A if (log.isLoggable(PlatformLogger.FINER)) {
0N/A log.finer("result = " + (reset_time_utc + server_offset));
0N/A }
0N/A return reset_time_utc + server_offset;
0N/A }
0N/A
0N/A /**
0N/A * @see sun.awt.SunToolkit#needsXEmbedImpl
0N/A */
0N/A protected boolean needsXEmbedImpl() {
0N/A // XToolkit implements supports for XEmbed-client protocol and
0N/A // requires the supports from the embedding host for it to work.
0N/A return true;
0N/A }
0N/A
0N/A public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
0N/A return (modalityType == null) ||
0N/A (modalityType == Dialog.ModalityType.MODELESS) ||
0N/A (modalityType == Dialog.ModalityType.DOCUMENT_MODAL) ||
0N/A (modalityType == Dialog.ModalityType.APPLICATION_MODAL) ||
0N/A (modalityType == Dialog.ModalityType.TOOLKIT_MODAL);
0N/A }
0N/A
0N/A public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
0N/A return (exclusionType == null) ||
0N/A (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
0N/A (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) ||
0N/A (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
0N/A }
0N/A
0N/A static EventQueue getEventQueue(Object target) {
0N/A AppContext appContext = targetToAppContext(target);
0N/A if (appContext != null) {
0N/A return (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
0N/A }
0N/A return null;
0N/A }
0N/A
5255N/A static void removeSourceEvents(EventQueue queue,
5255N/A Object source,
5255N/A boolean removeAllEvents) {
5255N/A AWTAccessor.getEventQueueAccessor()
5255N/A .removeSourceEvents(queue, source, removeAllEvents);
0N/A }
0N/A
0N/A public boolean isAlwaysOnTopSupported() {
84N/A for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) {
0N/A if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) {
0N/A return true;
0N/A }
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A public boolean useBufferPerWindow() {
0N/A return XToolkit.getBackingStoreType() == XConstants.NotUseful;
0N/A }
0N/A
0N/A /**
0N/A * Returns one of XConstants: NotUseful, WhenMapped or Always.
0N/A * If backing store is not available on at least one screen, or
0N/A * java2d uses DGA(which conflicts with backing store) on at least one screen,
0N/A * or the string system property "sun.awt.backingStore" is neither "Always"
0N/A * nor "WhenMapped", then the method returns XConstants.NotUseful.
0N/A * Otherwise, if the system property "sun.awt.backingStore" is "WhenMapped",
0N/A * then the method returns XConstants.WhenMapped.
0N/A * Otherwise (i.e., if the system property "sun.awt.backingStore" is "Always"),
0N/A * the method returns XConstants.Always.
0N/A */
0N/A static int getBackingStoreType() {
0N/A return backingStoreType;
0N/A }
0N/A
0N/A private static void setBackingStoreType() {
0N/A String prop = (String)AccessController.doPrivileged(
0N/A new sun.security.action.GetPropertyAction("sun.awt.backingStore"));
0N/A
0N/A if (prop == null) {
0N/A backingStoreType = XConstants.NotUseful;
1696N/A if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) {
0N/A backingStoreLog.config("The system property sun.awt.backingStore is not set" +
0N/A ", by default backingStore=NotUseful");
0N/A }
0N/A return;
0N/A }
0N/A
1696N/A if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) {
0N/A backingStoreLog.config("The system property sun.awt.backingStore is " + prop);
0N/A }
0N/A prop = prop.toLowerCase();
0N/A if (prop.equals("always")) {
0N/A backingStoreType = XConstants.Always;
0N/A } else if (prop.equals("whenmapped")) {
0N/A backingStoreType = XConstants.WhenMapped;
0N/A } else {
0N/A backingStoreType = XConstants.NotUseful;
0N/A }
0N/A
1696N/A if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) {
0N/A backingStoreLog.config("backingStore(as provided by the system property)=" +
0N/A ( backingStoreType == XConstants.NotUseful ? "NotUseful"
0N/A : backingStoreType == XConstants.WhenMapped ?
0N/A "WhenMapped" : "Always") );
0N/A }
0N/A
0N/A if (sun.java2d.x11.X11SurfaceData.isDgaAvailable()) {
0N/A backingStoreType = XConstants.NotUseful;
0N/A
1696N/A if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) {
0N/A backingStoreLog.config("DGA is available, backingStore=NotUseful");
0N/A }
0N/A
0N/A return;
0N/A }
0N/A
0N/A awtLock();
0N/A try {
0N/A int screenCount = XlibWrapper.ScreenCount(getDisplay());
0N/A for (int i = 0; i < screenCount; i++) {
0N/A if (XlibWrapper.DoesBackingStore(XlibWrapper.ScreenOfDisplay(getDisplay(), i))
0N/A == XConstants.NotUseful) {
0N/A backingStoreType = XConstants.NotUseful;
0N/A
1696N/A if (backingStoreLog.isLoggable(PlatformLogger.CONFIG)) {
0N/A backingStoreLog.config("Backing store is not available on the screen " +
0N/A i + ", backingStore=NotUseful");
0N/A }
0N/A
0N/A return;
0N/A }
0N/A }
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * One of XConstants: NotUseful, WhenMapped or Always.
0N/A */
0N/A private static int backingStoreType;
0N/A
1342N/A static final int XSUN_KP_BEHAVIOR = 1;
1342N/A static final int XORG_KP_BEHAVIOR = 2;
1975N/A static final int IS_SUN_KEYBOARD = 1;
1975N/A static final int IS_NONSUN_KEYBOARD = 2;
1975N/A static final int IS_KANA_KEYBOARD = 1;
1975N/A static final int IS_NONKANA_KEYBOARD = 2;
1975N/A
1342N/A
1342N/A static int awt_IsXsunKPBehavior = 0;
0N/A static boolean awt_UseXKB = false;
1067N/A static boolean awt_UseXKB_Calls = false;
1067N/A static int awt_XKBBaseEventCode = 0;
1067N/A static int awt_XKBEffectiveGroup = 0; // so far, I don't use it leaving all calculations
1067N/A // to XkbTranslateKeyCode
1067N/A static long awt_XKBDescPtr = 0;
1342N/A
0N/A /**
1342N/A * Check for Xsun convention regarding numpad keys.
1342N/A * Xsun and some other servers (i.e. derived from Xsun)
1342N/A * under certain conditions process numpad keys unlike Xorg.
1342N/A */
1342N/A static boolean isXsunKPBehavior() {
0N/A awtLock();
0N/A try {
1342N/A if( awt_IsXsunKPBehavior == 0 ) {
1342N/A if( XlibWrapper.IsXsunKPBehavior(getDisplay()) ) {
1342N/A awt_IsXsunKPBehavior = XSUN_KP_BEHAVIOR;
1342N/A }else{
1342N/A awt_IsXsunKPBehavior = XORG_KP_BEHAVIOR;
1342N/A }
0N/A }
1342N/A return awt_IsXsunKPBehavior == XSUN_KP_BEHAVIOR ? true : false;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
1975N/A
1975N/A static int sunOrNotKeyboard = 0;
1975N/A static int kanaOrNotKeyboard = 0;
1975N/A static void resetKeyboardSniffer() {
1975N/A sunOrNotKeyboard = 0;
1975N/A kanaOrNotKeyboard = 0;
1975N/A }
1975N/A static boolean isSunKeyboard() {
1975N/A if( sunOrNotKeyboard == 0 ) {
1975N/A if( XlibWrapper.IsSunKeyboard( getDisplay() )) {
1975N/A sunOrNotKeyboard = IS_SUN_KEYBOARD;
1975N/A }else{
1975N/A sunOrNotKeyboard = IS_NONSUN_KEYBOARD;
1975N/A }
1975N/A }
1975N/A return (sunOrNotKeyboard == IS_SUN_KEYBOARD);
1975N/A }
1975N/A static boolean isKanaKeyboard() {
1975N/A if( kanaOrNotKeyboard == 0 ) {
1975N/A if( XlibWrapper.IsKanaKeyboard( getDisplay() )) {
1975N/A kanaOrNotKeyboard = IS_KANA_KEYBOARD;
1975N/A }else{
1975N/A kanaOrNotKeyboard = IS_NONKANA_KEYBOARD;
1975N/A }
1975N/A }
1975N/A return (kanaOrNotKeyboard == IS_KANA_KEYBOARD);
1975N/A }
0N/A static boolean isXKBenabled() {
0N/A awtLock();
0N/A try {
1067N/A return awt_UseXKB;
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A
1067N/A /**
1067N/A Query XKEYBOARD extension.
1067N/A If possible, initialize xkb library.
1067N/A */
1067N/A static boolean tryXKB() {
1067N/A awtLock();
1067N/A try {
1067N/A String name = "XKEYBOARD";
1067N/A // First, if there is extension at all.
1067N/A awt_UseXKB = XlibWrapper.XQueryExtension( getDisplay(), name, XlibWrapper.larg1, XlibWrapper.larg2, XlibWrapper.larg3);
1067N/A if( awt_UseXKB ) {
1067N/A // There is a keyboard extension. Check if a client library is compatible.
1067N/A // If not, don't use xkb calls.
1067N/A // In this case we still may be Xkb-capable application.
1067N/A awt_UseXKB_Calls = XlibWrapper.XkbLibraryVersion( XlibWrapper.larg1, XlibWrapper.larg2);
1067N/A if( awt_UseXKB_Calls ) {
1067N/A awt_UseXKB_Calls = XlibWrapper.XkbQueryExtension( getDisplay(), XlibWrapper.larg1, XlibWrapper.larg2,
1067N/A XlibWrapper.larg3, XlibWrapper.larg4, XlibWrapper.larg5);
1067N/A if( awt_UseXKB_Calls ) {
1067N/A awt_XKBBaseEventCode = Native.getInt(XlibWrapper.larg2);
1067N/A XlibWrapper.XkbSelectEvents (getDisplay(),
1067N/A XConstants.XkbUseCoreKbd,
1067N/A XConstants.XkbNewKeyboardNotifyMask |
1067N/A XConstants.XkbMapNotifyMask ,//|
1067N/A //XConstants.XkbStateNotifyMask,
1067N/A XConstants.XkbNewKeyboardNotifyMask |
1067N/A XConstants.XkbMapNotifyMask );//|
1067N/A //XConstants.XkbStateNotifyMask);
1067N/A
1067N/A XlibWrapper.XkbSelectEventDetails(getDisplay(), XConstants.XkbUseCoreKbd,
1067N/A XConstants.XkbStateNotify,
1067N/A XConstants.XkbGroupStateMask,
1067N/A XConstants.XkbGroupStateMask);
1067N/A //XXX ? XkbGroupLockMask last, XkbAllStateComponentsMask before last?
1067N/A awt_XKBDescPtr = XlibWrapper.XkbGetMap(getDisplay(),
1067N/A XConstants.XkbKeyTypesMask |
1067N/A XConstants.XkbKeySymsMask |
1067N/A XConstants.XkbModifierMapMask |
1067N/A XConstants.XkbVirtualModsMask,
1067N/A XConstants.XkbUseCoreKbd);
1067N/A }
1067N/A }
0N/A }
0N/A return awt_UseXKB;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
1067N/A static boolean canUseXKBCalls() {
1067N/A awtLock();
1067N/A try {
1067N/A return awt_UseXKB_Calls;
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A static int getXKBEffectiveGroup() {
1067N/A awtLock();
1067N/A try {
1067N/A return awt_XKBEffectiveGroup;
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A static int getXKBBaseEventCode() {
1067N/A awtLock();
1067N/A try {
1067N/A return awt_XKBBaseEventCode;
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A static long getXKBKbdDesc() {
1067N/A awtLock();
1067N/A try {
1067N/A return awt_XKBDescPtr;
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A void freeXKB() {
1067N/A awtLock();
1067N/A try {
1067N/A if (awt_UseXKB_Calls && awt_XKBDescPtr != 0) {
1067N/A XlibWrapper.XkbFreeKeyboard(awt_XKBDescPtr, 0xFF, true);
1217N/A awt_XKBDescPtr = 0;
1067N/A }
1067N/A } finally {
1067N/A awtUnlock();
1067N/A }
1067N/A }
1067N/A private void processXkbChanges(XEvent ev) {
1067N/A // mapping change --> refresh kbd map
1067N/A // state change --> get a new effective group; do I really need it
1067N/A // or that should be left for XkbTranslateKeyCode?
1067N/A XkbEvent xke = new XkbEvent( ev.getPData() );
1067N/A int xkb_type = xke.get_any().get_xkb_type();
1067N/A switch( xkb_type ) {
1067N/A case XConstants.XkbNewKeyboardNotify :
1067N/A if( awt_XKBDescPtr != 0 ) {
1067N/A freeXKB();
1067N/A }
1067N/A awt_XKBDescPtr = XlibWrapper.XkbGetMap(getDisplay(),
1067N/A XConstants.XkbKeyTypesMask |
1067N/A XConstants.XkbKeySymsMask |
1067N/A XConstants.XkbModifierMapMask |
1067N/A XConstants.XkbVirtualModsMask,
1067N/A XConstants.XkbUseCoreKbd);
1067N/A //System.out.println("XkbNewKeyboard:"+(xke.get_new_kbd()));
1067N/A break;
1067N/A case XConstants.XkbMapNotify :
1067N/A //TODO: provide a simple unit test.
1067N/A XlibWrapper.XkbGetUpdatedMap(getDisplay(),
1067N/A XConstants.XkbKeyTypesMask |
1067N/A XConstants.XkbKeySymsMask |
1067N/A XConstants.XkbModifierMapMask |
1067N/A XConstants.XkbVirtualModsMask,
1067N/A awt_XKBDescPtr);
1067N/A //System.out.println("XkbMap:"+(xke.get_map()));
1067N/A break;
1067N/A case XConstants.XkbStateNotify :
1067N/A // May use it later e.g. to obtain an effective group etc.
1067N/A //System.out.println("XkbState:"+(xke.get_state()));
1067N/A break;
1067N/A default:
1067N/A //System.out.println("XkbEvent of xkb_type "+xkb_type);
1067N/A break;
1067N/A }
1067N/A }
0N/A
0N/A private static long eventNumber;
0N/A public static long getEventNumber() {
0N/A awtLock();
0N/A try {
0N/A return eventNumber;
0N/A } finally {
0N/A awtUnlock();
0N/A }
0N/A }
0N/A
0N/A private static XEventDispatcher oops_waiter;
0N/A private static boolean oops_updated;
0N/A private static boolean oops_failed;
0N/A private XAtom oops;
0N/A private static final long WORKAROUND_SLEEP = 100;
0N/A
0N/A /**
0N/A * @inheritDoc
0N/A */
0N/A protected boolean syncNativeQueue(final long timeout) {
0N/A XBaseWindow win = XBaseWindow.getXAWTRootWindow();
0N/A
0N/A if (oops_waiter == null) {
0N/A oops_waiter = new XEventDispatcher() {
0N/A public void dispatchEvent(XEvent e) {
216N/A if (e.get_type() == XConstants.SelectionNotify) {
0N/A XSelectionEvent pe = e.get_xselection();
0N/A if (pe.get_property() == oops.getAtom()) {
0N/A oops_updated = true;
0N/A awtLockNotifyAll();
0N/A } else if (pe.get_selection() == XAtom.get("WM_S0").getAtom() &&
0N/A pe.get_target() == XAtom.get("VERSION").getAtom() &&
0N/A pe.get_property() == 0 &&
0N/A XlibWrapper.XGetSelectionOwner(getDisplay(), XAtom.get("WM_S0").getAtom()) == 0)
0N/A {
0N/A // WM forgot to acquire selection or there is no WM
0N/A oops_failed = true;
0N/A awtLockNotifyAll();
0N/A }
0N/A
0N/A }
0N/A }
0N/A };
0N/A }
0N/A
0N/A if (oops == null) {
0N/A oops = XAtom.get("OOPS");
0N/A }
0N/A
0N/A awtLock();
0N/A try {
0N/A addEventDispatcher(win.getWindow(), oops_waiter);
0N/A
0N/A oops_updated = false;
0N/A oops_failed = false;
0N/A // Wait for selection notify for oops on win
0N/A long event_number = getEventNumber();
0N/A XAtom atom = XAtom.get("WM_S0");
1696N/A eventLog.finer("WM_S0 selection owner {0}", XlibWrapper.XGetSelectionOwner(getDisplay(), atom.getAtom()));
0N/A XlibWrapper.XConvertSelection(getDisplay(), atom.getAtom(),
0N/A XAtom.get("VERSION").getAtom(), oops.getAtom(),
216N/A win.getWindow(), XConstants.CurrentTime);
0N/A XSync();
0N/A
0N/A
0N/A eventLog.finer("Requested OOPS");
0N/A
0N/A long start = System.currentTimeMillis();
0N/A while (!oops_updated && !oops_failed) {
0N/A try {
0N/A awtLockWait(timeout);
0N/A } catch (InterruptedException e) {
0N/A throw new RuntimeException(e);
0N/A }
0N/A // This "while" is a protection from spurious
0N/A // wake-ups. However, we shouldn't wait for too long
0N/A if ((System.currentTimeMillis() - start > timeout) && timeout >= 0) {
0N/A throw new OperationTimedOut(Long.toString(System.currentTimeMillis() - start));
0N/A }
0N/A }
0N/A if (oops_failed && getEventNumber() - event_number == 1) {
0N/A // If selection update failed we can simply wait some time
0N/A // hoping some events will arrive
0N/A awtUnlock();
1696N/A eventLog.finest("Emergency sleep");
0N/A try {
0N/A Thread.sleep(WORKAROUND_SLEEP);
0N/A } catch (InterruptedException ie) {
0N/A throw new RuntimeException(ie);
0N/A } finally {
0N/A awtLock();
0N/A }
0N/A }
0N/A return getEventNumber() - event_number > 2;
0N/A } finally {
0N/A removeEventDispatcher(win.getWindow(), oops_waiter);
1696N/A eventLog.finer("Exiting syncNativeQueue");
0N/A awtUnlock();
0N/A }
0N/A }
0N/A public void grab(Window w) {
0N/A if (w.getPeer() != null) {
0N/A ((XWindowPeer)w.getPeer()).setGrab(true);
0N/A }
0N/A }
0N/A
0N/A public void ungrab(Window w) {
0N/A if (w.getPeer() != null) {
0N/A ((XWindowPeer)w.getPeer()).setGrab(false);
0N/A }
0N/A }
0N/A /**
0N/A * Returns if the java.awt.Desktop class is supported on the current
0N/A * desktop.
0N/A * <p>
0N/A * The methods of java.awt.Desktop class are supported on the Gnome desktop.
0N/A * Check if the running desktop is Gnome by checking the window manager.
0N/A */
0N/A public boolean isDesktopSupported(){
0N/A return XDesktopPeer.isDesktopSupported();
0N/A }
0N/A
0N/A public DesktopPeer createDesktopPeer(Desktop target){
0N/A return new XDesktopPeer();
0N/A }
0N/A
870N/A public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
870N/A return areExtraMouseButtonsEnabled;
870N/A }
1045N/A
1045N/A @Override
1045N/A public boolean isWindowOpacitySupported() {
1045N/A XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
1045N/A
1045N/A if (net_protocol == null) {
1045N/A return false;
1045N/A }
1045N/A
1045N/A return net_protocol.doOpacityProtocol();
1045N/A }
1045N/A
1045N/A @Override
1045N/A public boolean isWindowShapingSupported() {
1045N/A return XlibUtil.isShapingSupported();
1045N/A }
1045N/A
1045N/A @Override
1045N/A public boolean isWindowTranslucencySupported() {
1045N/A //NOTE: it may not be supported. The actual check is being performed
1045N/A // at com.sun.awt.AWTUtilities(). In X11 we need to check
1045N/A // whether there's any translucency-capable GC available.
1045N/A return true;
1045N/A }
1045N/A
1045N/A @Override
1045N/A public boolean isTranslucencyCapable(GraphicsConfiguration gc) {
1045N/A if (!(gc instanceof X11GraphicsConfig)) {
1045N/A return false;
1045N/A }
1045N/A return ((X11GraphicsConfig)gc).isTranslucencyCapable();
1045N/A }
1065N/A
1065N/A /**
1065N/A * Returns the value of "sun.awt.disablegrab" property. Default
1065N/A * value is {@code false}.
1065N/A */
1065N/A public static boolean getSunAwtDisableGrab() {
1065N/A return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disablegrab"));
1065N/A }
0N/A}