Commit e051496b authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge remote-tracking branch 'projedi/smooth-scroll' into develop

parents 5834e6b5 56a5e0c4
......@@ -321,6 +321,8 @@ girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scr
event.x = scroll->x;
event.y = scroll->y;
double motion_direction[2];
switch (scroll->direction) {
case GDK_SCROLL_UP:
event.type = GIRARA_EVENT_SCROLL_UP;
......@@ -334,6 +336,10 @@ girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scr
case GDK_SCROLL_RIGHT:
event.type = GIRARA_EVENT_SCROLL_RIGHT;
break;
case GDK_SCROLL_SMOOTH:
event.type = GIRARA_EVENT_SCROLL_BIDIRECTIONAL;
gdk_event_get_scroll_deltas((GdkEvent*)scroll, motion_direction, motion_direction + 1);
break;
default:
return false;
}
......@@ -348,6 +354,7 @@ girara_callback_view_scroll_event(GtkWidget* UNUSED(widget), GdkEventScroll* scr
&& mouse_event->event_type == event.type
&& (session->modes.current_mode == mouse_event->mode || mouse_event->mode == 0)
) {
mouse_event->argument.data = motion_direction;
mouse_event->function(session, &(mouse_event->argument), &event, session->buffer.n);
girara_list_iterator_free(iter);
return true;
......
......@@ -203,6 +203,7 @@ girara_config_load_default(girara_session_t* session)
int n_completion_items = 15;
bool show_scrollbars = false;
girara_mode_t normal_mode = session->modes.normal;
bool use_smooth_scroll = false;
/* other values */
session->global.autohide_inputbar = true;
......@@ -243,6 +244,7 @@ girara_config_load_default(girara_session_t* session)
girara_setting_add(session, "window-icon", "", STRING, FALSE, _("Window icon"), cb_window_icon, NULL);
girara_setting_add(session, "exec-command", "", STRING, FALSE, _("Command to execute in :exec"), NULL, NULL);
girara_setting_add(session, "guioptions", "s", STRING, FALSE, _("Show or hide certain GUI elements"), cb_guioptions, NULL);
girara_setting_add(session, "smooth-scroll", &use_smooth_scroll, BOOLEAN, TRUE, _("Enable smooth scrolling and zooming"), NULL, NULL);
/* shortcuts */
girara_shortcut_add(session, 0, GDK_KEY_Escape, NULL, girara_sc_abort, normal_mode, 0, NULL);
......
......@@ -309,6 +309,14 @@ girara_session_init(girara_session_t* session, const char* sessionname)
return false;
}
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 4
bool smooth_scroll = false;
girara_setting_get(session, "smooth-scroll", &smooth_scroll);
if (smooth_scroll) {
gtk_widget_add_events(session->gtk.viewport, GDK_SMOOTH_SCROLL_MASK);
}
#endif
session->private_data->session_name = g_strdup(
(sessionname == NULL) ? "girara" : sessionname);
......
......@@ -196,7 +196,13 @@ typedef enum girara_event_type_e
GIRARA_EVENT_SCROLL_DOWN, /**< Scroll event */
GIRARA_EVENT_SCROLL_LEFT, /**< Scroll event */
GIRARA_EVENT_SCROLL_RIGHT, /**< Scroll event */
GIRARA_EVENT_OTHER /**< Unknown event */
GIRARA_EVENT_OTHER, /**< Unknown event */
GIRARA_EVENT_SCROLL_BIDIRECTIONAL /**< Scroll event that carries extra data
* in girara_argument_t with motion
* information as double[2].
* First component is horizontal shift,
* second - vertical.
*/
} girara_event_type_t;
/**
......
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