388 winToDispatcher.put(key, dispatchers);
389 }
390 dispatchers.add(dispatcher);
391 }
392 }
393 static void removeEventDispatcher(long window, XEventDispatcher dispatcher) {
394 synchronized(winToDispatcher) {
395 Long key = Long.valueOf(window);
396 Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
397 if (dispatchers != null) {
398 dispatchers.remove(dispatcher);
399 }
400 }
401 }
402
403 private Point lastCursorPos;
404
405 /**
406 * Returns whether there is last remembered cursor position. The
407 * position is remembered from X mouse events on our peers. The
408 * position is stored in <code>p</code>.
409 * @return true, if there is remembered last cursor position,
410 * false otherwise
411 */
412 boolean getLastCursorPos(Point p) {
413 awtLock();
414 try {
415 if (lastCursorPos == null) {
416 return false;
417 }
418 p.setLocation(lastCursorPos);
419 return true;
420 } finally {
421 awtUnlock();
422 }
423 }
424
425 private void processGlobalMotionEvent(XEvent e) {
426 // Only our windows guaranteely generate MotionNotify, so we
427 // should track enter/leave, to catch the moment when to
428 // switch to XQueryPointer
1648 hint);
1649 }
1650 }
1651 desktopProperties.put(SunToolkit.DESKTOPFONTHINTS,
1652 SunToolkit.getDesktopFontHints());
1653 }
1654
1655 return true;
1656 }
1657 }
1658 return false;
1659 }
1660
1661 private void loadXSettings() {
1662 xs = new XAWTXSettings();
1663 }
1664
1665 /**
1666 * Callback from the native side indicating some, or all, of the
1667 * desktop properties have changed and need to be reloaded.
1668 * <code>data</code> is the byte array directly from the x server and
1669 * may be in little endian format.
1670 * <p>
1671 * NB: This could be called from any thread if triggered by
1672 * <code>loadXSettings</code>. It is called from the System EDT
1673 * if triggered by an XSETTINGS change.
1674 */
1675 void parseXSettings(int screen_XXX_ignored,Map<String, Object> updatedSettings) {
1676
1677 if (updatedSettings == null || updatedSettings.isEmpty()) {
1678 return;
1679 }
1680
1681 Iterator<Map.Entry<String, Object>> i = updatedSettings.entrySet().iterator();
1682 while (i.hasNext()) {
1683 Map.Entry<String, Object> e = i.next();
1684 String name = e.getKey();
1685
1686 name = "gnome." + name;
1687 setDesktopProperty(name, e.getValue());
1688 if (log.isLoggable(PlatformLogger.Level.FINE)) {
1689 log.fine("name = " + name + " value = " + e.getValue());
1690 }
1691
1692 // XXX: we probably want to do something smarter. In
1909 Iterator<java.util.List<Runnable>> iter = values.iterator();
1910 while (iter.hasNext()) {
1911 java.util.List<Runnable> list = iter.next();
1912 boolean removed = false;
1913 if (list.contains(task)) {
1914 list.remove(task);
1915 if (list.isEmpty()) {
1916 iter.remove();
1917 }
1918 break;
1919 }
1920 }
1921 } finally {
1922 awtUnlock();
1923 }
1924 }
1925
1926 static native void wakeup_poll();
1927
1928 /**
1929 * Registers a Runnable which <code>run()</code> method will be called
1930 * once on the toolkit thread when a specified interval of time elapses.
1931 *
1932 * @param task a Runnable which <code>run</code> method will be called
1933 * on the toolkit thread when <code>interval</code> milliseconds
1934 * elapse
1935 * @param interval an interal in milliseconds
1936 *
1937 * @throws NullPointerException if <code>task</code> is <code>null</code>
1938 * @throws IllegalArgumentException if <code>interval</code> is not positive
1939 */
1940 static void schedule(Runnable task, long interval) {
1941 if (task == null) {
1942 throw new NullPointerException("task is null");
1943 }
1944 if (interval <= 0) {
1945 throw new IllegalArgumentException("interval " + interval + " is not positive");
1946 }
1947
1948 awtLock();
1949 try {
1950 if (timeoutTaskLog.isLoggable(PlatformLogger.Level.FINER)) {
1951 timeoutTaskLog.finer("XToolkit.schedule(): current time={0}" +
1952 "; interval={1}" +
1953 "; task being added={2}" + "; tasks before addition={3}",
1954 Long.valueOf(System.currentTimeMillis()), Long.valueOf(interval), task, timeoutTasks);
1955 }
1956
1957 if (timeoutTasks == null) {
1958 timeoutTasks = new TreeMap<>();
|
388 winToDispatcher.put(key, dispatchers);
389 }
390 dispatchers.add(dispatcher);
391 }
392 }
393 static void removeEventDispatcher(long window, XEventDispatcher dispatcher) {
394 synchronized(winToDispatcher) {
395 Long key = Long.valueOf(window);
396 Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
397 if (dispatchers != null) {
398 dispatchers.remove(dispatcher);
399 }
400 }
401 }
402
403 private Point lastCursorPos;
404
405 /**
406 * Returns whether there is last remembered cursor position. The
407 * position is remembered from X mouse events on our peers. The
408 * position is stored in {@code p}.
409 * @return true, if there is remembered last cursor position,
410 * false otherwise
411 */
412 boolean getLastCursorPos(Point p) {
413 awtLock();
414 try {
415 if (lastCursorPos == null) {
416 return false;
417 }
418 p.setLocation(lastCursorPos);
419 return true;
420 } finally {
421 awtUnlock();
422 }
423 }
424
425 private void processGlobalMotionEvent(XEvent e) {
426 // Only our windows guaranteely generate MotionNotify, so we
427 // should track enter/leave, to catch the moment when to
428 // switch to XQueryPointer
1648 hint);
1649 }
1650 }
1651 desktopProperties.put(SunToolkit.DESKTOPFONTHINTS,
1652 SunToolkit.getDesktopFontHints());
1653 }
1654
1655 return true;
1656 }
1657 }
1658 return false;
1659 }
1660
1661 private void loadXSettings() {
1662 xs = new XAWTXSettings();
1663 }
1664
1665 /**
1666 * Callback from the native side indicating some, or all, of the
1667 * desktop properties have changed and need to be reloaded.
1668 * {@code data} is the byte array directly from the x server and
1669 * may be in little endian format.
1670 * <p>
1671 * NB: This could be called from any thread if triggered by
1672 * {@code loadXSettings}. It is called from the System EDT
1673 * if triggered by an XSETTINGS change.
1674 */
1675 void parseXSettings(int screen_XXX_ignored,Map<String, Object> updatedSettings) {
1676
1677 if (updatedSettings == null || updatedSettings.isEmpty()) {
1678 return;
1679 }
1680
1681 Iterator<Map.Entry<String, Object>> i = updatedSettings.entrySet().iterator();
1682 while (i.hasNext()) {
1683 Map.Entry<String, Object> e = i.next();
1684 String name = e.getKey();
1685
1686 name = "gnome." + name;
1687 setDesktopProperty(name, e.getValue());
1688 if (log.isLoggable(PlatformLogger.Level.FINE)) {
1689 log.fine("name = " + name + " value = " + e.getValue());
1690 }
1691
1692 // XXX: we probably want to do something smarter. In
1909 Iterator<java.util.List<Runnable>> iter = values.iterator();
1910 while (iter.hasNext()) {
1911 java.util.List<Runnable> list = iter.next();
1912 boolean removed = false;
1913 if (list.contains(task)) {
1914 list.remove(task);
1915 if (list.isEmpty()) {
1916 iter.remove();
1917 }
1918 break;
1919 }
1920 }
1921 } finally {
1922 awtUnlock();
1923 }
1924 }
1925
1926 static native void wakeup_poll();
1927
1928 /**
1929 * Registers a Runnable which {@code run()} method will be called
1930 * once on the toolkit thread when a specified interval of time elapses.
1931 *
1932 * @param task a Runnable which {@code run} method will be called
1933 * on the toolkit thread when {@code interval} milliseconds
1934 * elapse
1935 * @param interval an interal in milliseconds
1936 *
1937 * @throws NullPointerException if {@code task} is {@code null}
1938 * @throws IllegalArgumentException if {@code interval} is not positive
1939 */
1940 static void schedule(Runnable task, long interval) {
1941 if (task == null) {
1942 throw new NullPointerException("task is null");
1943 }
1944 if (interval <= 0) {
1945 throw new IllegalArgumentException("interval " + interval + " is not positive");
1946 }
1947
1948 awtLock();
1949 try {
1950 if (timeoutTaskLog.isLoggable(PlatformLogger.Level.FINER)) {
1951 timeoutTaskLog.finer("XToolkit.schedule(): current time={0}" +
1952 "; interval={1}" +
1953 "; task being added={2}" + "; tasks before addition={3}",
1954 Long.valueOf(System.currentTimeMillis()), Long.valueOf(interval), task, timeoutTasks);
1955 }
1956
1957 if (timeoutTasks == null) {
1958 timeoutTasks = new TreeMap<>();
|