java.awt
Class LightweightDispatcher

java.lang.Object
  extended byjava.awt.LightweightDispatcher
All Implemented Interfaces:
AWTEventListener, EventListener, Serializable

class LightweightDispatcher
extends Object
implements Serializable, AWTEventListener

Class to manage the dispatching of MouseEvents to the lightweight descendants and SunDropTargetEvents to both lightweight and heavyweight descendants contained by a native container. NOTE: the class name is not appropriate anymore, but we cannot change it because we must keep serialization compatibility.

Author:
Timothy Prinzing

Field Summary
private static sun.awt.DebugHelper dbg
           
private  long eventMask
          The event mask for contained lightweight components.
private  Component focus
          This variable is not used, but kept for serialization compatibility
private  boolean isMouseInNativeContainer
          Is the mouse over the native container
private static int LWD_MOUSE_DRAGGED_OVER
           
private static long MOUSE_MASK
           
private  Component mouseEventTarget
          The current subcomponent being hosted by this windowed component that has events being forwarded to it.
private  Container nativeContainer
          The windowed container that might be hosting events for subcomponents.
private  Cursor nativeCursor
          This variable is not used, but kept for serialization compatibility
private static long PROXY_EVENT_MASK
          The kind of events routed to lightweight components from windowed hosts.
private static long serialVersionUID
           
private  Component targetLastEntered
          The last component entered
 
Constructor Summary
(package private) LightweightDispatcher(Container nativeContainer)
           
 
Method Summary
(package private)  boolean dispatchEvent(AWTEvent e)
          Dispatches an event to a sub-component if necessary, and returns whether or not the event was forwarded to a sub-component.
(package private)  void dispose()
           
(package private)  void enableEvents(long events)
          Enables events to subcomponents.
 void eventDispatched(AWTEvent e)
          Invoked when an event is dispatched in the AWT.
private  boolean isMouseGrab(MouseEvent e)
           
private  boolean processDropTargetEvent(sun.awt.dnd.SunDropTargetEvent e)
           
private  boolean processMouseEvent(MouseEvent e)
          This method attempts to distribute a mouse event to a lightweight component.
(package private)  void retargetMouseEvent(Component target, int id, MouseEvent e)
          Sends a mouse event to the current mouse event recipient using the given event (sent to the windowed host) as a srcEvent.
private  void startListeningForOtherDrags()
           
private  void stopListeningForOtherDrags()
           
private  void trackMouseEnterExit(Component targetOver, MouseEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

LWD_MOUSE_DRAGGED_OVER

private static final int LWD_MOUSE_DRAGGED_OVER
See Also:
Constant Field Values

dbg

private static final sun.awt.DebugHelper dbg

nativeContainer

private Container nativeContainer
The windowed container that might be hosting events for subcomponents.


focus

private Component focus
This variable is not used, but kept for serialization compatibility


mouseEventTarget

private transient Component mouseEventTarget
The current subcomponent being hosted by this windowed component that has events being forwarded to it. If this is null, there are currently no events being forwarded to a subcomponent.


targetLastEntered

private transient Component targetLastEntered
The last component entered


isMouseInNativeContainer

private transient boolean isMouseInNativeContainer
Is the mouse over the native container


nativeCursor

private Cursor nativeCursor
This variable is not used, but kept for serialization compatibility


eventMask

private long eventMask
The event mask for contained lightweight components. Lightweight components need a windowed container to host window-related events. This separate mask indicates events that have been requested by contained lightweight components without effecting the mask of the windowed component itself.


PROXY_EVENT_MASK

private static final long PROXY_EVENT_MASK
The kind of events routed to lightweight components from windowed hosts.

See Also:
Constant Field Values

MOUSE_MASK

private static final long MOUSE_MASK
See Also:
Constant Field Values
Constructor Detail

LightweightDispatcher

LightweightDispatcher(Container nativeContainer)
Method Detail

dispose

void dispose()

enableEvents

void enableEvents(long events)
Enables events to subcomponents.


dispatchEvent

boolean dispatchEvent(AWTEvent e)
Dispatches an event to a sub-component if necessary, and returns whether or not the event was forwarded to a sub-component.

Parameters:
e - the event

isMouseGrab

private boolean isMouseGrab(MouseEvent e)

processMouseEvent

private boolean processMouseEvent(MouseEvent e)
This method attempts to distribute a mouse event to a lightweight component. It tries to avoid doing any unnecessary probes down into the component tree to minimize the overhead of determining where to route the event, since mouse movement events tend to come in large and frequent amounts.


processDropTargetEvent

private boolean processDropTargetEvent(sun.awt.dnd.SunDropTargetEvent e)

trackMouseEnterExit

private void trackMouseEnterExit(Component targetOver,
                                 MouseEvent e)

startListeningForOtherDrags

private void startListeningForOtherDrags()

stopListeningForOtherDrags

private void stopListeningForOtherDrags()

eventDispatched

public void eventDispatched(AWTEvent e)
Description copied from interface: AWTEventListener
Invoked when an event is dispatched in the AWT.

Specified by:
eventDispatched in interface AWTEventListener

retargetMouseEvent

void retargetMouseEvent(Component target,
                        int id,
                        MouseEvent e)
Sends a mouse event to the current mouse event recipient using the given event (sent to the windowed host) as a srcEvent. If the mouse event target is still in the component tree, the coordinates of the event are translated to those of the target. If the target has been removed, we don't bother to send the message.