diff --git a/docs/manual-mupdf-gl.html b/docs/manual-mupdf-gl.html
index 367b46a5a1..a036e05748 100644
--- a/docs/manual-mupdf-gl.html
+++ b/docs/manual-mupdf-gl.html
@@ -47,6 +47,9 @@
Mouse Bindings
The right mouse button selects a region and copies the marked text to the clipboard.
+
+
+The mouse4/mouse5 side buttons go one page backward/forward.
Key Bindings
diff --git a/platform/gl/gl-app.h b/platform/gl/gl-app.h
index 7f91484e8e..f357f3b450 100644
--- a/platform/gl/gl-app.h
+++ b/platform/gl/gl-app.h
@@ -53,6 +53,8 @@ enum
KEY_F10,
KEY_F11,
KEY_F12,
+ MOUSE_SIDE_1,
+ MOUSE_SIDE_2,
};
enum side { ALL, T, R, B, L };
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index 1bbdfa0588..dfd3bd8414 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -1417,12 +1417,12 @@ static void do_app(void)
case 'g': jump_to_page(number - 1); break;
case 'G': jump_to_location(fz_last_page(ctx, doc)); break;
- case ',': case KEY_PAGE_UP:
+ case ',': case KEY_PAGE_UP: case MOUSE_SIDE_1:
number = fz_maxi(number, 1);
while (number--)
currentpage = fz_previous_page(ctx, doc, currentpage);
break;
- case '.': case KEY_PAGE_DOWN:
+ case '.': case KEY_PAGE_DOWN: case MOUSE_SIDE_2:
number = fz_maxi(number, 1);
while (number--)
currentpage = fz_next_page(ctx, doc, currentpage);
diff --git a/platform/gl/gl-ui.c b/platform/gl/gl-ui.c
index 61111dedf0..376bc08b12 100644
--- a/platform/gl/gl-ui.c
+++ b/platform/gl/gl-ui.c
@@ -307,6 +307,8 @@ static void on_mouse(int button, int action, int x, int y)
case 4: on_wheel(0, -1, x, y); break;
case 5: on_wheel(1, 1, x, y); break;
case 6: on_wheel(1, -1, x, y); break;
+ case 7: ui.key = MOUSE_SIDE_1; break;
+ case 8: ui.key = MOUSE_SIDE_2; break;
}
}
else if (action == GLUT_UP)
@@ -319,7 +321,9 @@ static void on_mouse(int button, int action, int x, int y)
}
}
ui.mod = glutGetModifiers();
+ ui.plain = !(ui.mod & ~GLUT_ACTIVE_SHIFT);
run_main_loop();
+ ui.key = ui.plain = 0;
ui_invalidate(); // TODO: leave this to caller
}