+#define SCROLL_INCREMENT_LINES 5
+
+#if GTK_CHECK_VERSION(3,4,0)
+gboolean scroll_internal(struct gui_data *inst, gdouble delta, guint state,
+ gdouble ex, gdouble ey)
+{
+ int shift, ctrl, alt, x, y, raw_mouse_mode;
+
+ show_mouseptr(inst, 1);
+
+ shift = state & GDK_SHIFT_MASK;
+ ctrl = state & GDK_CONTROL_MASK;
+ alt = state & inst->meta_mod_mask;
+
+ x = (ex - inst->window_border) / inst->font_width;
+ y = (ey - inst->window_border) / inst->font_height;
+
+ raw_mouse_mode =
+ send_raw_mouse && !(shift && conf_get_int(inst->conf,
+ CONF_mouse_override));
+
+ inst->cumulative_scroll += delta * SCROLL_INCREMENT_LINES;
+
+ if (!raw_mouse_mode) {
+ int scroll_lines = (int)inst->cumulative_scroll; /* rounds toward 0 */
+ if (scroll_lines) {
+ term_scroll(inst->term, 0, scroll_lines);
+ inst->cumulative_scroll -= scroll_lines;
+ }
+ return TRUE;
+ } else {
+ int scroll_events = (int)(inst->cumulative_scroll /
+ SCROLL_INCREMENT_LINES);
+ if (scroll_events) {
+ int button;
+
+ inst->cumulative_scroll -= scroll_events * SCROLL_INCREMENT_LINES;
+
+ if (scroll_events > 0) {
+ button = MBT_WHEEL_DOWN;
+ } else {
+ button = MBT_WHEEL_UP;
+ scroll_events = -scroll_events;
+ }
+
+ while (scroll_events-- > 0) {
+ term_mouse(inst->term, button, translate_button(button),
+ MA_CLICK, x, y, shift, ctrl, alt);
+ }
+ }
+ return TRUE;
+ }
+}
+#endif
+