forked from e16/e16
1
0
Fork 0

Thu Mar 30 17:15:19 PST 2000

(Mandrake)

Makes dox recognize xinerama to pop up centered on the current head.


SVN revision: 2390
This commit is contained in:
Mandrake 2000-03-31 01:18:28 +00:00
parent cb7e3bee1e
commit 4f83029530
3 changed files with 442 additions and 437 deletions

View File

@ -63,3 +63,10 @@ Tue Mar 14 20:23:53 CET 2000
Added patch from Masahiko Mori <masa@cthulhu.engr.sgi.com> Added patch from Masahiko Mori <masa@cthulhu.engr.sgi.com>
to improve localization support (I modified the patch somewhat). to improve localization support (I modified the patch somewhat).
-----------------------------------------------------------------
Thu Mar 30 17:15:19 PST 2000
(Mandrake)
Makes dox recognize xinerama to pop up centered on the current head.

View File

@ -29,7 +29,7 @@ dox_SOURCES = \
exit2.xpm \ exit2.xpm \
dox.h dox.h
LDADD = $(TTF_LIBS) $(FNLIB_LIBS) $(IMLIB_LIBS) -lm LDADD = $(TTF_LIBS) $(FNLIB_LIBS) $(IMLIB_LIBS) $(XINERAMA_LIBS) -lm
INCLUDES=-I$(top_srcdir) $(IMLIB_CFLAGS) -I$(includedir) -I.. INCLUDES=-I$(top_srcdir) $(IMLIB_CFLAGS) -I$(includedir) -I..

870
dox/dox.c
View File

@ -32,6 +32,11 @@
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <X11/extensions/XTest.h> #include <X11/extensions/XTest.h>
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
#ifdef HAS_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#include <Imlib.h> #include <Imlib.h>
#include <Fnlib.h> #include <Fnlib.h>
#include <stdio.h> #include <stdio.h>
@ -42,7 +47,7 @@
#include "dox.h" #include "dox.h"
#ifdef __alpha__ /* gets rid of some misalignment in GCC */ #ifdef __alpha__ /* gets rid of some misalignment in GCC */
#pragma 2 #pragma 2
#endif #endif
@ -69,16 +74,14 @@
#define PROP_MWM_HINTS_ELEMENTS 4 #define PROP_MWM_HINTS_ELEMENTS 4
#define STARTPOS 4 /* to bypass next/prev/exit buttons for key binding positions */ #define STARTPOS 4 /* to bypass next/prev/exit buttons for key binding positions */
typedef struct _mwmhints typedef struct _mwmhints {
{ CARD32 flags;
CARD32 flags; CARD32 functions;
CARD32 functions; CARD32 decorations;
CARD32 decorations; INT32 inputMode;
INT32 inputMode; } MWMHints;
}
MWMHints;
#include "title.xpm" #include "title.xpm"
#include "prev1.xpm" #include "prev1.xpm"
@ -88,63 +91,61 @@ MWMHints;
#include "exit1.xpm" #include "exit1.xpm"
#include "exit2.xpm" #include "exit2.xpm"
Display *disp; Display *disp;
ImlibData *id; ImlibData *id;
FnlibData *fd; FnlibData *fd;
Window win_main, win_title, win_exit, win_next, win_prev, win_text, Window win_main, win_title, win_exit, win_next, win_prev, win_text, win_cover;
win_cover; int w, h, t;
int w, h, t; ImlibImage *im_text;
ImlibImage *im_text; ImlibImage *im_title;
ImlibImage *im_title; ImlibImage *im_prev1, *im_prev2;
ImlibImage *im_prev1, *im_prev2; ImlibImage *im_next1, *im_next2;
ImlibImage *im_next1, *im_next2; ImlibImage *im_exit1, *im_exit2;
ImlibImage *im_exit1, *im_exit2; char *docdir;
char *docdir;
Window CreateWindow(Window parent, int x, int y, int ww, int hh); Window CreateWindow(Window parent, int x, int y, int ww, int hh);
int ReadHeader(FILE * f); int ReadHeader(FILE * f);
int ReadPages(FILE * f); int ReadPages(FILE * f);
Window Window CreateWindow(Window parent, int x, int y, int ww, int hh)
CreateWindow(Window parent, int x, int y, int ww, int hh)
{ {
Window win; Window win;
XSetWindowAttributes attr; XSetWindowAttributes attr;
MWMHints mwm; MWMHints mwm;
/* Atom a; */ /* Atom a; */
XSizeHints hnt; XSizeHints hnt;
attr.backing_store = NotUseful; attr.backing_store = NotUseful;
attr.override_redirect = False; attr.override_redirect = False;
attr.colormap = Imlib_get_colormap(id); attr.colormap = Imlib_get_colormap(id);
attr.border_pixel = 0; attr.border_pixel = 0;
attr.background_pixel = 0; attr.background_pixel = 0;
attr.save_under = False; attr.save_under = False;
mwm.flags = MWM_HINTS_DECORATIONS; mwm.flags = MWM_HINTS_DECORATIONS;
mwm.functions = 0; mwm.functions = 0;
mwm.decorations = 0; mwm.decorations = 0;
mwm.inputMode = 0; mwm.inputMode = 0;
/* a = XInternAtom(disp, "_MOTIF_WM_HINTS", False); */ /* a = XInternAtom(disp, "_MOTIF_WM_HINTS", False); */
win = XCreateWindow(disp, parent, x, y, ww, hh, 0, id->x.depth, win = XCreateWindow(disp, parent, x, y, ww, hh, 0, id->x.depth,
InputOutput, Imlib_get_visual(id), InputOutput, Imlib_get_visual(id),
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWOverrideRedirect | CWSaveUnder | CWBackingStore |
CWColormap | CWBackPixel | CWBorderPixel, &attr); CWColormap | CWBackPixel | CWBorderPixel, &attr);
XSetWindowBackground(disp, win, 0); XSetWindowBackground(disp, win, 0);
/* XChangeProperty(disp, win, a, a, 32, PropModeReplace, /* XChangeProperty(disp, win, a, a, 32, PropModeReplace,
* (unsigned char *)&mwm, sizeof(MWMHints) / 4); */ * (unsigned char *)&mwm, sizeof(MWMHints) / 4); */
XStoreName(disp, win, "DOX: Enlightenment Document Viewer"); XStoreName(disp, win, "DOX: Enlightenment Document Viewer");
hnt.flags = USPosition | USSize | PPosition | PSize | PMinSize | PMaxSize; hnt.flags = USPosition | USSize | PPosition | PSize | PMinSize | PMaxSize;
hnt.x = x; hnt.x = x;
hnt.y = y; hnt.y = y;
hnt.width = ww; hnt.width = ww;
hnt.height = hh; hnt.height = hh;
hnt.min_width = ww; hnt.min_width = ww;
hnt.max_width = ww; hnt.max_width = ww;
hnt.min_height = hh; hnt.min_height = hh;
hnt.max_height = hh; hnt.max_height = hh;
XSetWMNormalHints(disp, win, &hnt); XSetWMNormalHints(disp, win, &hnt);
return win; return win;
} }
#define FREE_LINKS \ #define FREE_LINKS \
@ -179,405 +180,402 @@ XClearWindow(disp, win_text); \
} \ } \
} }
int int main(int argc, char **argv)
main(int argc, char **argv)
{ {
int pagenum; int pagenum;
int i, w, h, x, y; int i, w, h, x, y;
int wx, wy; int wx, wy;
FILE *f; FILE *f;
char *s, *docfile = NULL; char *s, *docfile = NULL;
Pixmap draw = 0; Pixmap draw = 0;
Link *l = NULL, *ll = NULL; Link *l = NULL, *ll = NULL;
ImlibBorder ibd; ImlibBorder ibd;
ImlibInitParams params; ImlibInitParams params;
int *page_hist = NULL; int *page_hist = NULL;
int page_hist_len = 1; int page_hist_len = 1;
int page_hist_pos = 0; int page_hist_pos = 0;
w = 512; w = 512;
h = 400; h = 400;
x = 0; x = 0;
y = 0; y = 0;
pagenum = 0; pagenum = 0;
disp = XOpenDisplay(NULL); disp = XOpenDisplay(NULL);
/* now we'll set the locale */ /* now we'll set the locale */
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
if (!XSupportsLocale()) if (!XSupportsLocale())
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
XSetLocaleModifiers(""); XSetLocaleModifiers("");
setlocale(LC_ALL, NULL); setlocale(LC_ALL, NULL);
/* I dont want any internationalisation of my numeric input & output */ /* I dont want any internationalisation of my numeric input & output */
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
params.flags = PARAMS_IMAGECACHESIZE | PARAMS_PIXMAPCACHESIZE; params.flags = PARAMS_IMAGECACHESIZE | PARAMS_PIXMAPCACHESIZE;
params.imagecachesize = (w * h * 3 * 2); params.imagecachesize = (w * h * 3 * 2);
params.pixmapcachesize = (w * h * 3 * 2 * 8); params.pixmapcachesize = (w * h * 3 * 2 * 8);
id = Imlib_init_with_params(disp, &params); id = Imlib_init_with_params(disp, &params);
Imlib_set_render_type(id, RT_DITHER_TRUECOL); Imlib_set_render_type(id, RT_DITHER_TRUECOL);
fd = Fnlib_init(id); fd = Fnlib_init(id);
im_title = Imlib_create_image_from_xpm_data(id, title_xpm); im_title = Imlib_create_image_from_xpm_data(id, title_xpm);
ibd.left = 50; ibd.left = 50;
ibd.right = 2; ibd.right = 2;
ibd.top = 2; ibd.top = 2;
ibd.bottom = 2; ibd.bottom = 2;
Imlib_set_image_border(id, im_title, &ibd); Imlib_set_image_border(id, im_title, &ibd);
im_prev1 = Imlib_create_image_from_xpm_data(id, prev1_xpm); im_prev1 = Imlib_create_image_from_xpm_data(id, prev1_xpm);
im_prev2 = Imlib_create_image_from_xpm_data(id, prev2_xpm); im_prev2 = Imlib_create_image_from_xpm_data(id, prev2_xpm);
im_next1 = Imlib_create_image_from_xpm_data(id, next1_xpm); im_next1 = Imlib_create_image_from_xpm_data(id, next1_xpm);
im_next2 = Imlib_create_image_from_xpm_data(id, next2_xpm); im_next2 = Imlib_create_image_from_xpm_data(id, next2_xpm);
im_exit1 = Imlib_create_image_from_xpm_data(id, exit1_xpm); im_exit1 = Imlib_create_image_from_xpm_data(id, exit1_xpm);
im_exit2 = Imlib_create_image_from_xpm_data(id, exit2_xpm); im_exit2 = Imlib_create_image_from_xpm_data(id, exit2_xpm);
if (argc < 2) {
printf("usage:\n"
"%s [-page page_number] [-file Edoc_fname] [-size width height] Edoc_dir\n",
argv[0]);
exit(1);
}
docdir = ".";
docfile = "MAIN";
for (i = 1; i < argc; i++) {
if ((!strcmp(argv[i], "-page")) && (i < (argc - 1)))
pagenum = atoi(argv[++i]);
else if ((!strcmp(argv[i], "-file")) && (i < (argc - 1)))
docfile = argv[++i];
else if ((!strcmp(argv[i], "-size")) && (i < (argc - 2))) {
w = atoi(argv[++i]);
h = atoi(argv[++i]);
} else
docdir = strdup(argv[i]);
}
s = malloc(strlen(docdir) + strlen(docfile) + 2 + 20);
sprintf(s, "%s/%s", docdir, docfile);
findLocalizedFile(s);
if (argc < 2)
{
printf("usage:\n"
"%s [-page page_number] [-file Edoc_fname] [-size width height] Edoc_dir\n",
argv[0]);
exit(1);
}
docdir = ".";
docfile = "MAIN";
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-page")) && (i < (argc - 1)))
pagenum = atoi(argv[++i]);
else if ((!strcmp(argv[i], "-file")) && (i < (argc - 1)))
docfile = argv[++i];
else if ((!strcmp(argv[i], "-size")) && (i < (argc - 2)))
{
w = atoi(argv[++i]);
h = atoi(argv[++i]);
}
else
docdir = strdup(argv[i]);
}
s = malloc(strlen(docdir) + strlen(docfile) + 2 + 20);
sprintf(s, "%s/%s", docdir, docfile );
findLocalizedFile(s);
#ifndef __EMX__
f = fopen(s, "r");
#else
f = fopen(s, "rt");
#endif
if (!f)
{
strcpy(s, docdir);
strcat(s, "/");
strcat(s, docfile);
#ifndef __EMX__ #ifndef __EMX__
f = fopen(s, "r"); f = fopen(s, "r");
#else #else
f = fopen(s, "rt"); f = fopen(s, "rt");
#endif #endif
if(!f) if (!f) {
{ strcpy(s, docdir);
printf("Edoc_dir %s does not contain a %s file\n", docdir, docfile); strcat(s, "/");
exit(1); strcat(s, docfile);
} #ifndef __EMX__
} f = fopen(s, "r");
Esetenv("DISPLAY", DisplayString(disp), 1); #else
Esetenv("E_DATADIR", ENLIGHTENMENT_ROOT, 1); f = fopen(s, "rt");
Esetenv("E_BINDIR", ENLIGHTENMENT_BIN, 1); #endif
if (!f) {
printf("Edoc_dir %s does not contain a %s file\n", docdir, docfile);
exit(1);
}
}
Esetenv("DISPLAY", DisplayString(disp), 1);
Esetenv("E_DATADIR", ENLIGHTENMENT_ROOT, 1);
Esetenv("E_BINDIR", ENLIGHTENMENT_BIN, 1);
t = 16; t = 16;
GetObjects(f); GetObjects(f);
fclose(f); fclose(f);
Fnlib_add_dir(fd, docdir); Fnlib_add_dir(fd, docdir);
wx = (DisplayWidth(disp, DefaultScreen(disp)) - w) / 2; wx = (DisplayWidth(disp, DefaultScreen(disp)) - w) / 2;
wy = (DisplayHeight(disp, DefaultScreen(disp)) - (h + t)) / 2; wy = (DisplayHeight(disp, DefaultScreen(disp)) - (h + t)) / 2;
win_main = CreateWindow(id->x.root, wx, wy, w, h + t); #ifdef HAS_XINERAMA
win_title = CreateWindow(win_main, 0, 0, (w - 64 - 64 - t), t); {
win_prev = CreateWindow(win_main, (w - 64 - 64 - t), 0, 64, t); if (XineramaIsActive(disp)) {
XSelectInput(disp, win_prev, ButtonPressMask | ButtonReleaseMask); Window rt, ch;
win_next = CreateWindow(win_main, (w - 64 - 64 - t) + 64, 0, 64, t); int d;
XSelectInput(disp, win_next, ButtonPressMask | ButtonReleaseMask); unsigned int ud;
win_exit = CreateWindow(win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t); int pointer_x, pointer_y;
XSelectInput(disp, win_exit, ButtonPressMask | ButtonReleaseMask); int num;
win_text = CreateWindow(win_main, 0, t, w, h); XineramaScreenInfo *screens;
XSelectInput(disp, win_text, ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask | PointerMotionMask);
draw = XCreatePixmap(disp, win_text, w, h, id->x.depth);
XSetWindowBackgroundPixmap(disp, win_text, draw);
Imlib_apply_image(id, im_title, win_title);
Imlib_apply_image(id, im_exit1, win_exit);
Imlib_apply_image(id, im_next1, win_next);
Imlib_apply_image(id, im_prev1, win_prev);
l = RenderPage(draw, pagenum, w, h); XQueryPointer(disp, id->x.root, &rt, &ch, &pointer_x, &pointer_y,
&d, &d, &ud);
XMapWindow(disp, win_text); screens = XineramaQueryScreens(disp, &num);
XMapWindow(disp, win_exit); for (i = 0; i < num; i++) {
XMapWindow(disp, win_next); if (pointer_x >= screens[i].x_org) {
XMapWindow(disp, win_prev); if (pointer_x <= (screens[i].width + screens[i].x_org)) {
XMapWindow(disp, win_title); if (pointer_y >= screens[i].y_org) {
XMapWindow(disp, win_main); if (pointer_y <= (screens[i].height +
XSync(disp, False); screens[i].y_org)) {
page_hist = malloc(sizeof(int)); wx = ((screens[i].width - w) / 2)
+ screens[i].x_org;
page_hist[0] = 0; wy = ((screens[i].height - (h + t)) / 2)
+ screens[i].y_org;
for (;;) }
{ }
KeySym key;
XEvent ev;
XNextEvent(disp, &ev);
switch (ev.type)
{
case KeyPress:
key = XLookupKeysym(&ev.xkey, 0);
switch (key)
{
case XK_Escape:
exit(0);
break;
case XK_Down:
case XK_Right:
break;
case XK_Up:
case XK_Left:
break;
case XK_Return:
break;
case XK_Home:
FREE_LINKS;
pagenum = 0;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_End:
FREE_LINKS;
pagenum = 99999;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_Prior:
FREE_LINKS;
pagenum--;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_Next:
FREE_LINKS;
pagenum++;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
}
break;
case ButtonPress:
if (ev.xbutton.window == win_prev)
Imlib_apply_image(id, im_prev2, win_prev);
else if (ev.xbutton.window == win_next)
Imlib_apply_image(id, im_next2, win_next);
else if (ev.xbutton.window == win_exit)
Imlib_apply_image(id, im_exit2, win_exit);
else
{
int x, y;
x = ev.xbutton.x;
y = ev.xbutton.y;
ll = l;
while (ll)
{
if ((x >= ll->x) && (y >= ll->y) &&
(x < (ll->x + ll->w)) &&
(y < (ll->y + ll->h)))
{
int pg;
if (!strncmp("EXEC.", ll->name, 5))
{
if (!fork())
{
char *exe;
exe = &(ll->name[5]);
execl("/bin/sh", "/bin/sh", "-c", exe, NULL);
exit(0);
}
}
else if (!strncmp("INPUT.", ll->name, 6))
{
FILE *p;
char *exe, tmp[1024];
exe = &(ll->name[6]);
if (exe[0] != '/')
{
sprintf(tmp, "%s/%s", docdir, exe);
findLocalizedFile(tmp);
exe = tmp;
}
p = popen(exe, "r");
if (p)
{
int dirlen = 0;
char *sp;
sp = exe;
while ((*sp) && (*sp != ' '))
sp++;
while ((*sp != '/') && (sp != exe))
sp--;
dirlen = sp - exe;
if (dirlen > 1)
{
free(docdir);
docdir = malloc(dirlen + 1);
memcpy(docdir, exe, dirlen);
docdir[dirlen] = 0;
} }
GetObjects(p); }
pclose(p); }
if (page_hist)
free(page_hist);
page_hist = malloc(sizeof(int));
page_hist[0] = 0; XFree(screens);
page_hist_len = 1; }
pagenum = 0;
page_hist_pos = 0; }
FREE_LINKS; #endif
l = RenderPage(draw, pagenum, w, h); win_main = CreateWindow(id->x.root, wx, wy, w, h + t);
UPDATE; win_title = CreateWindow(win_main, 0, 0, (w - 64 - 64 - t), t);
} win_prev = CreateWindow(win_main, (w - 64 - 64 - t), 0, 64, t);
} XSelectInput(disp, win_prev, ButtonPressMask | ButtonReleaseMask);
else win_next = CreateWindow(win_main, (w - 64 - 64 - t) + 64, 0, 64, t);
{ XSelectInput(disp, win_next, ButtonPressMask | ButtonReleaseMask);
pg = GetPage(ll->name); win_exit = CreateWindow(win_main, (w - 64 - 64 - t) + 64 + 64, 0, t, t);
if (pg >= 0) XSelectInput(disp, win_exit, ButtonPressMask | ButtonReleaseMask);
{ win_text = CreateWindow(win_main, 0, t, w, h);
FREE_LINKS; XSelectInput(disp, win_text, ButtonPressMask | ButtonReleaseMask |
pagenum = pg; KeyPressMask | KeyReleaseMask | PointerMotionMask);
page_hist_pos++; draw = XCreatePixmap(disp, win_text, w, h, id->x.depth);
if (page_hist_pos >= page_hist_len) XSetWindowBackgroundPixmap(disp, win_text, draw);
{ Imlib_apply_image(id, im_title, win_title);
page_hist_len++; Imlib_apply_image(id, im_exit1, win_exit);
page_hist = Imlib_apply_image(id, im_next1, win_next);
realloc(page_hist, Imlib_apply_image(id, im_prev1, win_prev);
sizeof(int) * page_hist_len);
l = RenderPage(draw, pagenum, w, h);
XMapWindow(disp, win_text);
XMapWindow(disp, win_exit);
XMapWindow(disp, win_next);
XMapWindow(disp, win_prev);
XMapWindow(disp, win_title);
XMapWindow(disp, win_main);
XSync(disp, False);
page_hist = malloc(sizeof(int));
page_hist[0] = 0;
for (;;) {
KeySym key;
XEvent ev;
XNextEvent(disp, &ev);
switch (ev.type) {
case KeyPress:
key = XLookupKeysym(&ev.xkey, 0);
switch (key) {
case XK_Escape:
exit(0);
break;
case XK_Down:
case XK_Right:
break;
case XK_Up:
case XK_Left:
break;
case XK_Return:
break;
case XK_Home:
FREE_LINKS;
pagenum = 0;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_End:
FREE_LINKS;
pagenum = 99999;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_Prior:
FREE_LINKS;
pagenum--;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
case XK_Next:
FREE_LINKS;
pagenum++;
pagenum = FixPage(pagenum);
l = RenderPage(draw, pagenum, w, h);
UPDATE;
break;
}
break;
case ButtonPress:
if (ev.xbutton.window == win_prev)
Imlib_apply_image(id, im_prev2, win_prev);
else if (ev.xbutton.window == win_next)
Imlib_apply_image(id, im_next2, win_next);
else if (ev.xbutton.window == win_exit)
Imlib_apply_image(id, im_exit2, win_exit);
else {
int x, y;
x = ev.xbutton.x;
y = ev.xbutton.y;
ll = l;
while (ll) {
if ((x >= ll->x) && (y >= ll->y) &&
(x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) {
int pg;
if (!strncmp("EXEC.", ll->name, 5)) {
if (!fork()) {
char *exe;
exe = &(ll->name[5]);
execl("/bin/sh", "/bin/sh", "-c", exe, NULL);
exit(0);
}
} else if (!strncmp("INPUT.", ll->name, 6)) {
FILE *p;
char *exe, tmp[1024];
exe = &(ll->name[6]);
if (exe[0] != '/') {
sprintf(tmp, "%s/%s", docdir, exe);
findLocalizedFile(tmp);
exe = tmp;
}
p = popen(exe, "r");
if (p) {
int dirlen = 0;
char *sp;
sp = exe;
while ((*sp) && (*sp != ' '))
sp++;
while ((*sp != '/') && (sp != exe))
sp--;
dirlen = sp - exe;
if (dirlen > 1) {
free(docdir);
docdir = malloc(dirlen + 1);
memcpy(docdir, exe, dirlen);
docdir[dirlen] = 0;
}
GetObjects(p);
pclose(p);
if (page_hist)
free(page_hist);
page_hist = malloc(sizeof(int));
page_hist[0] = 0;
page_hist_len = 1;
pagenum = 0;
page_hist_pos = 0;
FREE_LINKS;
l = RenderPage(draw, pagenum, w, h);
UPDATE;
}
} else {
pg = GetPage(ll->name);
if (pg >= 0) {
FREE_LINKS;
pagenum = pg;
page_hist_pos++;
if (page_hist_pos >= page_hist_len) {
page_hist_len++;
page_hist =
realloc(page_hist,
sizeof(int) * page_hist_len);
}
page_hist[page_hist_pos] = pagenum;
l = RenderPage(draw, pagenum, w, h);
UPDATE;
}
}
break;
} }
page_hist[page_hist_pos] = pagenum; ll = ll->next;
l = RenderPage(draw, pagenum, w, h); }
UPDATE; }
} break;
} case ButtonRelease:
break; if (ev.xbutton.window == win_prev) {
} Imlib_apply_image(id, im_prev1, win_prev);
ll = ll->next; FREE_LINKS;
} page_hist_pos--;
} if (page_hist_pos < 0)
break; page_hist_pos = 0;
case ButtonRelease: pagenum = page_hist[page_hist_pos];
if (ev.xbutton.window == win_prev) l = RenderPage(draw, pagenum, w, h);
{ UPDATE;
Imlib_apply_image(id, im_prev1, win_prev); } else if (ev.xbutton.window == win_next) {
FREE_LINKS; int prev_pagenum;
page_hist_pos--;
if (page_hist_pos < 0)
page_hist_pos = 0;
pagenum = page_hist[page_hist_pos];
l = RenderPage(draw, pagenum, w, h);
UPDATE;
}
else if (ev.xbutton.window == win_next)
{
int prev_pagenum;
Imlib_apply_image(id, im_next1, win_next); Imlib_apply_image(id, im_next1, win_next);
prev_pagenum = pagenum; prev_pagenum = pagenum;
pagenum++; pagenum++;
pagenum = FixPage(pagenum); pagenum = FixPage(pagenum);
if (pagenum != prev_pagenum) if (pagenum != prev_pagenum) {
{ FREE_LINKS;
FREE_LINKS; page_hist_pos++;
page_hist_pos++; if (page_hist_pos >= page_hist_len) {
if (page_hist_pos >= page_hist_len) page_hist_len++;
{ page_hist = realloc(page_hist,
page_hist_len++; sizeof(int) * page_hist_len);
page_hist = realloc(page_hist,
sizeof(int) * page_hist_len);
page_hist[page_hist_pos] = pagenum; page_hist[page_hist_pos] = pagenum;
} } else
else page_hist[page_hist_pos] = pagenum;
page_hist[page_hist_pos] = pagenum; l = RenderPage(draw, pagenum, w, h);
l = RenderPage(draw, pagenum, w, h); UPDATE;
UPDATE; }
} } else if (ev.xbutton.window == win_exit) {
} Imlib_apply_image(id, im_exit1, win_exit);
else if (ev.xbutton.window == win_exit) exit(0);
{ }
Imlib_apply_image(id, im_exit1, win_exit); break;
exit(0); case EnterNotify:
} break;
break; case LeaveNotify:
case EnterNotify: break;
break; case MotionNotify:
case LeaveNotify: while (XCheckTypedEvent(disp, ev.type, &ev));
break; {
case MotionNotify: int x, y;
while (XCheckTypedEvent(disp, ev.type, &ev)); static Link *pl = NULL;
{ char found = 0;
int x, y;
static Link *pl = NULL;
char found = 0;
x = ev.xmotion.x; x = ev.xmotion.x;
y = ev.xmotion.y; y = ev.xmotion.y;
ll = l; ll = l;
while (ll) while (ll) {
{ if ((x >= ll->x) && (y >= ll->y) &&
if ((x >= ll->x) && (y >= ll->y) && (x < (ll->x + ll->w)) && (y < (ll->y + ll->h))) {
(x < (ll->x + ll->w)) && GC gc;
(y < (ll->y + ll->h))) XGCValues gcv;
{ int r, g, b;
GC gc;
XGCValues gcv;
int r, g, b;
if (pl != ll) if (pl != ll) {
{ if (pl) {
if (pl) UPDATE_NOW;
{ }
UPDATE_NOW; GetLinkColors(pagenum, &r, &g, &b);
} gc = XCreateGC(disp, win_text, 0, &gcv);
GetLinkColors(pagenum, &r, &g, &b); XSetForeground(disp, gc,
gc = XCreateGC(disp, win_text, 0, &gcv); Imlib_best_color_match(id, &r, &g,
XSetForeground(disp, gc, &b));
Imlib_best_color_match(id, &r, &g, &b)); XDrawRectangle(disp, win_text, gc, ll->x, ll->y,
XDrawRectangle(disp, win_text, gc, ll->x, ll->y, ll->w, ll->h);
ll->w, ll->h); XFreeGC(disp, gc);
XFreeGC(disp, gc); pl = ll;
pl = ll; }
} found = 1;
found = 1; ll = NULL;
ll = NULL; }
} if (ll)
if (ll) ll = ll->next;
ll = ll->next; }
} if (!found) {
if (!found) UPDATE_NOW;
{ pl = NULL;
UPDATE_NOW; }
pl = NULL; }
} break;
} default:
break; break;
default: }
break; }
}
}
} }