mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:16:00 +01:00
Pan by using mouse button 2
This commit is contained in:
parent
427b8eb51c
commit
d2fc051f36
2 changed files with 30 additions and 6 deletions
13
config.c
13
config.c
|
@ -136,12 +136,13 @@ config_load_default(zathura_t* zathura)
|
|||
girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
|
||||
|
||||
/* mouse events */
|
||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
|
||||
girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_PRESS, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_RELEASE, 0, NULL);
|
||||
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL);
|
||||
|
||||
/* define default inputbar commands */
|
||||
girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark");
|
||||
|
|
23
shortcuts.c
23
shortcuts.c
|
@ -186,6 +186,9 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
|
|||
g_return_val_if_fail(argument != NULL, false);
|
||||
g_return_val_if_fail(event != NULL, false);
|
||||
|
||||
static int x = 0;
|
||||
static int y = 0;
|
||||
|
||||
if (zathura->document == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -208,7 +211,27 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
|
|||
}
|
||||
|
||||
return sc_scroll(session, argument, NULL, t);
|
||||
} else if (event->type == GIRARA_EVENT_BUTTON_PRESS) {
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
} else if (event->type == GIRARA_EVENT_BUTTON_RELEASE) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
} else if (event->type == GIRARA_EVENT_MOTION_NOTIFY) {
|
||||
GtkAdjustment* x_adj =
|
||||
gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
GtkAdjustment* y_adj =
|
||||
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
|
||||
if (x_adj == NULL || y_adj == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_adjustment(x_adj, gtk_adjustment_get_value(x_adj) - (event->x - x));
|
||||
set_adjustment(y_adj, gtk_adjustment_get_value(y_adj) - (event->y - y));
|
||||
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue