static void newpen(int w) { if (w < 0 || w > 10) w = 1; if (!c_flg || mono_flg) { line_width = l_width[w]; XSetLineAttributes(display, gc, line_width, line_style, CapButt, join_style); } else XSetForeground(display, gc, get_color_pix(c_name[w])); }
void init_window(int argc, char *argv[]) { unsigned long get_color_pix(char *color_name); screen = DefaultScreen(display); #if defined(HAVE_BZERO) && !defined(HAVE_MEMSET) bzero(&xsh, sizeof(xsh)); #else memset(&xsh, 0, sizeof(xsh)); #endif if (geometry) { int bitmask; bitmask = XGeometry(display, screen, geometry, NULL, bwidth, 1, 1, 1, 1, &(xsh.x), &(xsh.y), &(xsh.width), &(xsh.height)); if (bitmask & (XValue | YValue)) { xsh.flags |= USPosition; } if (bitmask & (WidthValue | HeightValue)) { xsh.flags |= USSize; } } else { xsh.flags = USPosition | PSize; if (!landscape) { xsh.width = XLENG / shrink; xsh.height = YLENG / shrink; xsh.x = X0; xsh.y = Y0; } else { xsh.width = YLENG / shrink; xsh.height = XLENG / shrink; xsh.x = X0_LAND; xsh.y = Y0; } } /** Color **/ #ifdef COLOR_BUG reverse = 1; #endif if (DisplayPlanes(display, screen) >= 3) { c_flg = 1; if (!reverse) { forepix = get_color_pix(fore_color); backpix = get_color_pix(back_color); highpix = get_color_pix(high_color); brdrpix = get_color_pix(brdr_color); mouspix = get_color_pix(mous_color); } else { forepix = get_color_pix(back_color); backpix = get_color_pix(fore_color); highpix = get_color_pix(high_color); brdrpix = get_color_pix(brdr_color); mouspix = get_color_pix(mous_color); } } else { if (!reverse) { forepix = BlackPixel(display, screen); highpix = BlackPixel(display, screen); backpix = WhitePixel(display, screen); brdrpix = BlackPixel(display, screen); mouspix = BlackPixel(display, screen); } else { forepix = WhitePixel(display, screen); highpix = WhitePixel(display, screen); backpix = BlackPixel(display, screen); brdrpix = WhitePixel(display, screen); mouspix = WhitePixel(display, screen); } } /** Generate Window **/ main_window = XCreateSimpleWindow(display, DefaultRootWindow(display), xsh.x, xsh.y, xsh.width, xsh.height, bwidth, brdrpix, backpix); XSetStandardProperties(display, main_window, windowtitle, windowtitle, None, argv, argc, &xsh); /* winatt.bit_gravity = SouthWestGravity; */ XChangeWindowAttributes(display, main_window, CWBitGravity, &winatt); /** Map Window **/ XSelectInput(display, main_window, StructureNotifyMask); XMapWindow(display, main_window); for (;;) { XNextEvent(display, &ev); if (ev.type == MapNotify) break; } XSelectInput(display, main_window, ButtonPressMask | PointerMotionMask | KeyPressMask | ExposureMask); /* KeyReleaseMask|ExposureMask|StructureNotifyMask); */ /** Cursor **/ watch_cur = XCreateFontCursor(display, XC_watch); XDefineCursor(display, main_window, watch_cur); /** GC **/ gcval.line_width = 1; gc = XCreateGC(display, main_window, GCLineWidth, &gcval); XSetFunction(display, gc, GXcopy); XSetGraphicsExposures(display, gc, False); XSetForeground(display, gc, forepix); XSetBackground(display, gc, backpix); font = XLoadFont(display, f_name[fno]); XSetFont(display, gc, font); }