2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: image.c /main/3 1995/11/02 16:07:35 rswiston $ */
27 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
28 * (c) Copyright 1993, 1994 International Business Machines Corp. *
29 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
30 * (c) Copyright 1993, 1994 Novell, Inc. *
33 * image.c - image bouncer for dtscreen, the X Window System lockscreen.
35 * Copyright (c) 1991 by Patrick J. Naughton.
37 * See dtscreen.c for copying information.
47 static XImage logo = {
48 0, 0, /* width, height */
49 0, XYBitmap, 0, /* xoffset, format, data */
50 LSBFirst, 8, /* byte-order, bitmap-unit */
51 LSBFirst, 8, 1 /* bitmap-bit-order, bitmap-pad, depth */
70 point icons[MAXICONS];
75 drawimage(perwindow *pwin)
80 ip = (imagestruct *)pwin->data;
81 XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
82 for (i = 0; i < ip->iconcount; i++) {
84 XFillRectangle(dsp, pwin->w, pwin->gc,
85 ip->xb + xlogo_width * ip->icons[i].x,
86 ip->yb + xlogo_height * ip->icons[i].y,
87 xlogo_width, xlogo_height);
89 ip->icons[i].x = random() % ip->ncols;
90 ip->icons[i].y = random() % ip->nrows;
92 if (pwin->perscreen->npixels == 2)
93 XSetForeground(dsp, pwin->gc, WhitePixelOfScreen(pwin->perscreen->screen));
94 for (i = 0; i < ip->iconcount; i++) {
95 if (pwin->perscreen->npixels > 2)
96 XSetForeground(dsp, pwin->gc,
97 pwin->perscreen->pixels[random() % pwin->perscreen->npixels]);
99 XPutImage(dsp, pwin->w, pwin->gc, &logo,
101 ip->xb + xlogo_width * ip->icons[i].x,
102 ip->yb + xlogo_height * ip->icons[i].y,
103 xlogo_width, xlogo_height);
108 initimage(perwindow *pwin)
110 XWindowAttributes xgwa;
113 if (pwin->data) free(pwin->data);
114 pwin->data = (void *)malloc(sizeof(imagestruct));
115 memset(pwin->data, '\0', sizeof(imagestruct));
116 ip = (imagestruct *)pwin->data;
117 ip->startTime = seconds();
119 logo.data = (char *) xlogo_bits;
120 logo.width = xlogo_width;
121 logo.height = xlogo_height;
122 logo.bytes_per_line = (xlogo_width + 7) / 8;
124 XGetWindowAttributes(dsp, pwin->w, &xgwa);
125 ip->width = xgwa.width;
126 ip->height = xgwa.height;
127 ip->ncols = ip->width / xlogo_width;
128 ip->nrows = ip->height / xlogo_height;
129 ip->iconmode = (ip->ncols < 2 || ip->nrows < 2);
133 ip->iconcount = 1; /* icon mode */
135 ip->xb = (ip->width - xlogo_width * ip->ncols) / 2;
136 ip->yb = (ip->height - xlogo_height * ip->nrows) / 2;
137 ip->iconcount = batchcount;
139 XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
140 XFillRectangle(dsp, pwin->w, pwin->gc, 0, 0, ip->width, ip->height);