diff options
author | Xin LI <delphij@FreeBSD.org> | 2011-05-18 00:25:45 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2011-05-18 00:25:45 +0000 |
commit | f3009f8faa948f7b10b6c50c42dab034bddb1cd6 (patch) | |
tree | b93568378cc904fb7b4f18eb80b35cc3a0f5f94e /graphics | |
parent | 0ab1c134c9938b6dda08a59cbad78d8e0aff839d (diff) | |
download | ports-f3009f8faa948f7b10b6c50c42dab034bddb1cd6.tar.gz ports-f3009f8faa948f7b10b6c50c42dab034bddb1cd6.zip |
- Instead of using a hardcoded DPI, obtain it from X;
- Add an optional hack that allows j, k and mouse to scroll across
page boundary.
Submitted by: maintainer
PR: ports/157095 (with changes)
Notes
Notes:
svn path=/head/; revision=274247
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/mupdf/Makefile | 9 | ||||
-rw-r--r-- | graphics/mupdf/files/patch-apps_x11_main.c | 36 | ||||
-rw-r--r-- | graphics/mupdf/files/scroll_hack-apps_pdfapp.c | 46 |
3 files changed, 91 insertions, 0 deletions
diff --git a/graphics/mupdf/Makefile b/graphics/mupdf/Makefile index 043e6040f6d4..32e12bab8ba4 100644 --- a/graphics/mupdf/Makefile +++ b/graphics/mupdf/Makefile @@ -6,6 +6,7 @@ PORTNAME= mupdf PORTVERSION= 0.8.165 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= graphics MASTER_SITES= GOOGLE_CODE \ @@ -31,6 +32,14 @@ MAKE_JOBS_SAFE= yes LICENSE= GPLv3 LICENSE_FILE= ${WRKSRC}/COPYING +OPTIONS= SCROLL "Build with scroll hacks" on \ + +.include <bsd.port.options.mk> + +.if defined(WITH_SCROLL) +EXTRA_PATCHES+= ${FILESDIR}/scroll_hack-apps_pdfapp.c +.endif + post-patch: .SILENT ${REINPLACE_CMD} \ -e 's#\(PDF_APPS :=.*/\)#\1mu_#' \ diff --git a/graphics/mupdf/files/patch-apps_x11_main.c b/graphics/mupdf/files/patch-apps_x11_main.c new file mode 100644 index 000000000000..7395cb6cf7ff --- /dev/null +++ b/graphics/mupdf/files/patch-apps_x11_main.c @@ -0,0 +1,36 @@ +--- apps/x11_main.c.orig 2011-05-16 23:18:12.046785782 -0500 ++++ apps/x11_main.c 2011-05-16 23:24:55.669305772 -0500 +@@ -563,6 +563,24 @@ static void winresettmo(struct timeval * + tmo_at->tv_usec = 0; + } + ++/* reference: ++ * http://stackoverflow.com/questions/2621439/how-to-get-screen-dpi-linux-mac-programatically ++ */ ++int get_dpi(void) ++{ ++ Display *xdpy; ++ int xscr; ++ int x = 0; ++ ++ if ((xdpy = XOpenDisplay(NULL))) { ++ xscr = DefaultScreen(xdpy); ++ x = (int) (DisplayWidth(xdpy, xscr) * 25.4 / ++ DisplayWidthMM(xdpy, xscr) + 0.5); ++ XCloseDisplay(xdpy); ++ } ++ return x; ++} ++ + int main(int argc, char **argv) + { + int c; +@@ -571,7 +589,7 @@ int main(int argc, char **argv) + KeySym keysym; + int oldx = 0; + int oldy = 0; +- int resolution = 72; ++ int resolution = get_dpi(); + int pageno = 1; + int wasshowingpage; + struct timeval tmo, tmo_at; diff --git a/graphics/mupdf/files/scroll_hack-apps_pdfapp.c b/graphics/mupdf/files/scroll_hack-apps_pdfapp.c new file mode 100644 index 000000000000..c0cfc7d04688 --- /dev/null +++ b/graphics/mupdf/files/scroll_hack-apps_pdfapp.c @@ -0,0 +1,46 @@ +--- apps/pdfapp.c.orig 2011-04-29 14:06:09.000000000 -0500 ++++ apps/pdfapp.c 2011-05-16 19:58:55.650380651 -0500 +@@ -777,11 +777,15 @@ void pdfapp_onkey(pdfapp_t *app, int c) + break; + + case 'j': ++ if (app->pany + app->image->h <= app->winh) ++ goto pagedown; + app->pany -= app->image->h / 10; + pdfapp_showpage(app, 0, 0, 1); + break; + + case 'k': ++ if (app->pany >= 0) ++ goto pageup; + app->pany += app->image->h / 10; + pdfapp_showpage(app, 0, 0, 1); + break; +@@ -843,6 +847,7 @@ void pdfapp_onkey(pdfapp_t *app, int c) + */ + + case ',': ++ pageup: + panto = PAN_TO_BOTTOM; + if (app->numberlen > 0) + app->pageno -= atoi(app->number); +@@ -851,6 +856,7 @@ void pdfapp_onkey(pdfapp_t *app, int c) + break; + + case '.': ++ pagedown: + panto = PAN_TO_TOP; + if (app->numberlen > 0) + app->pageno += atoi(app->number); +@@ -1022,6 +1028,11 @@ void pdfapp_onmouse(pdfapp_t *app, int x + int isx = (modifiers & (1<<0)); + int xstep = isx ? 20 * dir : 0; + int ystep = !isx ? 20 * dir : 0; ++ if (!isx && dir < 0 && app->pany + app->image->h <= app->winh) ++ pdfapp_onkey(app, 'j'); ++ else if (!isx && dir > 0 && app->pany >= 0) ++ pdfapp_onkey(app, 'k'); ++ else + pdfapp_panview(app, app->panx + xstep, app->pany + ystep); + } + } |