Commit 3ce8dadb authored by eric@webkit.org's avatar eric@webkit.org

2009-11-24 Evan Stade <estade@chromium.org>

        Reviewed by David Levin.

        Linux Chromium sends too many click events
        https://bugs.webkit.org/show_bug.cgi?id=31841

        Manually count number of clicks for double/triple click events. This
        makes us match Firefox on http://www.quirksmode.org/js/events_mouse.html
        Chromium side of this patch is here:
        http://codereview.chromium.org/431031/show

        * src/gtk/WebInputEventFactory.cpp:
        (WebKit::WebInputEventFactory::mouseEvent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6fbc13cc
2009-11-24 Evan Stade <estade@chromium.org>
Reviewed by David Levin.
Linux Chromium sends too many click events
https://bugs.webkit.org/show_bug.cgi?id=31841
Manually count number of clicks for double/triple click events. This
makes us match Firefox on http://www.quirksmode.org/js/events_mouse.html
Chromium side of this patch is here:
http://codereview.chromium.org/431031/show
* src/gtk/WebInputEventFactory.cpp:
(WebKit::WebInputEventFactory::mouseEvent):
2009-11-24 Darin Fisher <darin@chromium.org>
Reviewed by Adam Barth.
......
......@@ -38,10 +38,23 @@
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gtk/gtkversion.h>
#include <wtf/Assertions.h>
namespace {
gint getDoubleClickTime()
{
static GtkSettings* settings = gtk_settings_get_default();
gint doubleClickTime = 250;
g_object_get(G_OBJECT(settings), "gtk-double-click-time", &doubleClickTime, 0);
return doubleClickTime;
}
} // namespace
namespace WebKit {
static double gdkEventTimeToWebEventTime(guint32 time)
......@@ -321,24 +334,34 @@ WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
result.clickCount = 0;
switch (event->type) {
case GDK_3BUTTON_PRESS:
++result.clickCount;
// fallthrough
case GDK_2BUTTON_PRESS:
++result.clickCount;
// fallthrough
case GDK_BUTTON_PRESS:
result.type = WebInputEvent::MouseDown;
++result.clickCount;
break;
case GDK_BUTTON_RELEASE:
result.type = WebInputEvent::MouseUp;
break;
case GDK_3BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
default:
ASSERT_NOT_REACHED();
};
if (GDK_BUTTON_PRESS == event->type) {
static int numClicks = 0;
static GdkWindow* eventWindow = 0;
static gint lastLeftClickTime = 0;
gint time_diff = event->time - lastLeftClickTime;
if (eventWindow == event->window && time_diff < getDoubleClickTime())
numClicks++;
else
numClicks = 1;
result.clickCount = numClicks;
eventWindow = event->window;
lastLeftClickTime = event->time;
}
result.button = WebMouseEvent::ButtonNone;
if (event->button == 1)
result.button = WebMouseEvent::ButtonLeft;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment