java.awt
Class LightweightDispatcher

java.lang.Object
  |
  +--java.awt.LightweightDispatcher

class LightweightDispatcher
extends Object
implements Serializable, AWTEventListener

Class to manage the dispatching of events to the lightweight components contained by a native container.

See Also:
Serialized Form

Field Summary
private  boolean dragging
          Indicates if the mouse pointer is currently being dragged...
private  long eventMask
          The event mask for contained lightweight components.
private  Component focus
          The current lightweight component that has focus that is being hosted by this container.
private  boolean isClickOrphaned
          Is the next click event orphaned because the component hid/moved
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 lightweight component being hosted by this windowed component that has mouse events being forwarded to it.
private  Container nativeContainer
          The windowed container that might be hosting events for lightweight components.
private  Cursor nativeCursor
          The cursor used by the native container that is hosting the lightweight components.
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 lightweight sub-component if necessary, and returns whether or not the event was forwarded to a lightweight sub-component.
(package private)  void enableEvents(long events)
          Enables events to lightweight components.
 void eventDispatched(AWTEvent e)
           
private  boolean processFocusEvent(FocusEvent e)
           
private  boolean processKeyEvent(KeyEvent 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.
(package private)  boolean setFocusRequest(Component c)
          This is called by the hosting native container on behalf of lightweight components that have requested focus.
private  void setMouseTarget(Component target, MouseEvent e)
          Change the current target of mouse events.
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, registerNatives, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID

LWD_MOUSE_DRAGGED_OVER

private static final int LWD_MOUSE_DRAGGED_OVER

nativeContainer

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

focus

private Component focus
The current lightweight component that has focus that is being hosted by this container. If this is a null reference then there is currently no focus on a lightweight component being hosted by this container

mouseEventTarget

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

targetLastEntered

private transient Component targetLastEntered
The last component entered

isMouseInNativeContainer

private transient boolean isMouseInNativeContainer
Is the mouse over the native container

isClickOrphaned

private transient boolean isClickOrphaned
Is the next click event orphaned because the component hid/moved

dragging

private boolean dragging
Indicates if the mouse pointer is currently being dragged... this is needed because we may receive exit events while dragging and need to keep the current mouse target in this case.

nativeCursor

private Cursor nativeCursor
The cursor used by the native container that is hosting the lightweight components. Since the Cursor used by the lightweight components overwrites the Cursor set in the native container we need to stash the native cursor so we can restore it after the lightweight components are done having their cursor shown.

eventMask

private long eventMask
The event mask for contained lightweight components. Lightweight components need a windowed container to host window-related events. This seperate 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.

MOUSE_MASK

private static final long MOUSE_MASK
Constructor Detail

LightweightDispatcher

LightweightDispatcher(Container nativeContainer)
Method Detail

enableEvents

void enableEvents(long events)
Enables events to lightweight components.

setFocusRequest

boolean setFocusRequest(Component c)
This is called by the hosting native container on behalf of lightweight components that have requested focus. The focus request is propagated upward from the requesting lightweight component until a windowed host is found, at which point the windowed host calls this method. This method returns whether or not the peer associated with the native component needs to request focus from the native window system. If a lightweight component already has focus the focus events are synthesized since there will be no native events to drive the focus. If the native host already has focus, the focus gained is synthesized for the lightweight component requesting focus since it will receive no native focus requests.

dispatchEvent

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

processKeyEvent

private boolean processKeyEvent(KeyEvent e)

processFocusEvent

private boolean processFocusEvent(FocusEvent 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.

setMouseTarget

private void setMouseTarget(Component target,
                            MouseEvent e)
Change the current target of mouse events.

trackMouseEnterExit

private void trackMouseEnterExit(Component targetOver,
                                 MouseEvent e)

startListeningForOtherDrags

private void startListeningForOtherDrags()

stopListeningForOtherDrags

private void stopListeningForOtherDrags()

eventDispatched

public void eventDispatched(AWTEvent e)
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.