Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse side buttons for previous/next page #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/manual-mupdf-gl.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ <h2>Mouse Bindings</h2>

<p>
The right mouse button selects a region and copies the marked text to the clipboard.

<p>
The mouse4/mouse5 side buttons go one page backward/forward.

<h2>Key Bindings</h2>

Expand Down
2 changes: 2 additions & 0 deletions platform/gl/gl-app.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum
KEY_F10,
KEY_F11,
KEY_F12,
MOUSE_SIDE_1,
MOUSE_SIDE_2,
};

enum side { ALL, T, R, B, L };
Expand Down
4 changes: 2 additions & 2 deletions platform/gl/gl-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions platform/gl/gl-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down