XI2: don't translate button releases as scroll events

This fixes scroll-by-2 sympoms seen in combo boxes.
https://bugzilla.gnome.org/show_bug.cgi?id=639846
This commit is contained in:
Matthias Clasen 2011-02-04 12:51:46 -05:00
parent 03df034684
commit 272aa7bc55

View File

@ -1016,7 +1016,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
parent_iface->translate_event (translator, display, event, xevent)) parent_iface->translate_event (translator, display, event, xevent))
{ {
GdkDevice *device; GdkDevice *device;
g_print ("translating core keypress with keycode 0 and state %d\n", xevent->xkey.state);
/* The core device manager sets a core device on the event. /* The core device manager sets a core device on the event.
* We need to override that with an XI2 device, since we are * We need to override that with an XI2 device, since we are
* using XI2. * using XI2.
@ -1132,33 +1132,38 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
case 5: case 5:
case 6: case 6:
case 7: case 7:
event->scroll.type = GDK_SCROLL; /* Button presses of button 4-7 are scroll events */
if (ev->evtype == XI_ButtonPress)
{
event->scroll.type = GDK_SCROLL;
if (xev->detail == 4) if (xev->detail == 4)
event->scroll.direction = GDK_SCROLL_UP; event->scroll.direction = GDK_SCROLL_UP;
else if (xev->detail == 5) else if (xev->detail == 5)
event->scroll.direction = GDK_SCROLL_DOWN; event->scroll.direction = GDK_SCROLL_DOWN;
else if (xev->detail == 6) else if (xev->detail == 6)
event->scroll.direction = GDK_SCROLL_LEFT; event->scroll.direction = GDK_SCROLL_LEFT;
else else
event->scroll.direction = GDK_SCROLL_RIGHT; event->scroll.direction = GDK_SCROLL_RIGHT;
event->scroll.window = window; event->scroll.window = window;
event->scroll.time = xev->time; event->scroll.time = xev->time;
event->scroll.x = (gdouble) xev->event_x; event->scroll.x = (gdouble) xev->event_x;
event->scroll.y = (gdouble) xev->event_y; event->scroll.y = (gdouble) xev->event_y;
event->scroll.x_root = (gdouble) xev->root_x; event->scroll.x_root = (gdouble) xev->root_x;
event->scroll.y_root = (gdouble) xev->root_y; event->scroll.y_root = (gdouble) xev->root_y;
event->scroll.device = g_hash_table_lookup (device_manager->id_table, event->scroll.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid)); GUINT_TO_POINTER (xev->deviceid));
source_device = g_hash_table_lookup (device_manager->id_table, source_device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->sourceid)); GUINT_TO_POINTER (xev->sourceid));
gdk_event_set_source_device (event, source_device); gdk_event_set_source_device (event, source_device);
event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons); event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons);
break; break;
}
/* else (XI_ButtonRelease) fall thru */
default: default:
event->button.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE; event->button.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;