Skip to content

Commit

Permalink
[LibWPE] Fix click count logic
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259000

Reviewed by Michael Catanzaro.

When comparing screen coordinates for a click `==` was used instead of
a subtraction. Also modify the threshold to be an int so there isn't
a type warning since `std::abs` outputs an `int` not an `unsigned`.

* Source/WebKit/Shared/libwpe/WebEventFactory.cpp:
(WebKit::clickCount):

Canonical link: https://commits.webkit.org/265874@main
  • Loading branch information
donny-dont committed Jul 8, 2023
1 parent 6a797e1 commit 4776b34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/WebKit/Shared/libwpe/WebEventFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ static inline short pressedMouseButtons(uint32_t modifiers)
static inline unsigned clickCount(struct wpe_input_pointer_event* event)
{
static const uint32_t doubleClickTime = 500; // Milliseconds.
static const unsigned pixelThreshold = 5;
static const int pixelThreshold = 5;
static struct wpe_input_pointer_event gLastClickEvent = { };
static unsigned gLastClickCount = 1;

bool cancelPreviousClick = (event->time - gLastClickEvent.time) > doubleClickTime
|| abs(event->x == gLastClickEvent.x) > pixelThreshold
|| abs(event->y == gLastClickEvent.y) > pixelThreshold;
|| std::abs(event->x - gLastClickEvent.x) > pixelThreshold
|| std::abs(event->y - gLastClickEvent.y) > pixelThreshold;

if (event->type == wpe_input_pointer_event_type_button && event->state) {
if (!cancelPreviousClick && (event->button == gLastClickEvent.button))
Expand Down

0 comments on commit 4776b34

Please sign in to comment.