summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@hotmail.com>2011-01-06 18:36:55 +0000
committerSebastian Rasmussen <sebras@hotmail.com>2011-01-06 18:36:55 +0000
commita53b4dac2ed84d9d40420f0c88d05914f73c5556 (patch)
treee7e93ee194a677f52447dfce16d402a3543f3568
parent95d9c93d148c6b8e24a93f01a196e6b76cd61318 (diff)
downloadmupdf-a53b4dac2ed84d9d40420f0c88d05914f73c5556.tar.xz
Make panning and repainting optional when showing a page in x11 viewer.
-rw-r--r--apps/pdfapp.c101
1 files changed, 51 insertions, 50 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 20c27065..f07f0592 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -13,7 +13,7 @@ enum panning
PAN_TO_BOTTOM
};
-static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage);
+static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repaint);
static void pdfapp_warn(pdfapp_t *app, const char *fmt, ...)
{
@@ -168,7 +168,7 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd)
app->panx = 0;
app->pany = 0;
- pdfapp_showpage(app, 1, 1);
+ pdfapp_showpage(app, 1, 1, 1);
}
void pdfapp_close(pdfapp_t *app)
@@ -234,23 +234,20 @@ static void pdfapp_panview(pdfapp_t *app, int newx, int newy)
app->pany = newy;
}
-static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage)
+static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repaint)
{
char buf[256];
fz_error error;
fz_device *idev, *tdev, *mdev;
+ fz_colorspace *colorspace;
fz_matrix ctm;
fz_bbox bbox;
fz_obj *obj;
- sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle,
- app->pageno, app->pagecount, app->resolution);
- wintitle(app, buf);
+ wincursor(app, WAIT);
if (loadpage)
{
- wincursor(app, WAIT);
-
if (app->page)
pdf_freepage(app->page);
app->page = nil;
@@ -275,24 +272,25 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage)
app->hit = -1;
app->hitlen = 0;
+ /* Extract text */
+ app->page->text = fz_newtextspan();
+ tdev = fz_newtextdevice(app->page->text);
+ ctm = pdfapp_viewctm(app);
+ fz_executedisplaylist(app->page->list, tdev, ctm);
+ fz_freedevice(tdev);
+
pdf_agestore(app->xref->store, 3);
}
if (drawpage)
{
- fz_colorspace *colorspace;
-
- wincursor(app, WAIT);
+ sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle,
+ app->pageno, app->pagecount, app->resolution);
+ wintitle(app, buf);
ctm = pdfapp_viewctm(app);
bbox = fz_roundrect(fz_transformrect(ctm, app->page->mediabox));
- /* Extract text */
- app->page->text = fz_newtextspan();
- tdev = fz_newtextdevice(app->page->text);
- fz_executedisplaylist(app->page->list, tdev, ctm);
- fz_freedevice(tdev);
-
/* Draw */
if (app->image)
fz_droppixmap(app->image);
@@ -311,27 +309,30 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage)
fz_freedevice(idev);
}
- pdfapp_panview(app, app->panx, app->pany);
-
- if (app->shrinkwrap)
+ if (repaint)
{
- int w = app->image->w;
- int h = app->image->h;
- if (app->winw == w)
- app->panx = 0;
- if (app->winh == h)
- app->pany = 0;
- if (w > app->scrw * 90 / 100)
- w = app->scrw * 90 / 100;
- if (h > app->scrh * 90 / 100)
- h = app->scrh * 90 / 100;
- if (w != app->winw || h != app->winh)
- winresize(app, w, h);
- }
+ pdfapp_panview(app, app->panx, app->pany);
- winrepaint(app);
+ if (app->shrinkwrap)
+ {
+ int w = app->image->w;
+ int h = app->image->h;
+ if (app->winw == w)
+ app->panx = 0;
+ if (app->winh == h)
+ app->pany = 0;
+ if (w > app->scrw * 90 / 100)
+ w = app->scrw * 90 / 100;
+ if (h > app->scrh * 90 / 100)
+ h = app->scrh * 90 / 100;
+ if (w != app->winw || h != app->winh)
+ winresize(app, w, h);
+ }
+
+ winrepaint(app);
- wincursor(app, ARROW);
+ wincursor(app, ARROW);
+ }
}
static void pdfapp_gotouri(pdfapp_t *app, fz_obj *uri)
@@ -357,7 +358,7 @@ static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj)
}
app->hist[app->histlen++] = app->pageno;
app->pageno = page;
- pdfapp_showpage(app, 1, 1);
+ pdfapp_showpage(app, 1, 1, 1);
}
static inline fz_bbox bboxcharat(fz_textspan *span, int idx)
@@ -595,37 +596,37 @@ void pdfapp_onkey(pdfapp_t *app, int c)
app->resolution *= ZOOMSTEP;
if (app->resolution > MAXRES)
app->resolution = MAXRES;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
case '-':
app->resolution /= ZOOMSTEP;
if (app->resolution < MINRES)
app->resolution = MINRES;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
case 'L':
app->rotate -= 90;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
case 'R':
app->rotate += 90;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
case 'c':
app->grayscale ^= 1;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
#ifndef NDEBUG
case 'a':
app->rotate -= 15;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
case 's':
app->rotate += 15;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
break;
#endif
@@ -636,27 +637,27 @@ void pdfapp_onkey(pdfapp_t *app, int c)
case 'w':
app->shrinkwrap = 1;
app->panx = app->pany = 0;
- pdfapp_showpage(app, 0, 0);
+ pdfapp_showpage(app, 0, 0, 1);
break;
case 'h':
app->panx += app->image->w / 10;
- pdfapp_showpage(app, 0, 0);
+ pdfapp_showpage(app, 0, 0, 1);
break;
case 'j':
app->pany -= app->image->h / 10;
- pdfapp_showpage(app, 0, 0);
+ pdfapp_showpage(app, 0, 0, 1);
break;
case 'k':
app->pany += app->image->h / 10;
- pdfapp_showpage(app, 0, 0);
+ pdfapp_showpage(app, 0, 0, 1);
break;
case 'l':
app->panx -= app->image->w / 10;
- pdfapp_showpage(app, 0, 0);
+ pdfapp_showpage(app, 0, 0, 1);
break;
/*
@@ -806,7 +807,7 @@ void pdfapp_onkey(pdfapp_t *app, int c)
case DONT_PAN:
break;
}
- pdfapp_showpage(app, 1, 1);
+ pdfapp_showpage(app, 1, 1, 1);
}
}
@@ -881,7 +882,7 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
app->resolution = MAXRES;
if (app->resolution < MINRES)
app->resolution = MINRES;
- pdfapp_showpage(app, 0, 1);
+ pdfapp_showpage(app, 0, 1, 1);
}
else
{