gc.c revision 3e747e6d
1/*****************************************************************************/ 2/* 3 4Copyright 1989, 1998 The Open Group 5 6Permission to use, copy, modify, distribute, and sell this software and its 7documentation for any purpose is hereby granted without fee, provided that 8the above copyright notice appear in all copies and that both that 9copyright notice and this permission notice appear in supporting 10documentation. 11 12The above copyright notice and this permission notice shall be included in 13all copies or substantial portions of the Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall not be 23used in advertising or otherwise to promote the sale, use or other dealings 24in this Software without prior written authorization from The Open Group. 25 26*/ 27/* Copyright 1988 by Evans & Sutherland Computer Corporation, */ 28/* Salt Lake City, Utah */ 29/* Cambridge, Massachusetts */ 30/* */ 31/* All Rights Reserved */ 32/* */ 33/* Permission to use, copy, modify, and distribute this software and */ 34/* its documentation for any purpose and without fee is hereby */ 35/* granted, provided that the above copyright notice appear in all */ 36/* copies and that both that copyright notice and this permis- */ 37/* sion notice appear in supporting documentation, and that the */ 38/* name of Evans & Sutherland not be used in advertising */ 39/* in publicity pertaining to distribution of the software without */ 40/* specific, written prior permission. */ 41/* */ 42/* EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD */ 43/* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- */ 44/* ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND */ 45/* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- */ 46/* AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA */ 47/* OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER */ 48/* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE */ 49/* OR PERFORMANCE OF THIS SOFTWARE. */ 50/*********************************************************************(*****/ 51/* $XFree86: xc/programs/twm/gc.c,v 1.5 2001/01/17 23:45:06 dawes Exp $ */ 52 53 54/********************************************************************** 55 * 56 * $Xorg: gc.c,v 1.4 2001/02/09 02:05:36 xorgcvs Exp $ 57 * 58 * Open the fonts and create the GCs 59 * 60 * 31-Mar-88 Tom LaStrange Initial Version. 61 * 62 **********************************************************************/ 63 64#include <stdio.h> 65#include "twm.h" 66#include "util.h" 67#include "screen.h" 68#include "gc.h" 69 70/** \fn CreateGCs 71 * open fonts and create all the needed GC's. I only 72 * want to do this once, hence the first_time flag. 73 */ 74void 75CreateGCs() 76{ 77 static ScreenInfo *prevScr = NULL; 78 XGCValues gcv; 79 unsigned long gcm; 80 81 if (!Scr->FirstTime || prevScr == Scr) 82 return; 83 84 prevScr = Scr; 85 86 /* create GC's */ 87 88 gcm = 0; 89 gcm |= GCFunction; gcv.function = GXxor; 90 gcm |= GCLineWidth; gcv.line_width = 0; 91 gcm |= GCForeground; gcv.foreground = Scr->XORvalue; 92 gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors; 93 94 Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 95 96 gcm = 0; 97 gcm |= GCForeground; gcv.foreground = Scr->MenuC.fore; 98 gcm |= GCBackground; gcv.background = Scr->MenuC.back; 99 if (!use_fontset) 100 {gcm |= GCFont; gcv.font = Scr->MenuFont.font->fid;} 101 102 Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 103 104 gcm = 0; 105 gcm |= GCPlaneMask; gcv.plane_mask = AllPlanes; 106 /* 107 * Prevent GraphicsExpose and NoExpose events. We'd only get NoExpose 108 * events anyway; they cause BadWindow errors from XGetWindowAttributes 109 * call in FindScreenInfo (events.c) (since drawable is a pixmap). 110 */ 111 gcm |= GCGraphicsExposures; gcv.graphics_exposures = False; 112 gcm |= GCLineWidth; gcv.line_width = 0; 113 114 Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 115} 116