1/* 2 * Copyright 1988 by Evans & Sutherland Computer Corporation, 3 * Salt Lake City, Utah 4 * Portions Copyright 1989 by the Massachusetts Institute of Technology 5 * Cambridge, Massachusetts 6 * 7 * Copyright 1992 Claude Lecommandeur. 8 */ 9 10/********************************************************************** 11 * 12 * $XConsortium: gc.c,v 1.22 91/01/09 17:13:12 rws Exp $ 13 * 14 * Open the fonts and create the GCs 15 * 16 * 31-Mar-88 Tom LaStrange Initial Version. 17 * 18 * Do the necessary modification to be integrated in ctwm. 19 * Can no longer be used for the standard twm. 20 * 21 * 22-April-92 Claude Lecommandeur. 22 * 23 * 24 **********************************************************************/ 25 26#include "ctwm.h" 27 28#include <stdio.h> 29 30#include "gram.tab.h" 31#include "screen.h" 32#include "gc.h" 33 34/*********************************************************************** 35 * 36 * Procedure: 37 * CreateGCs - open fonts and create all the needed GC's. I only 38 * want to do this once, hence the first_time flag. 39 * 40 *********************************************************************** 41 */ 42 43void CreateGCs(void) 44{ 45 static ScreenInfo *prevScr = NULL; 46 XGCValues gcv; 47 unsigned long gcm; 48 static unsigned char greypattern [] = {0x0f, 0x05, 0x0f, 0x0a}; 49 Pixmap greypixmap; 50 static char dashlist [2] = {1, 1}; 51 52 if(!Scr->FirstTime || prevScr == Scr) { 53 return; 54 } 55 56 prevScr = Scr; 57 58 /* create GC's */ 59 60 gcm = 0; 61 gcm |= GCFunction; 62 gcv.function = GXxor; 63 gcm |= GCLineWidth; 64 gcv.line_width = 0; 65 gcm |= GCForeground; 66 gcv.foreground = Scr->XORvalue; 67 gcm |= GCSubwindowMode; 68 gcv.subwindow_mode = IncludeInferiors; 69 70 Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 71 72 gcm = 0; 73 gcm |= GCForeground; 74 gcv.foreground = Scr->MenuC.fore; 75 gcm |= GCBackground; 76 gcv.background = Scr->MenuC.back; 77 78 Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 79 80 gcm = 0; 81 gcm |= GCPlaneMask; 82 gcv.plane_mask = AllPlanes; 83 /* 84 * Prevent GraphicsExpose and NoExpose events. We'd only get NoExpose 85 * events anyway; they cause BadWindow errors from XGetWindowAttributes 86 * call in FindScreenInfo (events.c) (since drawable is a pixmap). 87 */ 88 gcm |= GCGraphicsExposures; 89 gcv.graphics_exposures = False; 90 gcm |= GCLineWidth; 91 gcv.line_width = 0; 92 93 Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 94 95 greypixmap = XCreatePixmapFromBitmapData(dpy, Scr->Root, 96 (char *) greypattern, 4, 4, 1, 0, 1); 97 98 if(Scr->Monochrome != COLOR) { 99 gcm = 0; 100 gcm |= GCStipple; 101 gcv.stipple = greypixmap; 102 gcm |= GCFillStyle; 103 gcv.fill_style = FillOpaqueStippled; 104 gcm |= GCForeground; 105 gcv.foreground = Scr->Black; 106 gcm |= GCBackground; 107 gcv.background = Scr->White; 108 Scr->BorderGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 109 XSetDashes(dpy, Scr->BorderGC, 1, dashlist, 2); 110 } 111 else if(Scr->BeNiceToColormap) { 112 gcm = 0; 113 gcm |= GCLineStyle; 114 gcv.line_style = LineDoubleDash; 115 Scr->BorderGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); 116 XSetDashes(dpy, Scr->BorderGC, 0, dashlist, 2); 117 } 118 else { 119 Scr->BorderGC = XCreateGC(dpy, Scr->Root, 0, NULL); 120 } 121} 122