Bug 65875 - [Qt][WK2] MiniBrowser is firing twice the QDesktopWebView::mousePressEvent method
Summary: [Qt][WK2] MiniBrowser is firing twice the QDesktopWebView::mousePressEvent me...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks: 62191
  Show dependency treegraph
 
Reported: 2011-08-08 14:12 PDT by Igor Trindade Oliveira
Modified: 2011-08-10 14:52 PDT (History)
3 users (show)

See Also:


Attachments
Patch. (2.03 KB, patch)
2011-08-08 14:19 PDT, Igor Trindade Oliveira
benjamin: review-
Details | Formatted Diff | Diff
Test Case (473 bytes, text/html)
2011-08-09 12:32 PDT, Igor Trindade Oliveira
no flags Details
Patch (2.51 KB, patch)
2011-08-09 16:59 PDT, Igor Trindade Oliveira
igor.oliveira: review-
igor.oliveira: commit-queue-
Details | Formatted Diff | Diff
Patch (2.51 KB, patch)
2011-08-09 17:01 PDT, Igor Trindade Oliveira
benjamin: review-
Details | Formatted Diff | Diff
Patch (3.15 KB, patch)
2011-08-10 10:16 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff
Patch (3.74 KB, patch)
2011-08-10 11:32 PDT, Igor Trindade Oliveira
no flags Details | Formatted Diff | Diff
Patch (1.52 KB, patch)
2011-08-10 12:00 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (2.04 KB, patch)
2011-08-10 12:51 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Trindade Oliveira 2011-08-08 14:12:57 PDT
Using MiniBrowser i noticed it is firing twice the QDesktopWebView::mousePressEvent method when the moused is pressed anywhere on the screen.
Comment 1 Igor Trindade Oliveira 2011-08-08 14:19:13 PDT
Created attachment 103291 [details]
Patch.

Proposed patch
Comment 2 Benjamin Poulain 2011-08-08 15:28:48 PDT
Comment on attachment 103291 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=103291&action=review

> Tools/MiniBrowser/qt/MiniBrowserApplication.cpp:107
>              if (m_touchPoints.contains(touchPoint.id()))
>                  touchPoint.setState(Qt::TouchPointMoved);
> -            else
> -                touchPoint.setState(Qt::TouchPointPressed);
> +            else {
> +                if (mouseEvent->modifiers().testFlag(Qt::ControlModifier))
> +                    touchPoint.setState(Qt::TouchPointPressed);
> +            }

It seems to me that the problem might be that m_touchPoints.contains(touchPoint.id()) == false.
If the touchpoint is still active because, it should be in m_touchPoints.
Comment 3 Igor Trindade Oliveira 2011-08-09 12:32:07 PDT
Created attachment 103384 [details]
Test Case

Adding Test case.
Comment 4 Igor Trindade Oliveira 2011-08-09 12:35:55 PDT
Probably we are talking about two different things. I added a test case where onmousedown event is firing two times the callback. It happens because  QDesktopWebView::mousePressEvent is called twice.

(In reply to comment #2)
> (From update of attachment 103291 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=103291&action=review
> 
> > Tools/MiniBrowser/qt/MiniBrowserApplication.cpp:107
> >              if (m_touchPoints.contains(touchPoint.id()))
> >                  touchPoint.setState(Qt::TouchPointMoved);
> > -            else
> > -                touchPoint.setState(Qt::TouchPointPressed);
> > +            else {
> > +                if (mouseEvent->modifiers().testFlag(Qt::ControlModifier))
> > +                    touchPoint.setState(Qt::TouchPointPressed);
> > +            }
> 
> It seems to me that the problem might be that m_touchPoints.contains(touchPoint.id()) == false.
> If the touchpoint is still active because, it should be in m_touchPoints.
Comment 5 Igor Trindade Oliveira 2011-08-09 16:59:41 PDT
Created attachment 103418 [details]
Patch

Updating proposed patch with a better ChangeLog explaining the modifications.
Comment 6 WebKit Review Bot 2011-08-09 17:01:07 PDT
Attachment 103418 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/MiniBrowser/qt/M..." exit_code: 1

Tools/MiniBrowser/qt/MiniBrowserApplication.cpp:104:  Missing space before ( in if(  [whitespace/parens] [5]
Total errors found: 1 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Igor Trindade Oliveira 2011-08-09 17:01:27 PDT
Created attachment 103419 [details]
Patch

Proposed patch.
Comment 8 Benjamin Poulain 2011-08-10 06:20:50 PDT
Comment on attachment 103419 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=103419&action=review

This has nothing to do with the ControlModifier. The problem is we still send the original mouse event after we send the touch events. QWidget also generate a fake mouse event for the touch event so we end up with 2 mouse events. The original event should be discarded when a touch event is generated.

> Tools/ChangeLog:9
> +        On some windowing systems, mouse events are also sent for the primary touch point. This
> +        means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the
> +        same user interaction point. MiniBrowser when setting the Qt::TouchPointPressed for a touch

Qt is supposed to always give you a mouse event for the primary touch point.

> Tools/ChangeLog:12
> +        to be called twice for a single mouse click. Now the Qt::TouchPointPressed is used just
> +        when Ctrl modifier is pressed.

This is not at all the intended behavior of the code of touch mocking.
Comment 9 Igor Trindade Oliveira 2011-08-10 10:16:37 PDT
Created attachment 103500 [details]
Patch

Proposed patch.
Comment 10 Igor Trindade Oliveira 2011-08-10 11:32:43 PDT
Created attachment 103509 [details]
Patch

Updated patch.
Comment 11 Benjamin Poulain 2011-08-10 12:00:46 PDT
Created attachment 103513 [details]
Patch
Comment 12 Benjamin Poulain 2011-08-10 12:02:18 PDT
Shouldn't this approach just work?
Comment 13 Benjamin Poulain 2011-08-10 12:16:25 PDT
Comment on attachment 103513 [details]
Patch

I cq-, let's not land that before Igor has a look.
Comment 14 Benjamin Poulain 2011-08-10 12:51:23 PDT
Created attachment 103520 [details]
Patch
Comment 15 Kenneth Rohde Christiansen 2011-08-10 13:59:30 PDT
Comment on attachment 103520 [details]
Patch

Looks OK. If this solves it, r=me
Comment 16 Benjamin Poulain 2011-08-10 14:42:23 PDT
Comment on attachment 103520 [details]
Patch

Let's land that. Freaking QWidget hacks... :)
Comment 17 WebKit Review Bot 2011-08-10 14:52:05 PDT
Comment on attachment 103520 [details]
Patch

Clearing flags on attachment: 103520

Committed r92799: <http://trac.webkit.org/changeset/92799>
Comment 18 WebKit Review Bot 2011-08-10 14:52:11 PDT
All reviewed patches have been landed.  Closing bug.