diff options
Diffstat (limited to 'apps/unix')
-rw-r--r-- | apps/unix/x11pdf.c | 106 | ||||
-rw-r--r-- | apps/unix/ximage.c | 116 |
2 files changed, 111 insertions, 111 deletions
diff --git a/apps/unix/x11pdf.c b/apps/unix/x11pdf.c index ee9349af..ac4fe6d6 100644 --- a/apps/unix/x11pdf.c +++ b/apps/unix/x11pdf.c @@ -16,27 +16,27 @@ #ifndef timeradd #define timeradd(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ - if ((result)->tv_usec >= 1000000) \ - { \ - ++(result)->tv_sec; \ - (result)->tv_usec -= 1000000; \ - } \ - } while (0) + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) #endif #ifndef timersub #define timersub(a, b, result) \ - do { \ - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ - if ((result)->tv_usec < 0) { \ - --(result)->tv_sec; \ - (result)->tv_usec += 1000000; \ - } \ - } while (0) + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) #endif extern int ximage_init(Display *display, int screen, Visual *visual); @@ -131,17 +131,17 @@ static void winopen(void) XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor); xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy), - 10, 10, 200, 100, 1, - ximage_get_depth(), - InputOutput, - ximage_get_visual(), - 0, - nil); + 10, 10, 200, 100, 1, + ximage_get_depth(), + InputOutput, + ximage_get_visual(), + 0, + nil); XSetWindowColormap(xdpy, xwin, ximage_get_colormap()); XSelectInput(xdpy, xwin, - StructureNotifyMask | ExposureMask | KeyPressMask | - PointerMotionMask | ButtonPressMask | ButtonReleaseMask); + StructureNotifyMask | ExposureMask | KeyPressMask | + PointerMotionMask | ButtonPressMask | ButtonReleaseMask); mapped = 0; @@ -154,7 +154,7 @@ static void winopen(void) { wmhints->flags = IconPixmapHint; wmhints->icon_pixmap = XCreateBitmapFromData(xdpy, xwin, - (char *) gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height); + (char *) gs_l_xbm_bits, gs_l_xbm_width, gs_l_xbm_height); if (wmhints->icon_pixmap) { XSetWMHints(xdpy, xwin, wmhints); @@ -290,12 +290,12 @@ static void winblit(pdfapp_t *app) invertcopyrect(); ximage_blit(xwin, xgc, - x0, y0, - gapp.image->samples, - 0, 0, - gapp.image->w, - gapp.image->h, - gapp.image->w * gapp.image->n); + x0, y0, + gapp.image->samples, + 0, 0, + gapp.image->w, + gapp.image->h, + gapp.image->w * gapp.image->n); if (gapp.iscopying || justcopied) invertcopyrect(); @@ -363,7 +363,7 @@ void windocopy(pdfapp_t *app) *utf8 = 0; *latin1 = 0; -printf("oncopy utf8=%zd latin1=%zd\n", strlen(copyutf8), strlen(copylatin1)); + printf("oncopy utf8=%zd latin1=%zd\n", strlen(copyutf8), strlen(copylatin1)); XSetSelectionOwner(xdpy, XA_PRIMARY, xwin, copytime); @@ -374,7 +374,7 @@ void onselreq(Window requestor, Atom selection, Atom target, Atom property, Time { XEvent nevt; -printf("onselreq\n"); + printf("onselreq\n"); if (property == None) property = target; @@ -395,31 +395,31 @@ printf("onselreq\n"); atomlist[1] = XA_TIMESTAMP; atomlist[2] = XA_STRING; atomlist[3] = XA_UTF8_STRING; -printf(" -> targets\n"); + printf(" -> targets\n"); XChangeProperty(xdpy, requestor, property, target, - 32, PropModeReplace, - (unsigned char *)atomlist, sizeof(atomlist)/sizeof(Atom)); + 32, PropModeReplace, + (unsigned char *)atomlist, sizeof(atomlist)/sizeof(Atom)); } else if (target == XA_STRING) { -printf(" -> string %zd\n", strlen(copylatin1)); + printf(" -> string %zd\n", strlen(copylatin1)); XChangeProperty(xdpy, requestor, property, target, - 8, PropModeReplace, - (unsigned char *)copylatin1, strlen(copylatin1)); + 8, PropModeReplace, + (unsigned char *)copylatin1, strlen(copylatin1)); } else if (target == XA_UTF8_STRING) { -printf(" -> utf8string\n"); + printf(" -> utf8string\n"); XChangeProperty(xdpy, requestor, property, target, - 8, PropModeReplace, - (unsigned char *)copyutf8, strlen(copyutf8)); + 8, PropModeReplace, + (unsigned char *)copyutf8, strlen(copyutf8)); } else { -printf(" -> unknown\n"); + printf(" -> unknown\n"); nevt.xselection.property = None; } @@ -472,7 +472,7 @@ static void usage(void) static void winawaitevent(struct timeval *tmo, struct timeval *tmo_at) { if (tmo_at->tv_sec == 0 && tmo_at->tv_usec == 0 && - tmo->tv_sec == 0 && tmo->tv_usec == 0) + tmo->tv_sec == 0 && tmo->tv_usec == 0) XNextEvent(xdpy, &xevt); else { @@ -568,7 +568,7 @@ int main(int argc, char **argv) winawaitevent(&tmo, &tmo_at); if (tmo_at.tv_sec != 0 && tmo_at.tv_usec != 0 && - tmo.tv_sec == 0 && tmo.tv_usec == 0) + tmo.tv_sec == 0 && tmo.tv_usec == 0) { /* redraw page */ winblit(&gapp); @@ -587,12 +587,12 @@ int main(int argc, char **argv) if (gapp.image) { if (xevt.xconfigure.width != reqw || - xevt.xconfigure.height != reqh) + xevt.xconfigure.height != reqh) gapp.shrinkwrap = 0; } pdfapp_onresize(&gapp, - xevt.xconfigure.width, - xevt.xconfigure.height); + xevt.xconfigure.width, + xevt.xconfigure.height); break; case KeyPress: @@ -636,10 +636,10 @@ int main(int argc, char **argv) case SelectionRequest: onselreq(xevt.xselectionrequest.requestor, - xevt.xselectionrequest.selection, - xevt.xselectionrequest.target, - xevt.xselectionrequest.property, - xevt.xselectionrequest.time); + xevt.xselectionrequest.selection, + xevt.xselectionrequest.target, + xevt.xselectionrequest.property, + xevt.xselectionrequest.time); break; } } diff --git a/apps/unix/ximage.c b/apps/unix/ximage.c index 34221d0f..5b03f559 100644 --- a/apps/unix/ximage.c +++ b/apps/unix/ximage.c @@ -21,13 +21,13 @@ extern int ffs(int); typedef void (*ximage_convert_func_t) - ( - const unsigned char *src, - int srcstride, - unsigned char *dst, - int dststride, - int w, - int h +( + const unsigned char *src, + int srcstride, + unsigned char *dst, + int dststride, + int w, + int h ); #define POOLSIZE 4 @@ -84,7 +84,7 @@ static struct int shmcode; XImage *pool[POOLSIZE]; /* MUST exist during the lifetime of the shared ximage according to the - xc/doc/hardcopy/Xext/mit-shm.PS.gz */ + xc/doc/hardcopy/Xext/mit-shm.PS.gz */ XShmSegmentInfo shminfo[POOLSIZE]; int lastused; } info; @@ -173,15 +173,15 @@ make_colormap(void) info.rgbcube[i].green = (g * 36) << 8; info.rgbcube[i].blue = (b * 85) << 8; info.rgbcube[i].flags = - DoRed | DoGreen | DoBlue; + DoRed | DoGreen | DoBlue; i++; } } } info.colormap = XCreateColormap(info.display, - RootWindow(info.display, info.screen), - info.visual.visual, - AllocAll); + RootWindow(info.display, info.screen), + info.visual.visual, + AllocAll); XStoreColors(info.display, info.colormap, info.rgbcube, 256); return; } @@ -191,7 +191,7 @@ make_colormap(void) return; } fprintf(stderr, "Cannot handle visual class %d with depth: %d\n", - info.visual.class, info.visual.depth); + info.visual.class, info.visual.depth); return; } @@ -220,11 +220,11 @@ select_mode(void) bs = ffs(bm) - 1; printf("ximage: mode %d/%d %08lx %08lx %08lx (%ld,%ld,%ld) %s%s\n", - info.visual.depth, - info.bitsperpixel, - rm, gm, bm, rs, gs, bs, - byteorder == MSBFirst ? "msb" : "lsb", - byterev ? " <swap>":""); + info.visual.depth, + info.bitsperpixel, + rm, gm, bm, rs, gs, bs, + byteorder == MSBFirst ? "msb" : "lsb", + byterev ? " <swap>":""); info.mode = UNKNOWN; if (info.bitsperpixel == 8) { @@ -273,8 +273,8 @@ create_pool(void) for (i = 0; i < POOLSIZE; i++) { info.pool[i] = createximage(info.display, - info.visual.visual, &info.shminfo[i], info.visual.depth, - WIDTH, HEIGHT); + info.visual.visual, &info.shminfo[i], info.visual.depth, + WIDTH, HEIGHT); if (info.pool[i] == nil) { return 0; } @@ -401,11 +401,11 @@ ximage_get_colormap(void) void ximage_blit(Drawable d, GC gc, - int dstx, int dsty, - unsigned char *srcdata, - int srcx, int srcy, - int srcw, int srch, - int srcstride) + int dstx, int dsty, + unsigned char *srcdata, + int srcx, int srcy, + int srcw, int srch, + int srcstride) { XImage *image; int ax, ay; @@ -422,12 +422,12 @@ ximage_blit(Drawable d, GC gc, image = next_pool_image(); srcptr = srcdata + - (ay + srcy) * srcstride + - (ax + srcx) * 4; + (ay + srcy) * srcstride + + (ax + srcx) * 4; info.convert_func(srcptr, srcstride, - (unsigned char *) image->data, - image->bytes_per_line, w, h); + (unsigned char *) image->data, + image->bytes_per_line, w, h); if (info.useshm) { @@ -499,17 +499,17 @@ ximage_convert_bgra8888(PARAMS) for (x = 0; x < w; x++) { val = s[x]; d[x] = - (val >> 24) | - ((val >> 8) & 0xff00) | - (val << 24) | - ((val << 8) & 0xff0000); -/* + (val >> 24) | + ((val >> 8) & 0xff00) | + (val << 24) | + ((val << 8) & 0xff0000); + /* d[x] = - (((val >> 24) & 0xff) << 0) | - (((val >> 16) & 0xff) << 8) | - (((val >> 8) & 0xff) << 16) | - (((val >> 0) & 0xff) << 24); -*/ + (((val >> 24) & 0xff) << 0) | + (((val >> 16) & 0xff) << 8) | + (((val >> 8) & 0xff) << 16) | + (((val >> 0) & 0xff) << 24); + */ } d += dststride>>2; s += srcstride>>2; @@ -531,7 +531,7 @@ ximage_convert_abgr8888(PARAMS) val = s[x]; #if 1 /* FZ_MSB */ d[x] = (val & 0xff00ff00) | - (((val << 16) | (val >> 16)) & 0x00ff00ff); + (((val << 16) | (val >> 16)) & 0x00ff00ff); #else /* FZ_LSB */ d[x] = (val << 24) | ((val >> 8) & 0xff); #endif @@ -598,9 +598,9 @@ ximage_convert_rgb565(PARAMS) g = src[4*x + 2]; b = src[4*x + 3]; ((unsigned short *)dst)[x] = - ((r & 0xF8) << 8) | - ((g & 0xFC) << 3) | - (b >> 3); + ((r & 0xF8) << 8) | + ((g & 0xFC) << 3) | + (b >> 3); } src += srcstride; dst += dststride; @@ -618,13 +618,13 @@ ximage_convert_rgb565_br(PARAMS) g = src[4*x + 2]; b = src[4*x + 3]; /* final word is: - g4 g3 g2 b7 b6 b5 b4 b3 r7 r6 r5 r4 r3 g7 g6 g5 - */ + g4 g3 g2 b7 b6 b5 b4 b3 r7 r6 r5 r4 r3 g7 g6 g5 + */ ((unsigned short *)dst)[x] = - (r & 0xF8) | - ((g & 0xE0) >> 5) | - ((g & 0x1C) << 11) | - ((b & 0xF8) << 5); + (r & 0xF8) | + ((g & 0xE0) >> 5) | + ((g & 0x1C) << 11) | + ((b & 0xF8) << 5); } src += srcstride; dst += dststride; @@ -642,9 +642,9 @@ ximage_convert_rgb555(PARAMS) g = src[4*x + 2]; b = src[4*x + 3]; ((unsigned short *)dst)[x] = - ((r & 0xF8) << 7) | - ((g & 0xF8) << 2) | - (b >> 3); + ((r & 0xF8) << 7) | + ((g & 0xF8) << 2) | + (b >> 3); } src += srcstride; dst += dststride; @@ -662,13 +662,13 @@ ximage_convert_rgb555_br(PARAMS) g = src[4*x + 2]; b = src[4*x + 3]; /* final word is: - g5 g4 g3 b7 b6 b5 b4 b3 0 r7 r6 r5 r4 r3 g7 g6 - */ + g5 g4 g3 b7 b6 b5 b4 b3 0 r7 r6 r5 r4 r3 g7 g6 + */ ((unsigned short *)dst)[x] = - ((r & 0xF8) >> 1) | - ((g & 0xC0) >> 6) | - ((g & 0x38) << 10) | - ((b & 0xF8) << 5); + ((r & 0xF8) >> 1) | + ((g & 0xC0) >> 6) | + ((g & 0x38) << 10) | + ((b & 0xF8) << 5); } src += srcstride; dst += dststride; |