JDK-6212197 : Should use desktop settings instead of hardcoded constants
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2004-12-23
  • Updated: 2011-04-28
Related Reports
Relates :  
Relates :  
Description
Starting with the fix for 6176814, a double click is recognized on XAWT
only if the distance between 2 successive mouse presses is not greater
than the constant 4. A desktop property (see Toolkit.getDesktopProperty())
should be used intead of the constant. On X platforms the desktop property
should be mapped to XSETTING Net/DoubleClickDistance (refer to
http://freedesktop.org/wiki/Standards_2fXSettingsRegistry).

There may be other places in AWT where desktop settings should be used 
instead of hardcoded contants.

###@###.### 2004-12-23 15:24:02 GMT

Comments
SUGGESTED FIX *** /tmp/geta11952 2005-06-08 14:05:50.000000000 +0400 --- XToolkit.java 2005-01-21 16:33:08.000000000 +0300 *************** *** 1124,1129 **** --- 1124,1136 ---- setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold); } + Integer doubleClickDistance = null; + synchronized (this) { + doubleClickDistance = (Integer)desktopProperties.get("gnome.Net/DoubleClickDistance"); + } + if (doubleClickDistance != null){ + setDesktopProperty("awt.doubleClickDistance", doubleClickDistance); + } } --- XBaseWindow.java 2005-01-20 12:22:41.000000000 +0300 + /* If a motion comes in while a multi-click is pending, + * allow a smudge factor so that moving the mouse by a small + * amount does not wipe out the multi-click state variables. + */ + static int AWT_MULTICLICK_SMUDGE; + /** * Called for delayed inits during construction */ *************** *** 119,124 **** --- 125,136 ---- instantPreInit(params); delayedParams = params; } + try { + AWT_MULTICLICK_SMUDGE = + ((Integer)Toolkit.getDefaultToolkit().getDesktopProperty("awt.doubleClickDistance")).intValue(); + } catch (Exception e) { + AWT_MULTICLICK_SMUDGE = 4; + } } /* *** /tmp/geta11977 2005-06-08 14:09:48.000000000 +0400 --- MToolkit.java 2005-01-21 18:42:50.000000000 +0300 *************** *** 51,56 **** --- 51,57 ---- import sun.misc.PerformanceLogger; import sun.security.action.GetBooleanAction; + import sun.security.action.GetIntegerAction; public class MToolkit extends UNIXToolkit implements Runnable { private static final DebugHelper dbg = DebugHelper.create(MToolkit.class); *************** *** 648,657 **** --- 649,687 ---- if (dragThreshold != null) { setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold); } + Integer doubleClickDistance = null; + synchronized (this) { + doubleClickDistance = (Integer)desktopProperties.get("gnome.Net/DoubleClickDistance"); + } + if (doubleClickDistance != null){ + setDesktopProperty("awt.doubleClickDistance", doubleClickDistance); + } } protected boolean needsXEmbedImpl() { return true; } + /** + * Returns the smudge value + * + * @return mouse smudge value + * @since 6.0 + */ + static int getMouseSmudgeValue() { + int smugdeValue = ((Integer)AccessController.doPrivileged( + new GetIntegerAction("awt.doubleClickDistance", 0))).intValue(); + if (smugdeValue > 0) { + return smugdeValue; + } else { + Integer sV = (Integer)Toolkit.getDefaultToolkit(). + getDesktopProperty("awt.doubleClickDistance"); + if (sV != null) { + return sV.intValue(); + } + } + return 4; + } + } // class MToolkit + *** /tmp/geta11988 2005-06-08 14:10:51.000000000 +0400 --- canvas.c 2005-01-21 18:35:17.000000000 +0300 *************** *** 102,108 **** static Boolean debugKeys = False; #endif ! jint awt_multiclick_smudge = 4; extern Widget drag_source; --- 102,108 ---- static Boolean debugKeys = False; #endif ! jint awt_multiclick_smudge; extern Widget drag_source; *************** *** 2042,2047 **** --- 2042,2063 ---- * allow a smudge factor so that moving the mouse by a small * amount does not wipe out the multi-click state variables. */ + if ( awt_multiclick_smudge == 0 ){ + //call propertyGetter + //awt_multiclick_smudge = + jclass class; + jmethodID mid; + + jclass tmpClass = (*env)->FindClass(env, "sun/awt/motif/MToolkit"); + class = (jclass)(*env)->NewGlobalRef(env, tmpClass); + (*env)->DeleteLocalRef(env, tmpClass); + mid = (*env)->GetMethodID(env, class, "getMouseSmudgeValue","()I"); + awt_multiclick_smudge = (*env)->CallMethod(env, class, mid); + if ((*env)->ExceptionOccurred(env)) { + (*env)->ExceptionDescribe(env); + (*env)->ExceptionClear(env); + } + } if (!(lastPeer == client_data && ((event->xmotion.time - lastTime) <= (Time) awt_multiclick_time) && (ABS(lastx - x) < awt_multiclick_smudge && ###@###.### 2005-06-08 10:11:52 GMT
08-06-2005

EVALUATION will fix in mustang timeframe ###@###.### 2004-12-24 12:51:39 GMT
24-12-2004