/* winx.c - xwindow version of display code */
static char *rcsid
= "$Header: /f/osi/others/quipu/photo/RCS/winx.c,v 7.0 89/11/23 22:01:50 mrose Rel $";
* $Header: /f/osi/others/quipu/photo/RCS/winx.c,v 7.0 89/11/23 22:01:50 mrose Rel $
* Revision 7.0 89/11/23 22:01:50 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
/* It appears that window manager writers have problems */
#define WM_DISAPPEARED_BUG /* wm screw up & loses the window ! */
#define WM_WINGE_BUG /* When wm screws up, it also winges */
#define TWM_RESIZE_BUG /* twm looses the resize if done too early. */
int winX
, winY
, winW
, winH
;
XSetWindowAttributes xswa
;
extern int NUMLINES
,PIC_LINESIZE
;
extern unsigned position
;
maxx
= 0, two_passes
= 1;
/* Decoding has finished - display the photo */
/* Initialise a window to recieve a photo of 'name' */
if (!(dpy
= XOpenDisplay((char *) 0))) {
(void) printf ("Cannot open X display");
scr
= DefaultScreenOfDisplay(dpy
);
winX
= WidthOfScreen(scr
) - winW
;
winY
= HeightOfScreen(scr
) - winH
;
/*NB: to get button release you have to ask for button press as well*/
xswa
.event_mask
= ExposureMask
| ButtonReleaseMask
| ButtonPressMask
;
xswa
.background_pixel
= BlackPixelOfScreen(scr
);
xswa
.backing_store
= WhenMapped
;
win
= XCreateWindow(dpy
, RootWindowOfScreen(scr
),
winX
, winY
, winW
, winH
, 0,
DefaultDepthOfScreen(scr
), InputOutput
,
DefaultVisualOfScreen(scr
),
CWEventMask
| CWBackPixel
| CWBackingStore
, &xswa
);
pixmap
= XCreatePixmap(dpy
, win
,
winW
,winH
, DefaultDepthOfScreen(scr
));
(void) fprintf (stderr
,"PHOTO: Pixmap failed");
/* Set up a graphics context: */
gc
= XCreateGC(dpy
, pixmap
, 0, NULL
);
XSetForeground(dpy
, gc
, BlackPixelOfScreen(scr
));
XFillRectangle(dpy
, pixmap
, gc
, 0, 0, winW
,winH
);
XSetForeground(dpy
, gc
, WhitePixelOfScreen(scr
));
XSetBackground(dpy
, gc
, BlackPixelOfScreen(scr
));
XorVal
= WhitePixelOfScreen(scr
) ^ BlackPixelOfScreen(scr
);
if (strcmp (name
, "unknown") == 0)
(void) printf ("(See X window, pid %d)", getpid());
(void) sprintf(buff
, name
? "%s" : "%s (%d)",
name
? name
: "Photo", getpid());
XChangeProperty(dpy
, win
, XA_WM_NAME
, XA_STRING
, 8,
PropModeReplace
, buff
, strlen(buff
));
XSetForeground(dpy
, gc
, XorVal
);
{ XSetFunction(dpy
, gc
, GXcopy
);
XCopyArea(dpy
, pixmap
, win
,
{ XSetFunction(dpy
, gc
, GXxor
);
XFillRectangle(dpy
, win
, gc
,
0, 0, PIC_LINESIZE
, NUMLINES
);
if (!buttons_down
) buttons_down
++;
if (--buttons_down
) continue;
if (!ignore_action
) break;
XSetFunction(dpy
, gc
, GXcopy
);
XCopyArea(dpy
, pixmap
, win
, gc
,
xev
.xexpose
.x
, xev
.xexpose
.y
,
xev
.xexpose
.width
, xev
.xexpose
.height
,
xev
.xexpose
.x
, xev
.xexpose
.y
);
/* draw a black line of 'length' pixels */
/* draw a white line of 'length' pixels */
XDrawLine (dpy
,pixmap
,gc
,position
,NUMLINES
,length
+position
-1,NUMLINES
);
/* the end of a line has been reached */
/* A bit string is stored in line->dbuf_top */
if (passno
== 1 && x
> maxx
)