RESOLVED FIXED 174674
[WPE] Implement click counting in mouse events
https://bugs.webkit.org/show_bug.cgi?id=174674
Summary [WPE] Implement click counting in mouse events
Claudio Saavedra
Reported 2017-07-20 07:14:09 PDT
WPE does not provide single-, double-, etc. click information, but this can be implemented in WebEventFactory. This missing information currently breaks fast/events/click-count.html.
Attachments
Patch (5.38 KB, patch)
2017-07-27 04:08 PDT, Claudio Saavedra
no flags
Patch (7.05 KB, patch)
2017-07-28 07:06 PDT, Claudio Saavedra
clopez: review-
Claudio Saavedra
Comment 1 2017-07-27 04:08:03 PDT
Zan Dobersek
Comment 2 2017-07-27 23:42:49 PDT
Comment on attachment 316544 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316544&action=review > Source/WebKit/Shared/wpe/WebEventFactory.cpp:89 > + static struct wpe_input_pointer_event m_lastClickEvent; This should be zero-initialized: `static struct wpe_input_pointer_event m_lastClickEvent = { 0, };` Might be the zero-init is guaranteed because the variable is static, but it's better to be explicit. > Source/WebKit/Shared/wpe/WebEventFactory.cpp:99 > + if (event->time - m_lastClickEvent.time < 1 && event->x == m_lastClickEvent.x && event->y == m_lastClickEvent.y && event->button == m_lastClickEvent.button) > + m_clickCount++; > + else > + m_clickCount = 1; Difference in time between the two events should be somehow made configurable in the future. I don't know exactly what time unit is used for the input event time, and it could differ from platform to platform anyway. Should the click count be upwards-limited? As it stands it can grow uncapped.
Claudio Saavedra
Comment 3 2017-07-28 05:03:17 PDT
Comment on attachment 316544 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316544&action=review >> Source/WebKit/Shared/wpe/WebEventFactory.cpp:99 >> + m_clickCount = 1; > > Difference in time between the two events should be somehow made configurable in the future. I don't know exactly what time unit is used for the input event time, and it could differ from platform to platform anyway. > > Should the click count be upwards-limited? As it stands it can grow uncapped. It only grows if it's happening in the same position and quickly enough to be counted as consecutive clicks, otherwise it is reset back to 1. WebKit uses this count to decide when it's a double or a triple click, and then again single, double, etc. As is I don't think it's a problem if it keeps growing.. As for the time between events, it seems to be a timestamp, so it's seconds. We can make it configurable at some point, not sure where would that go.
Claudio Saavedra
Comment 4 2017-07-28 07:06:01 PDT
Darin Adler
Comment 5 2017-07-30 14:19:45 PDT
Comment on attachment 316637 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316637&action=review > Source/WebKit/Shared/wpe/WebEventFactory.cpp:90 > + static struct wpe_input_pointer_event m_lastClickEvent = { }; > + static unsigned m_clickCount = 1; A function-private global variable should not have the prefix "m_" like this. The design pattern here is dangerous. It requires that we ask this question about each event once. If you call the function a second time or call it out of order then it does the wrong thing. I don’t see code elsewhere that guarantees or relies that this will be called exactly once for each event. > Source/WebKit/Shared/wpe/WebEventFactory.cpp:96 > + if (event->time - m_lastClickEvent.time < 1 && event->x == m_lastClickEvent.x && event->y == m_lastClickEvent.y && event->button == m_lastClickEvent.button) Typically, requiring that x and y being exactly the same is too strict a rule for double clicking. What is the unit for "time"? Typically 1 second is too long a time to define close enough in time to be a double click.
Carlos Alberto Lopez Perez
Comment 6 2017-10-10 12:13:41 PDT
Comment on attachment 316637 [details] Patch Setting r- due to Darin comments, please address them and upload a new patch.
Diego Pino
Comment 7 2023-07-04 22:03:46 PDT
EWS
Comment 8 2023-07-06 09:45:41 PDT
Committed 265808@main (0482f3984fab): <https://commits.webkit.org/265808@main> Reviewed commits have been landed. Closing PR #15555 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.