2265 */ |
2265 */ |
2266 private Component getMouseEventTargetImpl(int x, int y, boolean includeSelf, |
2266 private Component getMouseEventTargetImpl(int x, int y, boolean includeSelf, |
2267 EventTargetFilter filter, |
2267 EventTargetFilter filter, |
2268 boolean searchHeavyweightChildren, |
2268 boolean searchHeavyweightChildren, |
2269 boolean searchHeavyweightDescendants) { |
2269 boolean searchHeavyweightDescendants) { |
2270 int ncomponents = this.ncomponents; |
2270 synchronized (getTreeLock()) { |
2271 Component component[] = this.component; |
2271 int ncomponents = this.ncomponents; |
2272 |
2272 Component component[] = this.component; |
2273 for (int i = 0 ; i < ncomponents ; i++) { |
2273 |
2274 Component comp = component[i]; |
2274 for (int i = 0 ; i < ncomponents ; i++) { |
2275 if (comp != null && comp.visible && |
2275 Component comp = component[i]; |
2276 ((!searchHeavyweightChildren && |
2276 if (comp != null && comp.visible && |
2277 comp.peer instanceof LightweightPeer) || |
2277 ((!searchHeavyweightChildren && |
2278 (searchHeavyweightChildren && |
2278 comp.peer instanceof LightweightPeer) || |
2279 !(comp.peer instanceof LightweightPeer))) && |
2279 (searchHeavyweightChildren && |
2280 comp.contains(x - comp.x, y - comp.y)) { |
2280 !(comp.peer instanceof LightweightPeer))) && |
2281 |
2281 comp.contains(x - comp.x, y - comp.y)) { |
2282 // found a component that intersects the point, see if there is |
2282 |
2283 // a deeper possibility. |
2283 // found a component that intersects the point, see if there |
2284 if (comp instanceof Container) { |
2284 // is a deeper possibility. |
2285 Container child = (Container) comp; |
2285 if (comp instanceof Container) { |
2286 Component deeper = child.getMouseEventTarget(x - child.x, |
2286 Container child = (Container) comp; |
2287 y - child.y, |
2287 Component deeper = child.getMouseEventTarget( |
2288 includeSelf, |
2288 x - child.x, |
2289 filter, |
2289 y - child.y, |
2290 searchHeavyweightDescendants); |
2290 includeSelf, |
2291 if (deeper != null) { |
2291 filter, |
2292 return deeper; |
2292 searchHeavyweightDescendants); |
|
2293 if (deeper != null) { |
|
2294 return deeper; |
|
2295 } |
|
2296 } else { |
|
2297 if (filter.accept(comp)) { |
|
2298 // there isn't a deeper target, but this component |
|
2299 // is a target |
|
2300 return comp; |
|
2301 } |
2293 } |
2302 } |
2294 } else { |
2303 } |
2295 if (filter.accept(comp)) { |
2304 } |
2296 // there isn't a deeper target, but this component is a |
2305 |
2297 // target |
2306 boolean isPeerOK; |
2298 return comp; |
2307 boolean isMouseOverMe; |
2299 } |
2308 |
2300 } |
2309 isPeerOK = (peer instanceof LightweightPeer) || includeSelf; |
2301 } |
2310 isMouseOverMe = contains(x,y); |
2302 } |
2311 |
2303 |
2312 // didn't find a child target, return this component if it's |
2304 boolean isPeerOK; |
2313 // a possible target |
2305 boolean isMouseOverMe; |
2314 if (isMouseOverMe && isPeerOK && filter.accept(this)) { |
2306 |
2315 return this; |
2307 isPeerOK = (peer instanceof LightweightPeer) || includeSelf; |
2316 } |
2308 isMouseOverMe = contains(x,y); |
2317 // no possible target |
2309 |
2318 return null; |
2310 // didn't find a child target, return this component if it's a possible |
2319 } |
2311 // target |
|
2312 if (isMouseOverMe && isPeerOK && filter.accept(this)) { |
|
2313 return this; |
|
2314 } |
|
2315 // no possible target |
|
2316 return null; |
|
2317 } |
2320 } |
2318 |
2321 |
2319 static interface EventTargetFilter { |
2322 static interface EventTargetFilter { |
2320 boolean accept(final Component comp); |
2323 boolean accept(final Component comp); |
2321 } |
2324 } |