Hi,

Dalibor reported a regression with handling mouse events on Frames. This
is caused by the LightweightDispatcher eating up all events. This patch
makes LightweightDispatcher a little less greedy and seems to fix the
bug while still making lightweights handle the mouse events if they are
there.

2006-03-14  Mark Wielaard  <[EMAIL PROTECTED]>

    Fixes bug #26641
    * java/awt/LightweightDispatcher.java (dispatchEvent): Return result
    of handleMouseEvent.
    (handleMouseEvent): Return boolean to indicate whether we handled the
    event by passing it to a lightweight.

Does this look sane?

Cheers,

Mark
Index: java/awt/LightweightDispatcher.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/LightweightDispatcher.java,v
retrieving revision 1.2
diff -u -r1.2 LightweightDispatcher.java
--- java/awt/LightweightDispatcher.java	28 Feb 2006 11:27:15 -0000	1.2
+++ java/awt/LightweightDispatcher.java	14 Mar 2006 17:27:38 -0000
@@ -110,14 +110,12 @@
    */
   public boolean dispatchEvent(AWTEvent event)
   {
-    boolean dispatched = false;
     if (event instanceof MouseEvent && event.getSource() instanceof Window)
       {
         MouseEvent mouseEvent = (MouseEvent) event;
-        handleMouseEvent(mouseEvent);
-        dispatched = true;
+        return handleMouseEvent(mouseEvent);
       }
-    return dispatched;
+    return false;
   }
 
   /**
@@ -125,8 +123,9 @@
    * (Window instances) and dispatches them to the correct lightweight child.
    *
    * @param ev the mouse event
+   * @return whether or not we found a lightweight that handled the event.
    */
-  private void handleMouseEvent(MouseEvent ev)
+  private boolean handleMouseEvent(MouseEvent ev)
   {
     Window window = (Window) ev.getSource();
     Component target = window.findComponentAt(ev.getX(), ev.getY());
@@ -195,6 +194,9 @@
         // influenced by this modified event.
         ev.setSource(window);
         ev.translatePoint(-dx, -dy);
+	return true;
       }
+    else
+      return false;
   }
 }

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to