Commit 90f6f5dd authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Mouse scroll events

parent 21a65cbe
......@@ -134,8 +134,10 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
/* mouse events */
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, 0, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, 0, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, 0, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, 0, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, 0, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, 0, NULL);
/* define default inputbar commands */
girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark");
......
......@@ -207,6 +207,38 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
return false;
}
bool
sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t)
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(event != NULL, false);
if (zathura->document == NULL) {
return false;
}
/* scroll event */
if (event->type == GIRARA_EVENT_SCROLL) {
switch (event->direction) {
case GIRARA_SCROLL_UP:
argument->n = ZOOM_IN;
break;
case GIRARA_SCROLL_DOWN:
argument->n = ZOOM_OUT;
break;
default:
return false;
}
return sc_zoom(session, argument, NULL, t);
}
return false;
}
bool
sc_navigate(girara_session_t* session, girara_argument_t* argument,
girara_event_t* UNUSED(event), unsigned int t)
......
......@@ -71,6 +71,17 @@ bool sc_goto(girara_session_t* session, girara_argument_t* argument, girara_even
*/
bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Handle mouse zoom events
*
* @param session The used girara session
* @param argument The used argument
* @param event Girara event
* @param t Number of executions
* @return true if no error occured otherwise false
*/
bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Navigate through the document
*
......
Supports Markdown
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