139 pollInterval = defaultPollInterval; 140 } 141 } 142 return pollInterval; 143 } 144 } 145 146 private XAtom getTargetsPropertyAtom() { 147 if (null == targetsPropertyAtom) { 148 targetsPropertyAtom = 149 XAtom.get("XAWT_TARGETS_OF_SELECTION:" + selection.getSelectionAtom().getName()); 150 } 151 return targetsPropertyAtom; 152 } 153 154 protected void registerClipboardViewerChecked() { 155 // for XConvertSelection() to be called for the first time in getTargetsDelayed() 156 isSelectionNotifyProcessed = true; 157 158 boolean mustSchedule = false; 159 synchronized (XClipboard.classLock) { 160 if (targetsAtom2Clipboard == null) { 161 targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2); 162 } 163 mustSchedule = targetsAtom2Clipboard.isEmpty(); 164 targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this); 165 if (mustSchedule) { 166 XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), 167 new SelectionNotifyHandler()); 168 } 169 } 170 if (mustSchedule) { 171 XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval()); 172 } 173 } 174 175 private static class CheckChangeTimerTask implements Runnable { 176 public void run() { 177 for (XClipboard clpbrd : targetsAtom2Clipboard.values()) { 178 clpbrd.getTargetsDelayed(); 179 } 180 synchronized (XClipboard.classLock) { 181 if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { 182 // The viewer is still registered, schedule next poll. 183 XToolkit.schedule(this, XClipboard.getPollInterval()); 184 } 185 } 186 } 187 } 188 189 private static class SelectionNotifyHandler implements XEventDispatcher { 190 public void dispatchEvent(XEvent ev) { 191 if (ev.get_type() == XConstants.SelectionNotify) { | 139 pollInterval = defaultPollInterval; 140 } 141 } 142 return pollInterval; 143 } 144 } 145 146 private XAtom getTargetsPropertyAtom() { 147 if (null == targetsPropertyAtom) { 148 targetsPropertyAtom = 149 XAtom.get("XAWT_TARGETS_OF_SELECTION:" + selection.getSelectionAtom().getName()); 150 } 151 return targetsPropertyAtom; 152 } 153 154 protected void registerClipboardViewerChecked() { 155 // for XConvertSelection() to be called for the first time in getTargetsDelayed() 156 isSelectionNotifyProcessed = true; 157 158 boolean mustSchedule = false; 159 XToolkit.awtLock(); 160 try { 161 synchronized (XClipboard.classLock) { 162 if (targetsAtom2Clipboard == null) { 163 targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2); 164 } 165 mustSchedule = targetsAtom2Clipboard.isEmpty(); 166 targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this); 167 if (mustSchedule) { 168 XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), 169 new SelectionNotifyHandler()); 170 } 171 } 172 if (mustSchedule) { 173 XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval()); 174 } 175 } finally { 176 XToolkit.awtUnlock(); 177 } 178 } 179 180 private static class CheckChangeTimerTask implements Runnable { 181 public void run() { 182 for (XClipboard clpbrd : targetsAtom2Clipboard.values()) { 183 clpbrd.getTargetsDelayed(); 184 } 185 synchronized (XClipboard.classLock) { 186 if (targetsAtom2Clipboard != null && !targetsAtom2Clipboard.isEmpty()) { 187 // The viewer is still registered, schedule next poll. 188 XToolkit.schedule(this, XClipboard.getPollInterval()); 189 } 190 } 191 } 192 } 193 194 private static class SelectionNotifyHandler implements XEventDispatcher { 195 public void dispatchEvent(XEvent ev) { 196 if (ev.get_type() == XConstants.SelectionNotify) { |