|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1987, 1988, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/***********************************************************
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
All Rights Reserved
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, and distribute this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose and without fee is hereby granted,
|
|
Packit Service |
2b1f13 |
provided that the above copyright notice appear in all copies and that
|
|
Packit Service |
2b1f13 |
both that copyright notice and this permission notice appear in
|
|
Packit Service |
2b1f13 |
supporting documentation, and that the name of Digital not be
|
|
Packit Service |
2b1f13 |
used in advertising or publicity pertaining to distribution of the
|
|
Packit Service |
2b1f13 |
software without specific, written prior permission.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
Packit Service |
2b1f13 |
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
Packit Service |
2b1f13 |
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
Packit Service |
2b1f13 |
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
Packit Service |
2b1f13 |
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
Packit Service |
2b1f13 |
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
Packit Service |
2b1f13 |
SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
******************************************************************/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <stdio.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Intrinsic.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/Drawing.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _PixmapCache {
|
|
Packit Service |
2b1f13 |
Screen *screen;
|
|
Packit Service |
2b1f13 |
Pixmap pixmap;
|
|
Packit Service |
2b1f13 |
Pixel foreground, background;
|
|
Packit Service |
2b1f13 |
unsigned int depth;
|
|
Packit Service |
2b1f13 |
int ref_count;
|
|
Packit Service |
2b1f13 |
struct _PixmapCache *next;
|
|
Packit Service |
2b1f13 |
} CacheEntry;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
static CacheEntry *pixmapCache = NULL;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Pixmap
|
|
Packit Service |
2b1f13 |
XmuCreateStippledPixmap(Screen *screen, Pixel fore, Pixel back,
|
|
Packit Service |
2b1f13 |
unsigned int depth)
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Creates a stippled pixmap of specified depth
|
|
Packit Service |
2b1f13 |
* caches these so that multiple requests share the pixmap
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
register Display *display = DisplayOfScreen(screen);
|
|
Packit Service |
2b1f13 |
CacheEntry *cachePtr;
|
|
Packit Service |
2b1f13 |
Pixmap stippled_pixmap;
|
|
Packit Service |
2b1f13 |
static unsigned char pixmap_bits[] = {
|
|
Packit Service |
2b1f13 |
0x02, 0x01,
|
|
Packit Service |
2b1f13 |
};
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Creates a stippled pixmap of depth DefaultDepth(screen)
|
|
Packit Service |
2b1f13 |
* caches these so that multiple requests share the pixmap
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define pixmap_width 2
|
|
Packit Service |
2b1f13 |
#define pixmap_height 2
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* see if we already have a pixmap suitable for this screen */
|
|
Packit Service |
2b1f13 |
for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) {
|
|
Packit Service |
2b1f13 |
if (cachePtr->screen == screen && cachePtr->foreground == fore &&
|
|
Packit Service |
2b1f13 |
cachePtr->background == back && cachePtr->depth == depth)
|
|
Packit Service |
2b1f13 |
return( cachePtr->ref_count++, cachePtr->pixmap );
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
stippled_pixmap = XCreatePixmapFromBitmapData (display,
|
|
Packit Service |
2b1f13 |
RootWindowOfScreen(screen), (char *)pixmap_bits,
|
|
Packit Service |
2b1f13 |
pixmap_width, pixmap_height, fore, back, depth);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* and insert it at the head of the cache */
|
|
Packit Service |
2b1f13 |
cachePtr = XtNew(CacheEntry);
|
|
Packit Service |
2b1f13 |
cachePtr->screen = screen;
|
|
Packit Service |
2b1f13 |
cachePtr->foreground = fore;
|
|
Packit Service |
2b1f13 |
cachePtr->background = back;
|
|
Packit Service |
2b1f13 |
cachePtr->depth = depth;
|
|
Packit Service |
2b1f13 |
cachePtr->pixmap = stippled_pixmap;
|
|
Packit Service |
2b1f13 |
cachePtr->ref_count = 1;
|
|
Packit Service |
2b1f13 |
cachePtr->next = pixmapCache;
|
|
Packit Service |
2b1f13 |
pixmapCache = cachePtr;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return( stippled_pixmap );
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
XmuReleaseStippledPixmap(Screen *screen, Pixmap pixmap)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
register Display *display = DisplayOfScreen(screen);
|
|
Packit Service |
2b1f13 |
CacheEntry *cachePtr, **prevP;
|
|
Packit Service |
2b1f13 |
for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) {
|
|
Packit Service |
2b1f13 |
if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) {
|
|
Packit Service |
2b1f13 |
if (--cachePtr->ref_count == 0) {
|
|
Packit Service |
2b1f13 |
XFreePixmap( display, pixmap );
|
|
Packit Service |
2b1f13 |
*prevP = cachePtr->next;
|
|
Packit Service |
2b1f13 |
XtFree( (char*)cachePtr );
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
prevP = &cachePtr->next;
|
|
Packit Service |
2b1f13 |
cachePtr = *prevP;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|