- fixed small problem in my check-in from yesterday
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Dec 2004 20:40:25 +0000 (20:40 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Dec 2004 20:40:25 +0000 (20:40 +0000)
        * kwq/KWQEvent.mm:
        (positionForEvent): Get location from event without raising exception if it's the wrong type.
        (clickCountForEvent): Same, for clickCount.
        (QMouseEvent::QMouseEvent): Use the new helper functions so this can be constructed even with
        the wrong type of NSEvent. Required for cases where a keyboard event causes a "click" and we need
        to synthesize a QMouseEvent for KHTML internal use, using the key down NSEvent.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/kwq/KWQEvent.mm

index af307f69bb3e261ff2b96f35e3b0e0b4c87675b9..391626d40d60a64ca9a62d1a4ed27d1fab2407f5 100644 (file)
@@ -1,3 +1,14 @@
+2004-12-05  Darin Adler  <darin@apple.com>
+
+        - fixed small problem in my check-in from yesterday
+
+        * kwq/KWQEvent.mm:
+        (positionForEvent): Get location from event without raising exception if it's the wrong type.
+        (clickCountForEvent): Same, for clickCount.
+        (QMouseEvent::QMouseEvent): Use the new helper functions so this can be constructed even with
+        the wrong type of NSEvent. Required for cases where a keyboard event causes a "click" and we need
+        to synthesize a QMouseEvent for KHTML internal use, using the key down NSEvent.
+
 2004-12-04  Darin Adler  <darin@apple.com>
 
         Reviewed by John.
index a1118b8862c68887cc55c0fb1631c7891286b85b..d15dc8177397a4aeb44d2be68dbf50e55abc6337 100644 (file)
@@ -746,6 +746,42 @@ static int nonMouseButtonsForEvent(NSEvent *event)
     return buttons;
 }
 
+static QPoint positionForEvent(NSEvent *event)
+{
+    switch ([event type]) {
+        case NSLeftMouseDown:
+        case NSLeftMouseUp:
+        case NSLeftMouseDragged:
+        case NSRightMouseDown:
+        case NSRightMouseUp:
+        case NSRightMouseDragged:
+        case NSOtherMouseDown:
+        case NSOtherMouseUp:
+        case NSOtherMouseDragged:
+            return QPoint([event locationInWindow]);
+        default:
+            return QPoint();
+    }
+}
+
+static int clickCountForEvent(NSEvent *event)
+{
+    switch ([event type]) {
+        case NSLeftMouseDown:
+        case NSLeftMouseUp:
+        case NSLeftMouseDragged:
+        case NSRightMouseDown:
+        case NSRightMouseUp:
+        case NSRightMouseDragged:
+        case NSOtherMouseDown:
+        case NSOtherMouseUp:
+        case NSOtherMouseDragged:
+            return [event clickCount];
+        default:
+            return 0;
+    }
+}
+
 // ======== 
 
 QEvent::~QEvent()
@@ -762,10 +798,10 @@ QMouseEvent::QMouseEvent(Type type, const QPoint &position, int button, int stat
 
 QMouseEvent::QMouseEvent(Type type, NSEvent *event)
     : QEvent(type)
-    , _position([event locationInWindow])
+    , _position(positionForEvent(event))
     , _button(mouseButtonForEvent(event))
     , _state(nonMouseButtonsForEvent(event))
-    , _clickCount([event clickCount])
+    , _clickCount(clickCountForEvent(event))
 {
     fixState();
 }
@@ -775,10 +811,10 @@ QMouseEvent::QMouseEvent(Type type)
 {
     NSEvent *event = [NSApp currentEvent];
     if (event) {
-        _position = QPoint([event locationInWindow]);
+        _position = positionForEvent(event);
         _button = mouseButtonForEvent(event);
         _state = nonMouseButtonsForEvent(event);
-        _clickCount = [event clickCount];
+        _clickCount = clickCountForEvent(event);
     }
     fixState();
 }