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];
81 ip = (imagestruct *)pwin->data;
82 XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
83 for (i = 0; i < ip->iconcount; i++) {
85 XFillRectangle(dsp, pwin->w, pwin->gc,
86 ip->xb + xlogo_width * ip->icons[i].x,
87 ip->yb + xlogo_height * ip->icons[i].y,
88 xlogo_width, xlogo_height);
90 ip->icons[i].x = random() % ip->ncols;
91 ip->icons[i].y = random() % ip->nrows;
93 if (pwin->perscreen->npixels == 2)
94 XSetForeground(dsp, pwin->gc, WhitePixelOfScreen(pwin->perscreen->screen));
95 for (i = 0; i < ip->iconcount; i++) {
96 if (pwin->perscreen->npixels > 2)
97 XSetForeground(dsp, pwin->gc,
98 pwin->perscreen->pixels[random() % pwin->perscreen->npixels]);
100 XPutImage(dsp, pwin->w, pwin->gc, &logo,
102 ip->xb + xlogo_width * ip->icons[i].x,
103 ip->yb + xlogo_height * ip->icons[i].y,
104 xlogo_width, xlogo_height);
112 XWindowAttributes xgwa;
115 if (pwin->data) free(pwin->data);
116 pwin->data = (void *)malloc(sizeof(imagestruct));
117 memset(pwin->data, '\0', sizeof(imagestruct));
118 ip = (imagestruct *)pwin->data;
119 ip->startTime = seconds();
121 logo.data = (char *) xlogo_bits;
122 logo.width = xlogo_width;
123 logo.height = xlogo_height;
124 logo.bytes_per_line = (xlogo_width + 7) / 8;
126 XGetWindowAttributes(dsp, pwin->w, &xgwa);
127 ip->width = xgwa.width;
128 ip->height = xgwa.height;
129 ip->ncols = ip->width / xlogo_width;
130 ip->nrows = ip->height / xlogo_height;
131 ip->iconmode = (ip->ncols < 2 || ip->nrows < 2);
135 ip->iconcount = 1; /* icon mode */
137 ip->xb = (ip->width - xlogo_width * ip->ncols) / 2;
138 ip->yb = (ip->height - xlogo_height * ip->nrows) / 2;
139 ip->iconcount = batchcount;
141 XSetForeground(dsp, pwin->gc, BlackPixelOfScreen(pwin->perscreen->screen));
142 XFillRectangle(dsp, pwin->w, pwin->gc, 0, 0, ip->width, ip->height);