--- ray/src/rt/x11.c 2003/02/22 02:07:29 2.29
+++ ray/src/rt/x11.c 2011/05/20 02:06:39 2.35
@@ -1,74 +1,14 @@
#ifndef lint
-static const char RCSid[] = "$Id: x11.c,v 2.29 2003/02/22 02:07:29 greg Exp $";
+static const char RCSid[] = "$Id: x11.c,v 2.35 2011/05/20 02:06:39 greg Exp $";
#endif
/*
* x11.c - driver for X-windows version 11
*/
-/* ====================================================================
- * The Radiance Software License, Version 1.0
- *
- * Copyright (c) 1990 - 2002 The Regents of the University of California,
- * through Lawrence Berkeley National Laboratory. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes Radiance software
- * (http://radsite.lbl.gov/)
- * developed by the Lawrence Berkeley National Laboratory
- * (http://www.lbl.gov/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
- * and "The Regents of the University of California" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact radiance@radsite.lbl.gov.
- *
- * 5. Products derived from this software may not be called "Radiance",
- * nor may "Radiance" appear in their name, without prior written
- * permission of Lawrence Berkeley National Laboratory.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of Lawrence Berkeley National Laboratory. For more
- * information on Lawrence Berkeley National Laboratory, please see
- * .
- */
+#include "copyright.h"
#include "standard.h"
#include
-#ifdef sparc
-#include
-#include
-#include
-#endif
#if !defined(FNDELAY) && defined(O_NONBLOCK)
#define FNDELAY O_NONBLOCK
#endif
@@ -77,6 +17,7 @@ static const char RCSid[] = "$Id: x11.c,v 2.29 2003/02
#include
#include
+#include "platform.h"
#include "color.h"
#include "driver.h"
#include "x11twind.h"
@@ -134,27 +75,43 @@ static Colormap ourmap = 0; /* our color map */
static int inpcheck; /* whence to check input */
-static int x11_getcur();
+static void x11_errout(char *msg);
-static void x11_close(), x11_clear(), x11_paintr(), x11_errout(),
- x11_comout(), x11_comin(), x11_flush();
+static dr_closef_t x11_close;
+static dr_clearf_t x11_clear;
+static dr_paintrf_t x11_paintr;
+static dr_getcurf_t x11_getcur;
+static dr_comoutf_t x11_comout;
+static dr_cominf_t x11_comin;
+static dr_flushf_t x11_flush;
-static void std_comin(), std_comout();
+static dr_cominf_t std_comin;
+static dr_comoutf_t std_comout;
static struct driver x11_driver = {
x11_close, x11_clear, x11_paintr, x11_getcur,
NULL, NULL, x11_flush, 1.0
};
-static int getpixels(), x11_getc();
-static void xnewcolr(), freepixels(), resizewindow(),
- getevent(), getkey(), fixwindow();
-static unsigned long true_pixel();
+static dr_getchf_t x11_getc;
+static void freepixels(void);
+static int getpixels(void);
+static dr_newcolrf_t xnewcolr;
+static unsigned long true_pixel(COLOR col);
+static void getevent(void);
+static void getkey(XKeyPressedEvent *ekey);
+static void fixwindow(XExposeEvent *eexp);
+static void resizewindow(XConfigureEvent *ersz);
-struct driver *
-x11_init(name, id) /* initialize driver */
-char *name, *id;
+extern dr_initf_t x11_init; /* XXX this should be in a seperate header file */
+
+
+extern struct driver *
+x11_init( /* initialize driver */
+ char *name,
+ char *id
+)
{
char *gv;
int nplanes;
@@ -249,8 +206,10 @@ char *name, *id;
x11_driver.comin = x11_comin;
x11_driver.comout = x11_comout;
erract[COMMAND].pf = x11_comout;
+ /* doesn't work with raypcalls.c
if (erract[WARNING].pf != NULL)
erract[WARNING].pf = x11_errout;
+ */
inpcheck = IC_X11;
} else {
x11_driver.comin = std_comin;
@@ -263,7 +222,7 @@ char *name, *id;
static void
-x11_close() /* close our display */
+x11_close(void) /* close our display */
{
erract[COMMAND].pf = NULL; /* reset error vectors */
if (erract[WARNING].pf != NULL)
@@ -286,8 +245,10 @@ x11_close() /* close our display */
static void
-x11_clear(xres, yres) /* clear our display */
-int xres, yres;
+x11_clear( /* clear our display */
+ int xres,
+ int yres
+)
{
/* check limits */
if (xres < MINWIDTH)
@@ -306,11 +267,12 @@ int xres, yres;
}
XClearWindow(ourdisplay, gwind);
/* reinitialize color table */
- if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale)
+ if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale) {
if (getpixels() == 0)
eputs("cannot allocate colors\n");
else
new_ctab(ncolors);
+ }
/* get new command line */
if (comline != NULL)
xt_close(comline);
@@ -332,9 +294,13 @@ int xres, yres;
static void
-x11_paintr(col, xmin, ymin, xmax, ymax) /* fill a rectangle */
-COLOR col;
-int xmin, ymin, xmax, ymax;
+x11_paintr( /* fill a rectangle */
+ COLOR col,
+ int xmin,
+ int ymin,
+ int xmax,
+ int ymax
+)
{
unsigned long pixel;
@@ -351,7 +317,7 @@ int xmin, ymin, xmax, ymax;
static void
-x11_flush() /* flush output */
+x11_flush(void) /* flush output */
{
char buf[256];
int n;
@@ -387,8 +353,10 @@ x11_flush() /* flush output */
static void
-x11_comin(inp, prompt) /* read in a command line */
-char *inp, *prompt;
+x11_comin( /* read in a command line */
+ char *inp,
+ char *prompt
+)
{
if (prompt != NULL) {
x11_flush(); /* make sure we get everything */
@@ -403,8 +371,9 @@ char *inp, *prompt;
static void
-x11_comout(outp) /* output a string to command line */
-char *outp;
+x11_comout( /* output a string to command line */
+ char *outp
+)
{
if (comline == NULL || outp == NULL || !outp[0])
return;
@@ -415,8 +384,9 @@ char *outp;
static void
-x11_errout(msg) /* output an error message */
-char *msg;
+x11_errout( /* output an error message */
+ char *msg
+)
{
eputs(msg); /* send to stderr also! */
x11_comout(msg);
@@ -424,8 +394,10 @@ char *msg;
static void
-std_comin(inp, prompt) /* read in command line from stdin */
-char *inp, *prompt;
+std_comin( /* read in command line from stdin */
+ char *inp,
+ char *prompt
+)
{
if (prompt != NULL) {
if (fromcombuf(inp, &x11_driver))
@@ -453,8 +425,9 @@ char *inp, *prompt;
static void
-std_comout(outp) /* write out string to stdout */
-char *outp;
+std_comout( /* write out string to stdout */
+ char *outp
+)
{
fputs(outp, stdout);
fflush(stdout);
@@ -462,8 +435,10 @@ char *outp;
static int
-x11_getcur(xp, yp) /* get cursor position */
-int *xp, *yp;
+x11_getcur( /* get cursor position */
+ int *xp,
+ int *yp
+)
{
while (XGrabPointer(ourdisplay, gwind, True, ButtonPressMask,
GrabModeAsync, GrabModeAsync, None, pickcursor,
@@ -491,9 +466,12 @@ int *xp, *yp;
static void
-xnewcolr(ndx, r, g, b) /* enter a color into hardware table */
-int ndx;
-int r, g, b;
+xnewcolr( /* enter a color into hardware table */
+ int ndx,
+ int r,
+ int g,
+ int b
+)
{
XColor xcolor;
@@ -508,7 +486,7 @@ int r, g, b;
static int
-getpixels() /* get the color map */
+getpixels(void) /* get the color map */
{
XColor thiscolor;
register int i, j;
@@ -560,7 +538,7 @@ loop:
static void
-freepixels() /* free our pixels */
+freepixels(void) /* free our pixels */
{
if (ncolors == 0)
return;
@@ -575,11 +553,12 @@ freepixels() /* free our pixels */
static unsigned long
-true_pixel(col) /* return true pixel value for color */
-COLOR col;
+true_pixel( /* return true pixel value for color */
+ COLOR col
+)
{
unsigned long rval;
- BYTE rgb[3];
+ uby8 rgb[3];
map_color(rgb, col);
rval = ourvinfo.red_mask*rgb[RED]/255 & ourvinfo.red_mask;
@@ -590,7 +569,7 @@ COLOR col;
static int
-x11_getc() /* get a command character */
+x11_getc(void) /* get a command character */
{
while (c_last <= c_first) {
c_first = c_last = 0; /* reset */
@@ -602,7 +581,7 @@ x11_getc() /* get a command character */
static void
-getevent() /* get next event */
+getevent(void) /* get next event */
{
XNextEvent(ourdisplay, levptr(XEvent));
switch (levptr(XEvent)->type) {
@@ -615,11 +594,12 @@ getevent() /* get next event */
break;
case MapNotify:
if (ourvinfo.class == PseudoColor ||
- ourvinfo.class == GrayScale)
+ ourvinfo.class == GrayScale) {
if (getpixels() == 0)
eputs("cannot allocate colors\n");
else
new_ctab(ncolors);
+ }
mapped = 1;
break;
case Expose:
@@ -635,8 +615,9 @@ getevent() /* get next event */
static void
-getkey(ekey) /* get input key */
-register XKeyPressedEvent *ekey;
+getkey( /* get input key */
+ register XKeyPressedEvent *ekey
+)
{
register int n;
@@ -648,8 +629,9 @@ register XKeyPressedEvent *ekey;
static void
-fixwindow(eexp) /* repair damage to window */
-register XExposeEvent *eexp;
+fixwindow( /* repair damage to window */
+ register XExposeEvent *eexp
+)
{
char buf[80];
@@ -666,8 +648,9 @@ register XExposeEvent *eexp;
static void
-resizewindow(ersz) /* resize window */
-register XConfigureEvent *ersz;
+resizewindow( /* resize window */
+ register XConfigureEvent *ersz
+)
{
if (ersz->width == gwidth && ersz->height-comheight == gheight)
return;