union buffered_input_event inev;
struct frame *f, *frame;
struct pgtk_display_info *dpyinfo;
+ GdkScrollDirection dir;
+ double delta_x, delta_y;
EVENT_INIT (inev.ie);
inev.ie.kind = NO_EVENT;
else
f = pgtk_any_window_to_frame (gtk_widget_get_window (widget));
- inev.ie.kind = WHEEL_EVENT;
+ inev.ie.kind = NO_EVENT;
inev.ie.timestamp = event->scroll.time;
inev.ie.modifiers =
pgtk_gtk_to_emacs_modifiers (FRAME_DISPLAY_INFO (f), event->scroll.state);
XSETFRAME (inev.ie.frame_or_window, f);
inev.ie.arg = Qnil;
- switch (event->scroll.direction)
+ if (gdk_event_get_scroll_direction (event, &dir))
{
- case GDK_SCROLL_UP:
- inev.ie.kind = WHEEL_EVENT;
- inev.ie.modifiers |= up_modifier;
- break;
- case GDK_SCROLL_DOWN:
- inev.ie.kind = WHEEL_EVENT;
- inev.ie.modifiers |= down_modifier;
- break;
- case GDK_SCROLL_LEFT:
- inev.ie.kind = HORIZ_WHEEL_EVENT;
- inev.ie.modifiers |= up_modifier;
- break;
- case GDK_SCROLL_RIGHT:
- inev.ie.kind = HORIZ_WHEEL_EVENT;
- inev.ie.modifiers |= down_modifier;
- break;
- case GDK_SCROLL_SMOOTH:
- if (event->scroll.delta_y >= 0.5)
+ switch (dir)
{
+ case GDK_SCROLL_UP:
+ inev.ie.kind = WHEEL_EVENT;
+ inev.ie.modifiers |= up_modifier;
+ break;
+ case GDK_SCROLL_DOWN:
inev.ie.kind = WHEEL_EVENT;
inev.ie.modifiers |= down_modifier;
+ break;
+ case GDK_SCROLL_LEFT:
+ inev.ie.kind = HORIZ_WHEEL_EVENT;
+ inev.ie.modifiers |= up_modifier;
+ break;
+ case GDK_SCROLL_RIGHT:
+ inev.ie.kind = HORIZ_WHEEL_EVENT;
+ inev.ie.modifiers |= down_modifier;
+ break;
}
- else if (event->scroll.delta_y <= -0.5)
+ }
+ else if (gdk_event_get_scroll_deltas (event, &delta_x, &delta_y))
+ {
+ dpyinfo->scroll.acc_x += delta_x;
+ dpyinfo->scroll.acc_y += delta_y;
+ if (dpyinfo->scroll.acc_y >= dpyinfo->scroll.y_per_line)
{
+ int nlines = dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
+ inev.ie.kind = WHEEL_EVENT;
+ inev.ie.modifiers |= down_modifier;
+ inev.ie.arg = make_fixnum(nlines);
+ dpyinfo->scroll.acc_y -= dpyinfo->scroll.y_per_line * nlines;
+ }
+ else if (dpyinfo->scroll.acc_y <= -dpyinfo->scroll.y_per_line)
+ {
+ int nlines = -dpyinfo->scroll.acc_y / dpyinfo->scroll.y_per_line;
inev.ie.kind = WHEEL_EVENT;
inev.ie.modifiers |= up_modifier;
+ inev.ie.arg = make_fixnum(nlines);
+ dpyinfo->scroll.acc_y -= -dpyinfo->scroll.y_per_line * nlines;
}
- else if (event->scroll.delta_x >= 0.5)
+ else if (dpyinfo->scroll.acc_x >= dpyinfo->scroll.x_per_char)
{
+ int nchars = dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
inev.ie.kind = HORIZ_WHEEL_EVENT;
- inev.ie.modifiers |= down_modifier;
+ inev.ie.modifiers |= up_modifier;
+ inev.ie.arg = make_fixnum(nchars);
+ dpyinfo->scroll.acc_x -= dpyinfo->scroll.x_per_char * nchars;
}
- else if (event->scroll.delta_x <= -0.5)
+ else if (dpyinfo->scroll.acc_x <= -dpyinfo->scroll.x_per_char)
{
+ int nchars = -dpyinfo->scroll.acc_x / dpyinfo->scroll.x_per_char;
inev.ie.kind = HORIZ_WHEEL_EVENT;
- inev.ie.modifiers |= up_modifier;
+ inev.ie.modifiers |= down_modifier;
+ inev.ie.arg = make_fixnum(nchars);
+ dpyinfo->scroll.acc_x -= -dpyinfo->scroll.x_per_char * nchars;
}
- else
- return TRUE;
- break;
- default:
- return TRUE;
}
if (inev.ie.kind != NO_EVENT)
dpyinfo->resy = dpi;
}
+ /* smooth scroll setting */
+ dpyinfo->scroll.x_per_char = 2;
+ dpyinfo->scroll.y_per_line = 2;
+
x_setup_pointer_blanking (dpyinfo);
xsettings_initialize (dpyinfo);